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
tier-pricing-table / src / Settings / Sections / GeneralSection / Subsections / LayoutSubsection.php

LayoutSubsection.php in Tiered Pricing Table for WooCommerce 8.0.2, at src/Settings/Sections/GeneralSection/Subsections/LayoutSubsection.php

413 lines 18.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Settings\Sections\GeneralSection\Subsections;
2
3 use TierPricingTable\Addons\LayoutConfigurator\LayoutConfigurator;
4 use TierPricingTable\Addons\LayoutConfigurator\LayoutConfiguratorAddon;
5 use TierPricingTable\Settings\CustomOptions\TPTDisplayType;
6 use TierPricingTable\Settings\Sections\GeneralSection\GeneralSection;
7 use TierPricingTable\Settings\CustomOptions\TPTTableColumnsField;
8 use TierPricingTable\Settings\CustomOptions\TPTQuantityMeasurementField;
9 use TierPricingTable\Settings\CustomOptions\TPTSwitchOption;
10 use TierPricingTable\Settings\CustomOptions\TPTTextTemplate;
11 use TierPricingTable\Settings\Sections\SubsectionAbstract;
12 use TierPricingTable\Settings\Settings;
13 use TierPricingTable\TierPricingTablePlugin;
14
15 /**
16 * Product-page layout settings. With the layout configurator add-on on (the default) the whole
17 * subsection is one configurator field with a live preview; with it off the classic rows are shown.
18 */
19 class LayoutSubsection extends SubsectionAbstract {
20
21 public function getTitle(): string {
22 // the configurator prints its own heading, next to the page switch
23 return LayoutConfiguratorAddon::isActive() ? '' : __( 'Pricing Layout Settings', 'tier-pricing-table' );
24 }
25
26 public function getDescription(): string {
27 return LayoutConfiguratorAddon::isActive()
28 ? ''
29 : __( 'Customize the appearance and behavior of your tiered pricing tables.', 'tier-pricing-table' );
30 }
31
32 public function getSlug(): string {
33 return 'layout';
34 }
35
36 public function getSettings(): array {
37 return LayoutConfiguratorAddon::isActive() ? $this->getConfiguratorSettings() : $this->getClassicSettings();
38 }
39
40 protected function getConfiguratorSettings(): array {
41 return array(
42 array(
43 'title' => __( 'Pricing Display', 'tier-pricing-table' ),
44 'id' => Settings::SETTINGS_PREFIX . 'display_type',
45 'type' => LayoutConfigurator::FIELD_TYPE,
46 'desc' => '',
47 ),
48 // Options saved from the configurator's hidden inputs; rendered by nothing.
49 ...LayoutConfigurator::getSavedOnlyFields(),
50 );
51 }
52
53 /**
54 * The classic rows, one option each, shown while the layout configurator add-on is off.
55 */
56 protected function getClassicSettings(): array {
57 return array(
58 array(
59 'title' => __( 'Show tiered pricing automatically', 'tier-pricing-table' ),
60 'id' => Settings::SETTINGS_PREFIX . 'display',
61 'type' => TPTSwitchOption::FIELD_TYPE,
62 'default' => 'yes',
63 'desc' => __( 'Automatically insert the pricing layout on the product page. If disabled, pricing remains dynamic but you must insert the layout manually via shortcode, block, or widget.',
64 'tier-pricing-table' ),
65 'desc_tip' => true,
66 ),
67 array(
68 'title' => __( 'Default visual layout', 'tier-pricing-table' ),
69 'id' => Settings::SETTINGS_PREFIX . 'display_type',
70 'type' => TPTDisplayType::FIELD_TYPE,
71 'options' => TierPricingTablePlugin::getAvailablePricingLayouts(),
72 'desc' => __( 'Choose the default visual layout. You can also customize this individually per product.',
73 'tier-pricing-table' ),
74 'desc_tip' => true,
75 'default' => 'table',
76 ),
77 array(
78 'title' => __( 'Options design style', 'tier-pricing-table' ),
79 'id' => Settings::SETTINGS_PREFIX . 'pricing_options_style',
80 'type' => TPTDisplayType::FIELD_TYPE,
81 'options' => GeneralSection::getStyleOptions()['options'],
82 'desc_tip' => true,
83 'default' => 'default',
84 ),
85 array(
86 'title' => __( 'Table design style', 'tier-pricing-table' ),
87 'id' => Settings::SETTINGS_PREFIX . 'pricing_table_style',
88 'type' => TPTDisplayType::FIELD_TYPE,
89 'options' => GeneralSection::getStyleOptions()['table'],
90 'desc_tip' => true,
91 'default' => 'default',
92 ),
93 array(
94 'title' => __( 'Blocks design style', 'tier-pricing-table' ),
95 'id' => Settings::SETTINGS_PREFIX . 'pricing_blocks_style',
96 'type' => TPTDisplayType::FIELD_TYPE,
97 'options' => GeneralSection::getStyleOptions()['blocks'],
98 'desc_tip' => true,
99 'default' => 'default',
100 ),
101 array(
102 'title' => __( 'Dropdown design style', 'tier-pricing-table' ),
103 'id' => Settings::SETTINGS_PREFIX . 'pricing_dropdown_style',
104 'type' => TPTDisplayType::FIELD_TYPE,
105 'options' => GeneralSection::getStyleOptions()['dropdown'],
106 'default' => 'default',
107 ),
108 array(
109 'title' => __( 'Plain text design style', 'tier-pricing-table' ),
110 'id' => Settings::SETTINGS_PREFIX . 'pricing_plain_text_style',
111 'type' => TPTDisplayType::FIELD_TYPE,
112 'options' => GeneralSection::getStyleOptions()['plain-text'],
113 'default' => 'default',
114 ),
115 array(
116 'title' => __( 'Enable compact layout', 'tier-pricing-table' ),
117 'id' => Settings::SETTINGS_PREFIX . 'compact_layout',
118 'type' => TPTSwitchOption::FIELD_TYPE,
119 'default' => 'no',
120 'desc' => __( 'Apply a space-saving compact design for the selected layout.', 'tier-pricing-table' ),
121 ),
122 array(
123 'title' => __( 'Layout title', 'tier-pricing-table' ),
124 'id' => Settings::SETTINGS_PREFIX . 'table_title',
125 'type' => 'text',
126 'default' => '',
127 'desc_tip' => true,
128 ),
129 array(
130 'title' => __( 'Layout position', 'tier-pricing-table' ),
131 'id' => Settings::SETTINGS_PREFIX . 'position_hook',
132 'type' => 'select',
133 'options' => array(
134 'woocommerce_before_add_to_cart_button' => __( 'Above add to cart button', 'tier-pricing-table' ),
135 'woocommerce_after_add_to_cart_button' => __( 'Below add to cart button', 'tier-pricing-table' ),
136 'woocommerce_before_add_to_cart_form' => __( 'Above add to cart form', 'tier-pricing-table' ),
137 'woocommerce_after_add_to_cart_form' => __( 'Below add to cart form', 'tier-pricing-table' ),
138 'woocommerce_single_product_summary' => __( 'Above product title', 'tier-pricing-table' ),
139 'woocommerce_before_single_product_summary' => __( 'Before product summary', 'tier-pricing-table' ),
140 'woocommerce_after_single_product_summary' => __( 'After product summary', 'tier-pricing-table' ),
141 '____none____' => __( 'I display tiered pricing via shortcode/gutenberg/elementor',
142 'tier-pricing-table' ),
143 ),
144 'desc' => __( 'Choose where you what tiered pricing be displayed on the product page.',
145 'tier-pricing-table' ),
146 'desc_tip' => true,
147 ),
148 array(
149 'title' => __( 'Quantity format', 'tier-pricing-table' ),
150 'id' => Settings::SETTINGS_PREFIX . 'quantity_type',
151 'type' => TPTDisplayType::FIELD_TYPE,
152 'options' => array(
153 'range' => __( 'Range', 'tier-pricing-table' ),
154 'static' => __( 'Static values', 'tier-pricing-table' ),
155 ),
156 'desc' => __( '"Range" displays the quantity range a tier applies to. "Static" displays only the minimum quantity required.',
157 'tier-pricing-table' ),
158 'desc_tip' => false,
159 'default' => 'range',
160 ),
161 array(
162 'title' => __( 'Spacing', 'tier-pricing-table' ),
163 'id' => Settings::SETTINGS_PREFIX . 'layout_spacing',
164 'type' => 'number',
165 'default' => '',
166 'css' => 'width: 6em;',
167 'custom_attributes' => array( 'min' => 0, 'max' => 40, 'step' => 1, 'placeholder' => __( 'Auto', 'tier-pricing-table' ) ),
168 'desc' => __( 'Gap between the pricing blocks, options or card rows, in pixels. Leave empty to keep each design style\'s own spacing.', 'tier-pricing-table' ),
169 ),
170 array(
171 'title' => __( 'Cell padding', 'tier-pricing-table' ),
172 'id' => Settings::SETTINGS_PREFIX . 'cell_padding',
173 'type' => 'number',
174 'default' => '',
175 'css' => 'width: 6em;',
176 'custom_attributes' => array( 'min' => 0, 'max' => 30, 'step' => 1, 'placeholder' => __( 'Auto', 'tier-pricing-table' ) ),
177 'desc' => __( 'Padding inside the cells of the table and horizontal table layouts, in pixels. Leave empty to keep each design style\'s own padding; a value also overrides the theme\'s cell padding.', 'tier-pricing-table' ),
178 ),
179 array(
180 'title' => __( 'Tier order', 'tier-pricing-table' ),
181 'id' => Settings::SETTINGS_PREFIX . 'tiers_order',
182 'type' => TPTDisplayType::FIELD_TYPE,
183 'options' => array(
184 'asc' => __( 'Ascending', 'tier-pricing-table' ),
185 'desc' => __( 'Descending', 'tier-pricing-table' ),
186 ),
187 'descriptions' => array(
188 'asc' => __( 'Smallest quantity first', 'tier-pricing-table' ),
189 'desc' => __( 'Biggest discount first', 'tier-pricing-table' ),
190 ),
191 'default' => 'asc',
192 ),
193 array(
194 'title' => __( 'Active pricing tier color', 'tier-pricing-table' ),
195 'id' => Settings::SETTINGS_PREFIX . 'selected_quantity_color',
196 'type' => 'color',
197 'css' => 'width:6em;',
198 'default' => '#3858e9',
199 ),
200 array(
201 'title' => __( 'Discount badge color', 'tier-pricing-table' ),
202 'id' => Settings::SETTINGS_PREFIX . 'discount_badge_color',
203 'type' => 'color',
204 'css' => 'width:6em;',
205 'default' => '',
206 'desc' => __( 'The discount badge of table styles #2 to #6. Styles #2 and #6 show a light tint of this color behind text in this color, styles #3 and #4 a solid badge with white text, style #5 colors its savings bar and percentage. Leave empty to keep the style\'s own colors (the active tier color on styles #3 to #5).', 'tier-pricing-table' ),
207 ),
208 array(
209 'title' => __( 'Active tier left border', 'tier-pricing-table' ),
210 'id' => Settings::SETTINGS_PREFIX . 'table_active_border',
211 'type' => TPTSwitchOption::FIELD_TYPE,
212 'default' => 'yes',
213 'desc' => __( 'Table styles #1, #5 and #6 mark the active tier with a left border in the active tier color. Switch it off to keep the row highlight only.', 'tier-pricing-table' ),
214 ),
215 array(
216 'title' => __( 'Tooltip icon color', 'tier-pricing-table' ),
217 'id' => Settings::SETTINGS_PREFIX . 'tooltip_color',
218 'type' => 'color',
219 'default' => '#3858e9',
220 'css' => 'width:6em;',
221 'desc' => __( 'Color of the icon.', 'tier-pricing-table' ),
222 'desc_tip' => true,
223 ),
224 array(
225 'title' => __( 'Tooltip icon size (px)', 'tier-pricing-table' ),
226 'id' => Settings::SETTINGS_PREFIX . 'tooltip_size',
227 'type' => 'number',
228 'default' => '15',
229 'css' => 'width:120px;',
230 'desc' => __( 'Size of the icon.', 'tier-pricing-table' ),
231 'desc_tip' => true,
232 ),
233 array(
234 'title' => __( 'Tooltip border', 'tier-pricing-table' ),
235 'id' => Settings::SETTINGS_PREFIX . 'tooltip_border',
236 'type' => TPTSwitchOption::FIELD_TYPE,
237 'default' => 'yes',
238 ),
239 array(
240 'title' => __( 'Quantity unit label', 'tier-pricing-table' ),
241 'id' => Settings::SETTINGS_PREFIX . 'table_quantity_measurement',
242 'type' => TPTQuantityMeasurementField::FIELD_TYPE,
243 'default' => array(
244 'singular' => '',
245 'plural' => '',
246 ),
247 'desc' => __( 'For example: pieces, boxes, bottles, packs, etc. This will be shown next to quantity values. Leave blank to skip adding a unit label.',
248 'tier-pricing-table' ),
249 ),
250 array(
251 'title' => __( 'Quantity unit label', 'tier-pricing-table' ),
252 'id' => Settings::SETTINGS_PREFIX . 'blocks_quantity_measurement',
253 'type' => TPTQuantityMeasurementField::FIELD_TYPE,
254 'default' => array(
255 'singular' => _n( 'piece', 'pieces', 1, 'tier-pricing-table' ),
256 'plural' => _n( 'piece', 'pieces', 2, 'tier-pricing-table' ),
257 ),
258 'desc' => __( 'For example: pieces, boxes, bottles, packs, etc. This will be shown next to quantity values. Leave blank to skip adding a unit label.',
259 'tier-pricing-table' ),
260 ),
261 array(
262 'title' => __( 'Table column headers', 'tier-pricing-table' ),
263 'id' => Settings::SETTINGS_PREFIX . 'table_columns_titles',
264 'options' => array(
265 array(
266 'label' => __( 'Quantity', 'tier-pricing-table' ),
267 'id' => Settings::SETTINGS_PREFIX . 'head_quantity_text',
268 'default' => __( 'Quantity', 'tier-pricing-table' ),
269 ),
270 array(
271 'label' => __( 'Discount', 'tier-pricing-table' ),
272 'id' => Settings::SETTINGS_PREFIX . 'head_discount_text',
273 'default' => __( 'Discount (%)', 'tier-pricing-table' ),
274 ),
275 array(
276 'label' => __( 'Price', 'tier-pricing-table' ),
277 'id' => Settings::SETTINGS_PREFIX . 'head_price_text',
278 'default' => __( 'Price', 'tier-pricing-table' ),
279 ),
280 ),
281 'desc' => __( 'Leave a column title empty to hide that column entirely.', 'tier-pricing-table' ),
282 'type' => TPTTableColumnsField::FIELD_TYPE,
283 ),
284 array(
285 'title' => __( 'Show discount', 'tier-pricing-table' ),
286 'id' => Settings::SETTINGS_PREFIX . 'show_discount_column',
287 'type' => TPTSwitchOption::FIELD_TYPE,
288 'default' => 'yes',
289 'desc' => __( 'Show the discount in pricing blocks that offer a discount.',
290 'tier-pricing-table' ),
291 ),
292 array(
293 'title' => __( 'Discount format', 'tier-pricing-table' ),
294 'id' => Settings::SETTINGS_PREFIX . 'discount_format',
295 'type' => TPTDisplayType::FIELD_TYPE,
296 'options' => array(
297 'percentage' => __( 'Percentage', 'tier-pricing-table' ),
298 'amount' => __( 'Amount saved', 'tier-pricing-table' ),
299 'both' => __( 'Both', 'tier-pricing-table' ),
300 ),
301 'descriptions' => array(
302 'percentage' => __( 'e.g. 10%', 'tier-pricing-table' ),
303 'amount' => __( 'e.g. $4.50', 'tier-pricing-table' ),
304 'both' => __( 'e.g. 10% ($4.50)', 'tier-pricing-table' ),
305 ),
306 'desc' => __( 'How the discount column and discount badges show a tier\'s discount.', 'tier-pricing-table' ),
307 'desc_tip' => false,
308 'default' => 'percentage',
309 ),
310 array(
311 'title' => __( 'Show original price crossed out', 'tier-pricing-table' ),
312 'id' => Settings::SETTINGS_PREFIX . 'options_show_original_product_price',
313 'type' => TPTSwitchOption::FIELD_TYPE,
314 'default' => 'yes',
315 'desc' => __( 'Pricing options will show a crossed-out regular price next to the discounted tier price.',
316 'tier-pricing-table' ),
317 ),
318
319 array(
320 'title' => __( 'Show total calculated price for selected option', 'tier-pricing-table' ),
321 'id' => Settings::SETTINGS_PREFIX . 'options_show_total',
322 'type' => TPTSwitchOption::FIELD_TYPE,
323 'default' => 'yes',
324 'desc' => __( 'The selected pricing option will dynamically display the total calculated cost.', 'tier-pricing-table' ),
325 'custom_attributes' => [ 'data-tiered-pricing-premium-option' => true ],
326 ),
327 array(
328 'title' => __( 'Pricing option text template', 'tier-pricing-table' ),
329 'id' => Settings::SETTINGS_PREFIX . 'options_option_text',
330 'default' => __( '<strong>Buy {tp_quantity} pieces and save {tp_rounded_discount}%</strong>',
331 'tier-pricing-table' ),
332 'placeholders' => array(
333 'tp_quantity',
334 'tp_discount',
335 'tp_rounded_discount',
336 'tp_base_unit_name',
337 ),
338 'type' => TPTTextTemplate::FIELD_TYPE,
339 'desc' => __( 'Use the variables above to build the template for the pricing option.',
340 'tier-pricing-table' ),
341 ),
342 array(
343 'title' => __( 'Show base price (no discount) option', 'tier-pricing-table' ),
344 'id' => Settings::SETTINGS_PREFIX . 'options_show_default_option',
345 'type' => TPTSwitchOption::FIELD_TYPE,
346 'default' => 'yes',
347 'desc' => __( 'Display an option for the regular product price (e.g. 1 item) where no tier discount is applied.',
348 'tier-pricing-table' ),
349 ),
350 array(
351 'title' => __( 'Base price option template', 'tier-pricing-table' ),
352 'id' => Settings::SETTINGS_PREFIX . 'options_default_option_text',
353 'default' => __( '<strong>Buy {tp_quantity} pieces</strong>', 'tier-pricing-table' ),
354 'placeholders' => array(
355 'tp_quantity',
356 'tp_base_unit_name',
357 ),
358 'type' => TPTTextTemplate::FIELD_TYPE,
359 'desc' => __( 'Customize the template for the base price option.',
360 'tier-pricing-table' ),
361 ),
362 array(
363 'title' => __( 'Pricing string template', 'tier-pricing-table' ),
364 'id' => Settings::SETTINGS_PREFIX . 'plain_text_template',
365 'default' => __( '<strong>Buy {tp_quantity} pieces for {tp_price} each and save {tp_rounded_discount}%</strong>',
366 'tier-pricing-table' ),
367 'placeholders' => array(
368 'tp_quantity',
369 'tp_discount',
370 'tp_price',
371 'tp_rounded_discount',
372 'tp_base_unit_name',
373 ),
374 'type' => TPTTextTemplate::FIELD_TYPE,
375 'desc' => __( 'Use the variables above to build the template for the pricing string.',
376 'tier-pricing-table' ),
377 ),
378 array(
379 'title' => __( 'Show first tier pricing string', 'tier-pricing-table' ),
380 'id' => Settings::SETTINGS_PREFIX . 'plain_text_show_first_tier',
381 'type' => TPTSwitchOption::FIELD_TYPE,
382 'default' => 'yes',
383 'desc' => __( 'Show the tier with a regular product price. This is the first pricing tier where no discount is offered.',
384 'tier-pricing-table' ),
385 ),
386
387 array(
388 'title' => __( 'First tier pricing string template', 'tier-pricing-table' ),
389 'id' => Settings::SETTINGS_PREFIX . 'plain_text_first_tier_template',
390 'default' => __( '<strong>Buy {tp_quantity} pieces for {tp_price} each</strong>',
391 'tier-pricing-table' ),
392 'placeholders' => array(
393 'tp_quantity',
394 'tp_price',
395 'tp_base_unit_name',
396 ),
397 'type' => TPTTextTemplate::FIELD_TYPE,
398 'desc' => __( 'Set up the first pricing tier template where a discount is not offered.',
399 'tier-pricing-table' ),
400 ),
401 array(
402 'title' => __( 'Make pricing tiers clickable', 'tier-pricing-table' ),
403 'id' => Settings::SETTINGS_PREFIX . 'clickable_table_rows',
404 'type' => TPTSwitchOption::FIELD_TYPE,
405 'default' => 'yes',
406 'desc' => __( 'Allow customers to click on a pricing tier (table row, block, or option) to automatically select that quantity.',
407 'tier-pricing-table' ),
408 'custom_attributes' => [ 'data-tiered-pricing-premium-option' => true ],
409 ),
410 );
411 }
412 }
413