PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
← All changes | src/Addons/YouSave/YouSaveService.php +20 -4 6.4.0 → 8.0.2 View file →
@@ -19,11 +19,9 @@
19 19 * CatalogPriceManager constructor.
20 20 */
21 21 public function __construct() {
22 22
23 - if ( $this->isEnabled() ) {
24 - add_action( 'woocommerce_get_price_html', array( $this, 'addYouSave' ), 150, 2 );
25 - }
23 + add_action( 'woocommerce_get_price_html', array( $this, 'addYouSave' ), 150, 2 );
26 24
27 25 add_shortcode( 'tiered_price_you_save', function ( $tag, $args ) {
28 26
29 27 $args = wp_parse_args( $args, array(
@@ -38,8 +36,17 @@
38 36 if ( ! $product ) {
39 37 return '';
40 38 }
41 39
40 + $hasRules = \TierPricingTable\PricingTable::getInstance()->productHasPricingRules( $product );
41 + $isEnabled = $hasRules
42 + ? 'yes' === $this->getContainer()->getSettings()->get( 'you_save_enabled', 'yes' )
43 + : 'yes' === $this->getContainer()->getSettings()->get( 'you_save_non_tiered', 'no' ) && 'yes' === $this->getContainer()->getSettings()->get( 'you_save_consider_sale_price', 'yes' );
44 +
45 + if ( ! $isEnabled ) {
46 + return '';
47 + }
48 +
42 49 return $this->getYouSaveHTML( $args['color'], $args['template'], $args['consider_sale_price'], $product );
43 50 } );
44 51 }
45 52
@@ -48,8 +55,17 @@
48 55 if ( false === strpos( $priceHTML, 'tiered-pricing-dynamic-price-wrapper' ) ) {
49 56 return $priceHTML;
50 57 }
51 58
59 + $hasRules = \TierPricingTable\PricingTable::getInstance()->productHasPricingRules( $product );
60 + $isEnabled = $hasRules
61 + ? 'yes' === $this->getContainer()->getSettings()->get( 'you_save_enabled', 'yes' )
62 + : 'yes' === $this->getContainer()->getSettings()->get( 'you_save_non_tiered', 'no' ) && 'yes' === $this->getContainer()->getSettings()->get( 'you_save_consider_sale_price', 'yes' );
63 +
64 + if ( ! $isEnabled ) {
65 + return $priceHTML;
66 + }
67 +
52 68 $priceHTML .= '<br>' . $this->getYouSaveHTML( $this->getTextColor(), $this->getTemplate(),
53 69 $this->considerSalePrice(), $product );
54 70
55 71 return $priceHTML;
@@ -71,9 +87,9 @@
71 87 }
72 88
73 89 public function getTemplate() {
74 90 return get_option( Settings::SETTINGS_PREFIX . 'you_save_template',
75 - 'You save {tp_ys_total_price} ({tp_ys_percentage_discount}%)' );
91 + 'You save {tp_ys_total_price}' );
76 92 }
77 93
78 94 public function getTextColor() {
79 95 return get_option( Settings::SETTINGS_PREFIX . 'you_save_text_color', '#FF0000' );