2

I have tried removeing the form-coupon.php under the checkout template in woocommerce with this code on the child theme functions.php file with this code:

add_filter( 'woocommerce_review_order_before_payment' , 'coupon_code' );
 
function coupon_code() {
    if ( ! wc_coupons_enabled() ) { // @codingStandardsIgnoreLine.
    return;
    }
?>

<div class="coupon_code_form">
<form class="checkout_coupon woocommerce-form-coupon" method="post" style="display:none">
    <h4>ברשותך קוד קופון? הזיני כאן<h4/>
        <div id="coupon_redeem_form">
        <input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( 'הזיני קוד קופון', 'woocommerce' ); ?>" id="coupon_code" value="" />
        <button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_html_e( 'Apply coupon', 'woocommerce' ); ?></button>
    </div>
    <div class="clear"></div>
</form>
</div>
<?php
}

For some reasons the form is shown but isn't sending out post, why this could happen?

Ruvee
  • 8,611
  • 4
  • 18
  • 44
Site Lab
  • 35
  • 5

1 Answers1

2

You could change its location by removing it from the top of the page, and adding it back in, at the bottom of the page.

You could remove the coupon form using the following code:

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

And in order to add it back, after order review section, you could use the following code:

add_action('woocommerce_checkout_order_review', 'woocommerce_checkout_coupon_form', 5);

Or you could change the woocommerce_checkout_order_review hook according to where you would like to see the coupon form.

Code goes onto the functions.php file of your child theme!

This answer has been tested and works. Let me know if you could get it to work too!

Ruvee
  • 8,611
  • 4
  • 18
  • 44
  • It definitely works but we needed to remove some functionally from the coupon form, I think the function 'coupon_code' isn't working properly – Site Lab Oct 26 '21 at 13:16
  • The form isnt sumbitting, see for yourself -> https://woocommerce-620267-2036098.cloudwaysapps.com/checkout/ – Site Lab Oct 26 '21 at 13:23
  • Does any of these links help you? [This](https://stackoverflow.com/a/47018982/15040627), and [this](https://stackoverflow.com/a/62894898/15040627). – Ruvee Oct 31 '21 at 13:01
  • No actually, I tried both, this is the last one on the site -> https://stackoverflow.com/questions/62893614/move-coupon-form-before-subtotal-in-woocommerce-checkout/62894898#62894898 – Site Lab Nov 03 '21 at 17:00
  • If I moved the hook to `woocommerce_checkout_order_review` the form doesn't submit – Site Lab Nov 04 '21 at 14:19