Skip to content

Instantly share code, notes, and snippets.

@rockdrigo
Created November 27, 2017 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rockdrigo/4c21aa58559fcbf0ebc1ce640d79d366 to your computer and use it in GitHub Desktop.
Save rockdrigo/4c21aa58559fcbf0ebc1ce640d79d366 to your computer and use it in GitHub Desktop.
Descuento automatico al agregar al carrito de compras WooCommerce
//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