Month: August 2013

Woocommerce: add to cart ajax not working

Add this code in your function.php

wp_dequeue_script( 'wc-add-to-cart-variation' );
wp_dequeue_script( 'wc-cart' );
Advertisements

WooCommerce: How to apply discount coupon automatically

Step 1: Create a coupon (http://docs.woothemes.com/document/coupon-management/)

 

Step 2: Add this code in your theme function.php

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();
    }

}