4

I have tried many coded to do this but not working at all. I tried to edit cart.php & cart-totals.php file to move apply coupon field form into cart total box before shipping calculated. But nothing work. Below is mentioned a code I have used but this code not applying coupon using ajax. Page gets reloaded when click on apply coupon...any help would be appreciated!

<?php if ( wc_coupons_enabled() ) { ?>
            <form action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
                <label style="text-align:left" for="coupon_code"><?php esc_html_e( 'Coupon Code', 'woocommerce' ); ?></label><br>
                <p>
                    <input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" id="coupon_code" style="float:left;width:60%" />
                    <button type="submit" style="float:right" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_html_e( 'Apply coupon', 'woocommerce' ); ?></button>
                    <?php do_action( 'woocommerce_cart_coupon' ); ?>
                </p>
                <div class="clear"></div>
            </form>
        <?php } ?>

I used also this links code but didn't worked add coupon code in cart totals woocommerce

0 Answers0