PluginProbe
Tiered Pricing Table for WooCommerce / 7.1.4
Tiered Pricing Table for WooCommerce v7.1.4
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
tier-pricing-table / src / Integrations / Plugins / WCCS.php

WCCS.php in Tiered Pricing Table for WooCommerce 7.1.4, at src/Integrations/Plugins/WCCS.php

86 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Integrations\Plugins;
2
3 use TierPricingTable\PriceManager;
4 use TierPricingTable\PricingRule;
5
6 class WCCS extends PluginIntegrationAbstract {
7
8 public function run() {
9
10 add_filter( 'tiered_pricing_table/price/price_by_rules',
11 function ( $product_price, $quantity, $product_id, $context, $place, PricingRule $pricingRule ) {
12
13 global $WCCS;
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
23 $product = wc_get_product( $product_id );
24
25 if ( 'view' === $context && $product ) {
26 return $WCCS->wccs_custom_price( $product_price, $product );
27 }
28 }
29
30 return $product_price;
31
32 }, 10, 10 );
33
34 add_filter( 'tiered_pricing_table/cart/product_cart_price',
35 function ( $price, $cartItem, $cartItemKey, $totalQuantity ) {
36
37 global $WCCS;
38
39 if ( ! $WCCS ) {
40 return $price;
41 }
42
43 if ( $price ) {
44 return PriceManager::getPriceByRules( $totalQuantity, $cartItem['data']->get_id(), 'edit', 'cart',
45 false );
46 }
47
48 return $price;
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 } );
60 }
61
62 public function getTitle(): string {
63 return 'WooCommerce Currency Switcher by WP Experts (WCCS)';
64 }
65
66 public function getDescription(): string {
67 return __( 'Convert and display tiered pricing correctly when using the WooCommerce Currency Switcher by WP Experts.', 'tier-pricing-table' );
68 }
69
70 public function getIconURL(): string {
71 return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/wccs-icon.png' );
72 }
73
74 public function getAuthorURL(): string {
75 return 'https://woocommerce.com/products/currency-switcher-for-woocommerce/';
76 }
77
78 public function getSlug(): string {
79 return 'wccs';
80 }
81
82 public function getIntegrationCategory(): string {
83 return 'multicurrency';
84 }
85 }
86