|
|
|
@ -118,6 +118,8 @@ class Wc_Cdp_Public { |
|
|
|
{ |
|
|
|
$product = wc_get_product( $product_id ); |
|
|
|
|
|
|
|
if ( !$product->get_meta( '_wc_cdp_bundle_coupon' ) ) return null; |
|
|
|
|
|
|
|
$bundle_coupon = new WC_Coupon( $product->get_meta( '_wc_cdp_bundle_coupon' ) ); |
|
|
|
|
|
|
|
$bundle_coupon_type = $bundle_coupon->get_discount_type(); |
|
|
|
@ -131,10 +133,6 @@ class Wc_Cdp_Public { |
|
|
|
|
|
|
|
private function should_display_bundle_modal($product_id) |
|
|
|
{ |
|
|
|
$bundle_coupon = $this->get_bundle_coupon($product_id); |
|
|
|
|
|
|
|
if (!$bundle_coupon) return false; |
|
|
|
|
|
|
|
$bundle_products = $this->get_bundle_products($product_id); |
|
|
|
|
|
|
|
if (!$bundle_products) return false; |
|
|
|
@ -180,12 +178,15 @@ class Wc_Cdp_Public { |
|
|
|
|
|
|
|
$bundle_coupon = $this->get_bundle_coupon( $product->get_id() ); |
|
|
|
|
|
|
|
if ($bundle_coupon->get_discount_type() === 'percent') { |
|
|
|
$bundle_discount_price = $bundle_regular_price * ( 1 - $bundle_coupon->get_amount()/100 ); |
|
|
|
} else { |
|
|
|
$bundle_discount_price = $bundle_regular_price - $bundle_coupon->get_amount(); |
|
|
|
if ($bundle_coupon) { |
|
|
|
if ($bundle_coupon->get_discount_type() === 'percent') { |
|
|
|
$bundle_discount_price = $bundle_regular_price * ( 1 - $bundle_coupon->get_amount()/100 ); |
|
|
|
} else { |
|
|
|
$bundle_discount_price = $bundle_regular_price - $bundle_coupon->get_amount(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
require('partials/product-bundle-modal.php'); |
|
|
|
} |
|
|
|
|
|
|
|
@ -214,7 +215,9 @@ class Wc_Cdp_Public { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
WC()->cart->apply_coupon( $_POST['wc_cdp_bundle_coupon'] ); |
|
|
|
if ( isset( $_POST['wc_cdp_bundle_coupon'] ) && $_POST['wc_cdp_bundle_coupon'] ) { |
|
|
|
WC()->cart->apply_coupon( $_POST['wc_cdp_bundle_coupon'] ); |
|
|
|
} |
|
|
|
|
|
|
|
wc_clear_notices(); |
|
|
|
|
|
|
|
|