Created
November 29, 2015 14:30
-
-
Save jacquesletesson/7b5c74fc52dfd84bb670 to your computer and use it in GitHub Desktop.
WooCommerce : Hide coupon code fields on checkout if no coupon publish.
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 | |
add_filter( 'woocommerce_coupons_enabled', 'restofrais_coupons_enabled_checkout' ); | |
if( ! function_exists('restofrais_coupons_enabled_checkout')){ | |
function restofrais_coupons_enabled_checkout($coupons_enabled){ | |
$args = array( | |
'post_type' => 'shop_coupon', | |
'post_status' => 'publish', | |
); | |
$postslist = get_posts( $args ); | |
if(empty($postslist)){ | |
return false; | |
} else { | |
return $coupons_enabled; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment