PluginProbe
Tiered Pricing Table for WooCommerce / 8.1.0
Tiered Pricing Table for WooCommerce v8.1.0
8.1.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 All 92 releases
← All changes | src/Addons/GlobalTieredPricing/GlobalTieredPricingAddon.php +25 -0 7.1.5 → 8.1.0 View file →
@@ -1,8 +1,9 @@
1 1 <?php namespace TierPricingTable\Addons\GlobalTieredPricing;
2 2
3 3 use TierPricingTable\Addons\AbstractAddon;
4 4 use TierPricingTable\Addons\GlobalTieredPricing\CPT\GlobalTieredPricingCPT;
5 +use TierPricingTable\Addons\GlobalTieredPricing\CPT\PricingTestLinks;
5 6
6 7 class GlobalTieredPricingAddon extends AbstractAddon {
7 8
8 9 public function getName(): string {
@@ -15,8 +16,9 @@
15 16 add_filter( 'tiered_pricing_table/services/pricing_service_enabled', '__return_true' );
16 17
17 18 new LookupService();
18 19 new GlobalTieredPricingCPT();
20 + new PricingTestLinks();
19 21 new GlobalTieredPricingCartManager();
20 22 new PricingService();
21 23
22 24 GlobalPricingRulesRepository::getInstance();
@@ -24,8 +26,31 @@
24 26 add_action( 'tiered_pricing_table/admin/pricing_tab_end', array(
25 27 $this,
26 28 'showMessageOnProductsTieredPricingTab',
27 29 ), 999 );
30 +
31 + // The set of rules in force changes with schedules and priorities, so cached prices must change with it:
32 + // WooCommerce's variable price ranges and the plugin's own product data are keyed by this fingerprint.
33 + add_filter( 'woocommerce_get_variation_prices_hash', function ( $hash ) {
34 + if ( is_array( $hash ) ) {
35 + $hash[] = 'tpt-rules:' . self::getActiveRulesFingerprint();
36 + }
37 +
38 + return $hash;
39 + } );
40 +
41 + add_filter( 'tiered_pricing_table/cache/product_cache_key_salt', function ( $salt ) {
42 + return $salt . '|rules:' . self::getActiveRulesFingerprint();
43 + } );
44 + }
45 +
46 + /**
47 + * The rules in force right now with their priorities, as one string.
48 + */
49 + public static function getActiveRulesFingerprint(): string {
50 + return implode( ',', array_map( function ( GlobalPricingRule $rule ) {
51 + return $rule->getId() . ':' . $rule->getPriority();
52 + }, GlobalTieredPricingCPT::getGlobalRules() ) );
28 53 }
29 54
30 55 public function showMessageOnProductsTieredPricingTab() {
31 56 $globalRules = GlobalTieredPricingCPT::getGlobalRules( false );