From af12cd452516c3188ca6252dd96a3b287dc9d1b5 Mon Sep 17 00:00:00 2001 From: Habibillah Date: Fri, 17 Jun 2016 14:19:40 +0700 Subject: [PATCH] show hide discount info in check out mode --- classes/client-fixed-quantity-price.php | 35 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/classes/client-fixed-quantity-price.php b/classes/client-fixed-quantity-price.php index 5f436f0..af918e6 100644 --- a/classes/client-fixed-quantity-price.php +++ b/classes/client-fixed-quantity-price.php @@ -298,22 +298,31 @@ public function filter_subtotal_price($price, $cart_item) */ public function order_formatted_line_subtotal($price, $product) { - $productId = WoofixUtility::getActualId($product); - $fixedPriceData = WoofixUtility::isFixedQtyPrice($productId); - if ($fixedPriceData !== false) { - $discount = 0; + if (get_option(WOOFIXOPT_SHOW_DISC) === WOOFIXCONF_SHOW_DISC) { - foreach ($fixedPriceData['woofix'] as $disc) { - if ($disc['woofix_qty'] == $product['qty']) { - $discount = $disc['woofix_disc']; - } - } + $productId = WoofixUtility::getActualId($product); + $fixedPriceData = WoofixUtility::isFixedQtyPrice($productId); + if ($fixedPriceData !== false) { + + /** @noinspection PhpUnusedLocalVariableInspection */ + $discount = "0%"; - $newPrice = "$price "; - $newPrice .= sprintf(__("(Incl. %s%% discount)", "woofix"), $discount) . ""; - $newPrice .= ""; + foreach ($fixedPriceData['woofix'] as $disc) { + if ($disc['woofix_qty'] == $product['qty']) { - return $newPrice; + /** @noinspection PhpUnusedLocalVariableInspection */ + $discount = $disc['woofix_disc'] . "%"; + } + } + + $template = $this->woofix_locate_template( 'discount-info.php' ); + if ( $template !== false ) { + ob_start(); + /** @noinspection PhpIncludeInspection */ + include($template); + $price = ob_get_clean(); + } + } } return $price;