Support » Plugin: WC Gift Packaging » Custom position

  • Resolved matuh

    (@matuh)


    I’m new to WC and I can’t figure out how to use this code to change the position of the checkbox:

    add_filter( 'wc_gift_packaging_field_hook', 'custom_hook_position' );
    
    function custom_hook_position( $text ) {
    
        return 'woocommerce_after_order_notes';
    
    }

    How can I move the checkbox after the notes of the order box?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author GDY

    (@grandy)

    Aww man … sorry matuh. Totally forget that i have to subscribe to the support forums of my own plugins manually to get notifications. So this may be too late:

    Woocommerce as WordPress itself has some hooks on wich actions can be bound to. By default the gift checkbox is bound to woocommerce_after_checkout_billing_form.

    With the wc_gift_packaging_field_hook filter you can change that hook.

    Check out this page for the different hooks in the Woocommerce checkout.

    If you bind the function to the wrong hook it may cause some errors so do it locally if possible.

    You probably mean the hook woocommerce_review_order_before_submit. But thats not possible right now because there is a parameter missing that is needed to set the checkbox depending on previous input ($wccs_custom_checkout_field_pro).

    I probably make a update that this is optional and that you just have to check this each time if the variable isn’t available.

    Plugin Author GDY

    (@grandy)

    Ok. So i’ve just released version 1.1 wich allows you to do simply this:

    add_filter( 'wc_gift_packaging_field_hook', 'custom_hook_position' );
    
    function custom_hook_position( $hook ) {
    
        return 'woocommerce_review_order_before_submit';
    
    }

    I think you need woocommerce_review_order_before_submit or woocommerce_review_order_after_submit. Check out more possible hooks at this page.

    • This reply was modified 2 years, 7 months ago by GDY.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom position’ is closed to new replies.