Skip to content

Instantly share code, notes, and snippets.

@Luminus
Created November 20, 2017 06:27
Show Gist options
  • Save Luminus/8b1340ac28afd7db3d27f6bb305b90d2 to your computer and use it in GitHub Desktop.
Save Luminus/8b1340ac28afd7db3d27f6bb305b90d2 to your computer and use it in GitHub Desktop.
Hide Coupon Form from the Cart & Checkout Pages if there's a Deposit Product in the Cart
<?php
// hide coupon form from the cart and checkout pages if there's a deposit product in the cart
function hide_coupon_field( $enabled ) {
if ( is_cart() || is_checkout() ) {
if ( class_exists( 'WC_Deposits_Cart_Manager' ) ) {
if ( WC_Deposits_Cart_Manager::has_deposit() ) {
$enabled = false;
}
}
}
return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment