2

I tried to call in the mini cart woocommerce_cart_totals() to get a coupon discount. But in mini cart it's not working. It's working only when I go to the cart page and refresh the page.

After this, discount in mini cart is working fine. But now I want to know, why it's not working in another page? And not working without cart page refresh?

<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
        <tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
            <th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
            <td data-title="<?php echo esc_attr( wc_cart_totals_coupon_label( $coupon, false ) ); ?>"><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
        </tr>
    <?php endforeach; ?>

view image - mini cart screenshot

user1195202
  • 1,423
  • 1
  • 16
  • 20
Vardan
  • 21
  • 3
  • Where is your code attempt? You are expected to provide your own real code attempt in your question… So search and try a lot before … See [how to ask](https://stackoverflow.com/help/how-to-ask) – LoicTheAztec Jul 30 '20 at 20:25

0 Answers0