I am trying to add up all of my added coupons to get a discount total in the checkout. I tried adding a variable at the top of the checkout template file and doing ++ for each entry but I throws errors.
Any ideas how to add the values to a variable to get a total?
The checkout totals regenerate if you alter a value so I found my answer being outputted each time the loop runs.
My code:
<?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><?php $helloworld = wc_cart_totals_coupon_html( $coupon )++; ?></td>
</tr>
<?php endforeach; ?>