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/Managers/FormatPriceManager.php +22 -0 6.5.0 → 8.0.2 View file →
@@ -12,8 +12,30 @@
12 12 *
13 13 * @package TierPricingTable\Managers
14 14 */
15 15 class FormatPriceManager {
16 + /**
17 + * Cache key for a formatted price.
18 + *
19 + * The formatted output depends on the display type and formatting flags, and several callers (for example, SEO
20 + * integrations building schema or title variables) request a plain, prefix-less version early in the request.
21 + * Keying by these arguments keeps each variant cached separately instead of letting the first caller win.
22 + *
23 + * @param string $displayType
24 + * @param array $args
25 + *
26 + * @return string
27 + */
28 + protected static function getPriceCacheKey( string $displayType, array $args ) : string {
29 + return 'price_html_' . md5( wp_json_encode( array(
30 + $displayType,
31 + (bool) $args['html'],
32 + (bool) $args['for_display'],
33 + (bool) $args['with_suffix'],
34 + (bool) $args['with_lowest_prefix']
35 + ) ) );
36 + }
37 +
16 38 public static function getFormattedPrice( WC_Product $product, array $args = array() ) : ?string {
17 39 $args = wp_parse_args( $args, array(
18 40 'html' => true,
19 41 'display_type' => null,