cart; if ( ! $cart ) { return $recalculate; } $coupons = $cart->get_coupons(); if ( empty( $coupons ) ) { return $recalculate; } foreach ( $coupons as $coupon ) { if ( ! $coupon instanceof \WC_Coupon ) { continue; } if ( ! $coupon->is_valid_for_product( $item['data'] ) ) { continue; } if ( get_post_meta( $coupon->get_id(), '_disable_tiered_pricing', true ) === 'yes' ) { return false; } } return $recalculate; } public function saveTieredPricingOption( $couponId ) { update_post_meta( $couponId, '_disable_tiered_pricing', isset( $_REQUEST['_disable_tiered_pricing'] ) ? 'yes' : 'no' ); } public function addTieredPricingOption( $couponId, $coupon ) { woocommerce_wp_checkbox( array( 'id' => '_disable_tiered_pricing', 'label' => __( 'Disable tiered pricing when the coupon is applied', 'woocommerce' ), 'description' => __( 'Check this option to don\'t apply tiered pricing in the cart when users have applied this coupon.', 'tier-pricing-table' ), 'value' => get_post_meta( $couponId, '_disable_tiered_pricing', true ), ) ); } public function getDescription(): string { return __( 'Disable tiered pricing for specific coupons.', 'tier-pricing-table' ); } public function getIcon(): string { return ''; } public function getSlug(): string { return 'coupons'; } }