• Resolved Ibby

    (@ibby)


    Hi,

    When devs are using the Klaviyo plugin and want to move the Checkout page checkbox due to custom designs, we get a fatal error when removing the filter and re-adding it into a different location i.e.

    add_filter( 'woocommerce_review_order_before_submit', 'kl_checkbox_custom_checkout_field' );
    remove_filter( 'woocommerce_checkout_fields', 'kl_checkbox_custom_checkout_field' );

    Could you please shed some light on why this is happening? We want to have the checkbox show up below our terms and conditions checkbox (with is mandatory so no chance of the customer missing it).

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author klaviyo

    (@klaviyo)

    Hi @ibby

    Without the specific error message I can only speculate on the issue here however I think my explanation below should likely cover the problem you encountered.

    The ‘woocommerce_checkout_fields’ filter that Klaviyo’s plugin hooks into supplies an argument to the callback function, an array of checkout fields. Klaviyo’s callback method, ‘kl_checkbox_custom_checkout_field’, manipulates that array by adding the new billing form field and returns it. When you try to hook that callback into a different action/filter the arguments passed into the function are different hence the error you get.

    If you wish to re-order the billing fields in the checkout form you’ll want to adjust the priority of those fields, like this, in your theme’s functions.php file:

    /**
     * Move the email field and Klaviyo's email subscription checkbox
     * to the top of the billing details form during checkout.
     */
    add_filter( 'woocommerce_billing_fields', 'klaviyo_move_billing_email_and_checkbox', 10, 1 );
    
    function klaviyo_move_billing_email_and_checkbox( $address_fields ) {
        $address_fields['billing_email']['priority'] = 5;
        $address_fields['kl_newsletter_checkbox']['priority'] = 6;
        return $address_fields;
    }

    Best,
    Klaviyo

    Ross

    (@rmdglasgow)

    I’m also having the same issue as the OP. I want to move the checkbox out of the billing fields and onto the terms section, not change the order of the billing fields.

    This isn’t currently possible as you are adding the checkbox to the $fields['billing'] array. This is not a billing field so it doesn’t belong here, could you please consider a different implementation?

    I have a custom checkout that hides all the billing fields for logged-in customers, so this prevents the checkbox from appearing.

    If you were to add the checkbox via woocommerce_checkout_before_terms_and_conditions
    or woocommerce_review_order_before_submit it would prevent it from breaking on custom checkouts.

    Thanks!

    • This reply was modified 3 years, 7 months ago by Ross.
    Plugin Author klaviyo

    (@klaviyo)

    Hi @rmdglasgow

    Thank you for the additional feedback. Yes, you’re right that the consent checkboxes cannot be moved outside the billing fields. This is intentional to allow for the checkbox to be reordered in conjunction with the input field e.g. email and phone number.

    However, I can also see the value in maintaining the consent checkboxes outside of the billing fields to allow for placement near the TOC as you mentioned.

    I have created a feature request for our team to consider optionally allowing for these consent checkboxes to be inserted within or outside of the billing fields.

    Best,
    Klaviyo

    Hi, I would also like to move the klaviyo checkbox below the terms and conditions checkbox. How do I do that? Is your team working on this update?

    Hi @klaviyo ,

    Is there any update on this?

    This ability would be quite important. Currently I am stuck with mailchimp until I can get this sorted.

    I use Fluid Checkout for WooCommerce plugin, and it just doesn’t make any sense not to have the opt-in form with the very first step right after the the email field. Like in shopify.

    With ‘MC4WP: Mailchimp for WordPress’ there are multiple options to choose from where we want to place the opt-in form within the checkout page.

    Kind Regards
    Sandor

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Move the Checkout opt-in checkbox’ is closed to new replies.