• Resolved rafamerino

    (@rafamerino)


    I’m trying to change wc-ac checkbox in checkout to the bottom, after “Terms and Conditions” checkbox.

    I’ve changed line #53 in wc-ac-hook.php from:
    add_action('woocommerce_before_order_notes', array($this, 'marketing_checkout_field'));
    to:
    add_action('woocommerce_checkout_after_terms_and_conditions', array($this, 'marketing_checkout_field'));

    But page says “Fatal error” in checkout.

    How can I solve this?

    PS: I’m using WPocean theme, but this theme doesn’t rewrite checkout’s woocommerce

    • This topic was modified 3 years, 10 months ago by rafamerino.
    • This topic was modified 3 years, 10 months ago by rafamerino.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author mtreherne

    (@mtreherne)

    Hi there,

    The hook ‘woocommerce_checkout_after_terms_and_conditions’ does not pass the $checkout parameter. You can only use hooks that pass this parameter as the ‘marketing_checkout_field’ function in wc-ac-hook expects the parameter (it needs to get the field value from any submitted form).

    You may find another hook that works for you. Read below for the preferred approach that I have cut and paste from the FAQ on opt in to marketing. If you can’t find a suitable hook then I suggest looking at the WooCommerce Checkout Field Editor.

    “Note that if you want to change the position of the checkbox or are using tools such as WooCommerce Checkout Field Editor then you may still use this capability using the following steps:

    1. Keep (or set) the ‘Signup to Marketing’ option ‘No’ to suppress the default checkbox
    2. Enter the ‘Marketing Form ID’ (each form has a unique ID number on ActiveCampaign)
    3. Create your own custom checkbox field on the checkout page with the name wc_ac_marketing_checkbox”

    Hope this helps,
    Matt

    Thread Starter rafamerino

    (@rafamerino)

    Thanks for your time/reply, Matt.

    In case anyone is searching for a solution, here’s what I’ve done:

    
    /* Custom checkbox for WC-AC Hook, by @rafamerino */
    add_action( 'woocommerce_review_order_before_submit', 'rm_add_checkout_checkbox', 10 );
    function rm_add_checkout_checkbox() {
    
        woocommerce_form_field( 'wc_ac_marketing_checkbox', array(
           'type'          => 'checkbox',
           'class'         => array('form-row mycheckbox'),
           'label_class'   => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
           'input_class'   => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
           'required'      => false,
           'label'         => 'Text for the checkbox',
        ));    
    }
    • This reply was modified 3 years, 10 months ago by rafamerino.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change checkbox position in checkout (after terms & conditions)’ is closed to new replies.