PluginProbe
Tiered Pricing Table for WooCommerce / 7.1.1
Tiered Pricing Table for WooCommerce v7.1.1
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 / Addons / CatalogPrices / CatalogPricesSubsection.php

CatalogPricesSubsection.php in Tiered Pricing Table for WooCommerce 7.1.1, at src/Addons/CatalogPrices/CatalogPricesSubsection.php

102 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Addons\CatalogPrices;
2
3 use TierPricingTable\Settings\CustomOptions\TPTDisplayType;
4 use TierPricingTable\Settings\CustomOptions\TPTSwitchOption;
5 use TierPricingTable\Settings\Sections\SubsectionAbstract;
6 use TierPricingTable\Settings\Settings;
7
8 class CatalogPricesSubsection extends SubsectionAbstract {
9
10 public function getTitle(): string {
11 add_filter( 'tiered_pricing_table/text_template_variables', array( $this, 'registerTemplateVariables' ) );
12
13 return __( 'Shop & Categories Price Format',
14 'tier-pricing-table' );
15 }
16
17 public function getDescription(): string {
18 return __( 'Manage how the main product price string is formatted in shop pages, categories, and widgets.',
19 'tier-pricing-table' );
20 }
21
22 public function getSlug(): string {
23 return 'catalog_prices';
24 }
25
26 public function getSettings(): array {
27 return array(
28 array(
29 'title' => __( 'Override default price display', 'tier-pricing-table' ),
30 'id' => Settings::SETTINGS_PREFIX . 'tiered_price_at_catalog',
31 'type' => TPTSwitchOption::FIELD_TYPE,
32 'default' => 'yes',
33 'desc' => __( 'Replace the standard WooCommerce price with a custom lowest price or price range.',
34 'tier-pricing-table' ),
35 'desc_tip' => true,
36 ),
37 array(
38 'title' => __( 'Apply to variable products', 'tier-pricing-table' ),
39 'id' => Settings::SETTINGS_PREFIX . 'tiered_price_at_catalog_for_variable',
40 'type' => TPTSwitchOption::FIELD_TYPE,
41 'default' => 'no',
42 'desc' => __( 'Calculate the lowest and highest prices across all variations and display them using your chosen format.',
43 'tier-pricing-table' ),
44 'desc_tip' => true,
45 ),
46 array(
47 'title' => __( 'Format style', 'tier-pricing-table' ),
48 'id' => Settings::SETTINGS_PREFIX . 'tiered_price_at_catalog_type',
49 'type' => TPTDisplayType::FIELD_TYPE,
50 'options' => [
51 'lowest' => __( 'Show lowest price', 'tier-pricing-table' ),
52 'range' => __( 'Show range (lowest to highest)', 'tier-pricing-table' ),
53 'custom' => __( 'Custom template', 'tier-pricing-table' ),
54 ],
55 'default' => 'lowest',
56 'desc' => __( 'Choose whether to show only the lowest available price, the full price range, or a custom template.', 'tier-pricing-table' ),
57 'desc_tip' => true,
58 ),
59 array(
60 'title' => __( 'Custom template', 'tier-pricing-table' ),
61 'id' => Settings::SETTINGS_PREFIX . 'tiered_price_at_catalog_custom_template',
62 'type' => \TierPricingTable\Settings\CustomOptions\TPTTextTemplate::FIELD_TYPE,
63 'default' => __( 'From {tp_lowest_price} instead of {tp_original_price}', 'tier-pricing-table' ),
64 'desc' => __( 'Create a custom template for catalog prices. Use the available variables below to dynamically insert the lowest price, price range, or original product price.', 'tier-pricing-table' ),
65 'placeholders' => array(
66 'tp_lowest_price',
67 'tp_prices_range',
68 'tp_original_price',
69 ),
70 ),
71 array(
72 'title' => __( 'Prefix for lowest price', 'tier-pricing-table' ),
73 'id' => Settings::SETTINGS_PREFIX . 'lowest_prefix',
74 'type' => 'text',
75 'default' => __( 'From', 'tier-pricing-table' ),
76 'desc' => __( 'Text displayed before the lowest price (e.g., <b>From $10.00</b>).',
77 'tier-pricing-table' ),
78 ),
79 );
80 }
81
82 public function registerTemplateVariables( $variables ) {
83 $variables['tp_lowest_price'] = array(
84 'name' => __( 'Lowest price', 'tier-pricing-table' ),
85 'description' => __( '{tp_lowest_price} - lowest available tier price.', 'tier-pricing-table' ),
86 'variableKey' => '{tp_lowest_price}',
87 );
88 $variables['tp_prices_range'] = array(
89 'name' => __( 'Prices range', 'tier-pricing-table' ),
90 'description' => __( '{tp_prices_range} - price range from lowest tier to original price.', 'tier-pricing-table' ),
91 'variableKey' => '{tp_prices_range}',
92 );
93 $variables['tp_original_price'] = array(
94 'name' => __( 'Original price', 'tier-pricing-table' ),
95 'description' => __( '{tp_original_price} - product\'s original price without discounts.', 'tier-pricing-table' ),
96 'variableKey' => '{tp_original_price}',
97 );
98
99 return $variables;
100 }
101 }
102