'Ajax woocommerce remove coupon does not work in custom cart-totals.php

Ajax woocommerce remove coupon does not work in custom cart-totals.php

Here is code I used:

<div class="report-text-cntr-cart row mr-0 ml-0 <?php echo ( WC()->customer->has_calculated_shipping() ) ? 'calculated_shipping' : ''; ?>">

    <?php do_action( 'woocommerce_before_cart_totals' ); ?>
    <div class="col-xl-5 col-lg-4 col-md-4 col-sm-12 col-12 total-cntr cart-subtotal">
        <label>قیمت کل : </label>
        <span data-title="<?php esc_attr_e( 'Subtotal','woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></span>
    </div>
    <?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
        <div class="col-xl-2 col-lg-4 col-md-4 col-sm-12 col-12 send-cntr coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
            <label><?php wc_cart_totals_coupon_label( $coupon ); ?></label>
            <span data-title="<?php echo esc_attr( wc_cart_totals_coupon_label( $coupon, false ) ); ?>"><?php wc_cart_totals_coupon_html( $coupon ); ?></span>
        </div>
    <?php endforeach; ?>

code output ajax is:

?wc-ajax=remove_coupon

but applied coupon not removed after click on remove button.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source