Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jacquesletesson/7b5c74fc52dfd84bb670 to your computer and use it in GitHub Desktop.
Save jacquesletesson/7b5c74fc52dfd84bb670 to your computer and use it in GitHub Desktop.
WooCommerce : Hide coupon code fields on checkout if no coupon publish.
<?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