Skip to content

Instantly share code, notes, and snippets.

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 jaworowicz/d3d085a19903d853f616045a57ba6991 to your computer and use it in GitHub Desktop.
Save jaworowicz/d3d085a19903d853f616045a57ba6991 to your computer and use it in GitHub Desktop.
Automatyczne kupony rabatowe WooCommerce
add_action( 'woocommerce_before_cart', 'jcz_automatyczny_kupon' );
function jcz_automatyczny_kupon() {
global $woocommerce;
$kupon = 'jaworowicz'; // Zmien nazwę kodu
if ( $woocommerce->cart->has_discount( $kupon ) ) return;
if ( $woocommerce->cart->cart_contents_total >= 1 ) {
$woocommerce->cart->add_discount( $kupon );
$woocommerce->show_messages();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment