PluginProbe
Tiered Pricing Table for WooCommerce / 6.5.0
Tiered Pricing Table for WooCommerce v6.5.0
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 / Curcy.php

Curcy.php in Tiered Pricing Table for WooCommerce 6.5.0, at src/Integrations/Plugins/Curcy.php

94 lines 2.3 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 Curcy extends PluginIntegrationAbstract {
7
8 public function run() {
9 add_filter( 'tiered_pricing_table/price/price_by_rules',
10 function ( $productPrice, $quantity, $productId, $context, $place, PricingRule $pricingRule ) {
11
12 if ( ! function_exists( 'wmc_get_price' ) ) {
13 return $productPrice;
14 }
15
16 if ( $pricingRule->isPercentage() ) {
17 return $productPrice;
18 }
19
20 if ( $productPrice && 'view' === $context ) {
21 return wmc_get_price( $productPrice );
22 }
23
24 return $productPrice;
25
26 }, 10, 10 );
27
28 add_filter( 'tiered_pricing_table/cart/product_cart_price',
29 function ( $price, $cartItem, $cartItemKey, $totalQuantity ) {
30
31 if ( ! function_exists( 'wmc_get_price' ) ) {
32 return $price;
33 }
34
35 if ( $price ) {
36 return PriceManager::getPriceByRules( $totalQuantity, $cartItem['data']->get_id(), 'edit', 'cart',
37 false );
38 }
39
40 return $price;
41 }, 10, 4 );
42
43 add_filter( 'tiered_pricing_table/cart/recalculate_cart_item_subtotal', function ( $state ) {
44 if ( function_exists( 'wmc_get_price' ) ) {
45 return false;
46 }
47
48 return $state;
49 } );
50
51 // Add currency dependency to variable product price
52 add_filter( 'woocommerce_get_variation_prices_hash', function ( $hash ) {
53
54 if ( ! class_exists( 'WOOMULTI_CURRENCY_F_Data' ) ) {
55 return $hash;
56 }
57
58 $setting = \WOOMULTI_CURRENCY_F_Data::get_ins();
59
60 $hash[] = $setting->get_current_currency();
61
62 return $hash;
63 }, 10, 2 );
64 }
65
66 public function getTitle(): string {
67 return 'CURCY Multicurrency';
68 }
69
70 public function getIconURL(): string {
71 return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/curcy-icon.png' );
72 }
73
74 public function getAuthorURL(): string {
75 return 'https://ru.wordpress.org/plugins/woo-multi-currency/';
76 }
77
78 public function getDescription(): string {
79 return __( 'Convert and display tiered pricing correctly when using the CURCY multicurrency plugin.', 'tier-pricing-table' );
80 }
81
82 public function getSlug(): string {
83 return 'curcy';
84 }
85
86 public function getIntegrationCategory(): string {
87 return 'multicurrency';
88 }
89
90 protected function isActiveByDefault(): bool {
91 return true;
92 }
93 }
94