Created
November 27, 2017 03:57
-
-
Save rockdrigo/4c21aa58559fcbf0ebc1ce640d79d366 to your computer and use it in GitHub Desktop.
Descuento automatico al agregar al carrito de compras WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Cupón descuento automático | |
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' ); | |
function apply_matched_coupons() { | |
global $woocommerce; | |
$coupon_code = 'cupon_code'; // aquí tu código de cupón | |
if ( $woocommerce->cart->has_discount( $coupon_code ) ) return; | |
if ( $woocommerce->cart->cart_contents_total >= 1 ) { | |
$woocommerce->cart->add_discount( $coupon_code ); | |
$woocommerce->show_messages(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment