1

I've moved the coupon field in the cart from the items table to the cart totals table. Everything works fine so far. But after adding a code, the form doesn't show any error or success messages.

I tired to figure out why that's the case but couldn't find anything? Is there some javascript involved? Do I miss some classes?

Here's my current code:

<?php 
add_action( 'woocommerce_cart_totals_before_shipping', 'display_coupon_form_below_proceed_checkout', 100 );
function display_coupon_form_below_proceed_checkout() { ?>

   <?php if ( wc_coupons_enabled() ) { ?>
   <tr class="cart-discount-add">
        <th colspan="2">
            <a data-toggle="collapse" href="#collapseCartCoupon" role="button" aria-expanded="false" aria-controls="collapseCartCoupon">Add coupon code</a>
        </th>
    </tr>
    <tr class="cart-discount-form">
        <td colspan="2">
            <form class="woocommerce-coupon-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
                <div class="coupon collapse" id="collapseCartCoupon">
                <div class="input-group">
                    <input type="text" name="coupon_code" class="form-control input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" />
                    <div class="input-group-append">
                        <button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?></button>
                    </div>
                </div>

                </div>
            </form>
        </td>
    </tr>
    <?php } ?>

<?php } ?>
Cray
  • 5,307
  • 11
  • 70
  • 166

0 Answers0