Skip to content

Instantly share code, notes, and snippets.

@aimahdi
Created November 5, 2025 09:40
Show Gist options
  • Select an option

  • Save aimahdi/faf5b82664bca79d1d030f0920adc7f1 to your computer and use it in GitHub Desktop.

Select an option

Save aimahdi/faf5b82664bca79d1d030f0920adc7f1 to your computer and use it in GitHub Desktop.
Add custom field on FluentCart Checkout
<?php
add_action('fluent_cart/before_payment_methods', function($args) {
// Add your field here.....
// Example Field
$termsText = 'Yes, I\'d like to receive emails with exclusive offers and updates.';
?>
<div class="fct_checkout_marketing_opt_in" role="group" aria-labelledby="marketing_opt_in_label">
<label for="marketing_opt_in" class="fct_input_label fct_input_label_checkbox">
<input
data-fluent-cart-marketing-opt-in="yes"
type="checkbox"
class="fct-input fct-input-checkbox"
id="marketing_opt_in"
name="marketing_opt_in"
value="yes"
aria-label="<?php echo esc_attr($termsText); ?>"
>
<?php echo wp_kses_post($termsText); ?>
</label>
</div>
<?php
}, 10, 1);
add_filter('fluent_cart/checkout/validate_data', function($errors, $args){
// Validate data here
// $args['data']['marketing_opt_in']
//Example Validation
if(empty($args['data']['marketing_opt_in'])){
$errors['marketing_opt_in']['required'] = __('Marketing Opt-in is required', 'fluent-cart');
}
return $errors;
}, 10, 2);
add_action('fluent_cart/checkout/prepare_other_data', function($args){
//Save your data here
//$args['request_data']['marketing_opt_in']);
}, 10, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment