Last active
May 10, 2020 11:59
-
-
Save Oscar-Abad-Folgueira/af84930a1d1c178ae59f7773e11482f7 to your computer and use it in GitHub Desktop.
Forzar el uso de cupones en WooCommerce
This file contains 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
<?php | |
/** | |
* @snippet Forzar el uso de cupones en WooCommerce | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://www.oscarabadfolgueira.com/exigir-el-uso-de-cupones-en-woocommerce/ | |
*/ | |
add_action( 'woocommerce_check_cart_items', 'mandatory_coupon_code' ); | |
function mandatory_coupon_code() { | |
$applied_coupons = WC()->cart->get_applied_coupons(); | |
if( is_array($applied_coupons) && sizeof($applied_coupons) == 0 ) { | |
$message = __( 'Por favor, introduce un cupón.', 'woocommerce' ); | |
wc_add_notice( $message, 'error' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment