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/Integrations/Plugins/WCCS.php +32 -15 7.1.1 → 8.0.2 View file →
@@ -1,46 +1,63 @@
1 1 <?php namespace TierPricingTable\Integrations\Plugins;
2 2
3 3 use TierPricingTable\PriceManager;
4 +use TierPricingTable\PricingRule;
4 5
5 6 class WCCS extends PluginIntegrationAbstract {
6 -
7 +
7 8 public function run() {
8 -
9 +
9 10 add_filter( 'tiered_pricing_table/price/price_by_rules',
10 - function ( $product_price, $quantity, $product_id, $context ) {
11 -
11 + function ( $product_price, $quantity, $product_id, $context, $place, PricingRule $pricingRule ) {
12 +
12 13 global $WCCS;
13 -
14 - if ( $WCCS ) {
15 -
14 +
15 + // Percentage tiers are derived from the product's 'view' price, which WCCS has already converted.
16 + // Converting again here would double-convert the price.
17 + if ( $pricingRule->isPercentage() ) {
18 + return $product_price;
19 + }
20 +
21 + if ( $WCCS && $product_price ) {
22 +
16 23 $product = wc_get_product( $product_id );
17 -
24 +
18 25 if ( 'view' === $context && $product ) {
19 26 return $WCCS->wccs_custom_price( $product_price, $product );
20 27 }
21 28 }
22 -
29 +
23 30 return $product_price;
24 -
31 +
25 32 }, 10, 10 );
26 -
33 +
27 34 add_filter( 'tiered_pricing_table/cart/product_cart_price',
28 35 function ( $price, $cartItem, $cartItemKey, $totalQuantity ) {
29 -
36 +
30 37 global $WCCS;
31 -
38 +
32 39 if ( ! $WCCS ) {
33 40 return $price;
34 41 }
35 -
42 +
36 43 if ( $price ) {
37 44 return PriceManager::getPriceByRules( $totalQuantity, $cartItem['data']->get_id(), 'edit', 'cart',
38 45 false );
39 46 }
40 -
47 +
41 48 return $price;
42 49 }, 10, 4 );
50 +
51 + add_filter( 'tiered_pricing_table/cart/recalculate_cart_item_subtotal', function ( $state ) {
52 + global $WCCS;
53 +
54 + if ( $WCCS ) {
55 + return false;
56 + }
57 +
58 + return $state;
59 + } );
43 60 }
44 61
45 62 public function getTitle(): string {
46 63 return 'WooCommerce Currency Switcher by WP Experts (WCCS)';