• Resolved mag8891w

    (@mag8891w)


    Hello, I have browsed many forums but the problem seems to exist.

    Is it possible to move enter coupon field from top notice somewhere more meaningful on the checkout form, for example do the same as in cart page view, enter coupon field appears under all products in cart.

    or after shipping options before order total
    or on top of checkout product list? but not the top notice.

    I can suggest this opencart development as one of the best checkouts I have seem as an example of good checkout layout ideas https://simpleopencart.com

    Many thanks

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    To move the coupon field, you’d need to modify the specific theme that you’re using, as the location is often set in the template files. Here’s a good place to get started:
    https://hollerwp.com/customize-woocommerce-checkout-page/

    Thread Starter mag8891w

    (@mag8891w)

    hello Hannah,

    thank for your reply, it is very useful but I have tested hooks below

    woocommerce_review_order_after_cart_contents
    woocommerce_review_order_before_cart_contents
    woocommerce_review_order_before_order_total
    woocommerce_review_order_after_order_total

    and they don’t seem to work as they should what happens I see two duplicate links under heading YOUR ORDER on top of the order review section and one of the links doesn’t work.

    I used this code without optional css styles to insert the coupon field, https://tamstradingpost.com/move-the-woocommerce-coupon-field-anywhere/

    Is it possible to check this issue please, as it would be useful to use the above hooks too.
    thank you.

    • This reply was modified 6 years, 4 months ago by mag8891w.
    Plugin Support con

    (@conschneider)

    Engineer

    We cannot help with applying custom code, but maybe this approach will be more successful for you: https://www.sellwithwp.com/move-the-woocommerce-coupon-field/

    Thread Starter mag8891w

    (@mag8891w)

    Hi Con, I am not asking help with custom code, I just ask to double check if the hooks above work as they should, as at the moment it doesn’t seem to work properly and apply custom code where it says, so I think it maybe a bug.

    Thank you

    Plugin Support con

    (@conschneider)

    Engineer

    Hi again,

    You can go here and search the site for the hooks you posted: https://docs.woocommerce.com/wc-apidocs/hook-docs.html – if they are listed you can be certain they work.

    Kind regards,

    This plugin:
    https://hookr.io/plugin/
    will show which hooks are firing where in a page, both WooCommerce and theme hooks. Sometimes theme templates can remove WooCommerce hooks.

    Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    @mag8891w,

    This is a factor of what hook you’re targetting. You can see a visual representation of available hooks on the Checkout page here – https://hooks.wpdesk.org/checkout/

    I was able to display the coupon form by targetting this hook woocommerce_review_order_before_payment.

    Here’s a screenshot of that – https://cld.wthms.co/C3Tr0h.

    Cheers

    Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    @mag8891w,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Hi Luminus, can you forward the full code you used here ? I tried this one without success :

    add_action( ‘woocommerce_review_order_before_payment’ , ‘woocommerce_coupons_enabled’ , 10 );

    It seem that the coupon hook is not the good one probably.

    If you have a remove-action for coupon on cart page it would be fantastic.

    See: wc-template-hooks.php line 212
    for the code which sets up the coupon hook.

    So you’ll need something like this. Sorry, not tested.

    remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
    add_action( 'woocommerce_review_order_before_payment' , 'woocommerce_checkout_coupon_form' , 10 );

    I finally found the right code. It removes the top of checkout.

    // REMOVE coupon field on the top of the cart and checkout page ***”’
    remove_action( ‘woocommerce_before_checkout_form’, ‘woocommerce_checkout_coupon_form’, 10 );

    // ADD Coupon field before payment ****
    add_action( ‘woocommerce_review_order_before_payment’ , ‘woocommerce_checkout_coupon_form’ , 10 );

    Sadly there seem no “remove” hook for the Cart coupon so I used CSS. If some hook exists, please let me know.
    > Same for the message “… click here to enter code”. that’s useless when moved with this code since it’s not active > coupon field is always visible.
    >> let me know if there is another way to make it active (without editing theme files).

    The issue you’ll find is that the coupon code is a separate form. Once you add it to woocommerce_review_order_before_payment, it will be inside the checkout form. This means that the “Apply Coupon” button will submit the order form instead of applying the coupon. I’m dealing with the same issue. I recommend creating a modal to input the coupon so it doesn’t nest a form inside a form.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Move coupon enter field’ is closed to new replies.