null, 'color' => $this->getTextColor(), 'template' => $this->getTemplate(), 'consider_sale_price' => $this->considerSalePrice(), ) ); $product = wc_get_product( $args['product_id'] ); if ( ! $product ) { return ''; } $hasRules = \TierPricingTable\PricingTable::getInstance()->productHasPricingRules( $product ); $isEnabled = $hasRules ? 'yes' === $this->getContainer()->getSettings()->get( 'you_save_enabled', 'yes' ) : 'yes' === $this->getContainer()->getSettings()->get( 'you_save_non_tiered', 'no' ) && 'yes' === $this->getContainer()->getSettings()->get( 'you_save_consider_sale_price', 'yes' ); if ( ! $isEnabled ) { return ''; } return $this->getYouSaveHTML( $args['color'], $args['template'], $args['consider_sale_price'], $product ); } ); } public function addYouSave( $priceHTML, WC_Product $product ) { if ( false === strpos( $priceHTML, 'tiered-pricing-dynamic-price-wrapper' ) ) { return $priceHTML; } $hasRules = \TierPricingTable\PricingTable::getInstance()->productHasPricingRules( $product ); $isEnabled = $hasRules ? 'yes' === $this->getContainer()->getSettings()->get( 'you_save_enabled', 'yes' ) : 'yes' === $this->getContainer()->getSettings()->get( 'you_save_non_tiered', 'no' ) && 'yes' === $this->getContainer()->getSettings()->get( 'you_save_consider_sale_price', 'yes' ); if ( ! $isEnabled ) { return $priceHTML; } $priceHTML .= '
' . $this->getYouSaveHTML( $this->getTextColor(), $this->getTemplate(), $this->considerSalePrice(), $product ); return $priceHTML; } public function getYouSaveHTML( $color, $template, $considerSalePrice, $product = null ): string { $template = $this->parseTemplate( $template ); ob_start(); ?> '', '{tp_ys_total_price}' => '', '{tp_ys_percentage_discount}' => '', ) ); } }