Skip to content

Instantly share code, notes, and snippets.

@smeric
smeric / woocommerce-add-to-cart-before-applying-coupon.php
Last active July 23, 2018 09:16
Made to be used with the "Smart Coupons" WooCommerce extention. If we apply coupon from url and the coupon is dedicated to a specific product, the coupon is not applied if the product is not already in cart. So, before applying the coupon we add this product to cart.
<?php
/**
* Add to cart before applying coupon
*
* Made to be used with the "Smart Coupons" WooCommerce extention.
* If we apply coupon from url and the coupon is dedicated to a specific product, the coupon is not applied if
* the product is not already in cart. So, before applying the coupon we add this product to cart.
*
* @link
* @version 1.0.1
@mikejolley
mikejolley / gist:2044101
Last active May 18, 2021 17:02
WooCommerce - Show number of items in cart and total
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>