• Hi there
    I am using woocommerce + Cheope to create a website but I am struggling to automatically apply 2 levels of discount in the shopping cart. I have found the following bit of code but it needs amending to meet my needs…..

    add_action( 'woocommerce_before_cart', 'apply_matched_coupons' );
    
    function apply_matched_coupons() {
        global $woocommerce;
    
        $coupon_code = '10percent'; // your coupon code here
    
        if ( $woocommerce->cart->has_discount( $coupon_code ) ) return;
    
        if ( $woocommerce->cart->cart_contents_total >= 500 ) {
            $woocommerce->cart->add_discount( $coupon_code );
            $woocommerce->show_messages();
        }
    
    }

    I need a 10% discount coupon I have created to automatically apply if the cart totals more than £200 – and a 15% discount coupon to be applied if the cart totals more than £300 without the customer having to enter a code.

    I cannot post a link to the site at the moment as it is being developed on a temporary IP address but I will be able to allow access to anyone who can help me out. Please someone….anyone 🙁

  • The topic ‘Automatically apply coupons in cart’ is closed to new replies.