← All changes
|
src/Settings/Sections/GeneralSection/Subsections/LayoutSubsection.php
+116
-27
7.1.4
→
8.0.2
View file →
| @@ -1,7 +1,10 @@ | ||
| 1 | 1 | <?php namespace TierPricingTable\Settings\Sections\GeneralSection\Subsections; |
| 2 | 2 | |
| 3 | +use TierPricingTable\Addons\LayoutConfigurator\LayoutConfigurator; | |
| 4 | +use TierPricingTable\Addons\LayoutConfigurator\LayoutConfiguratorAddon; | |
| 3 | 5 | use TierPricingTable\Settings\CustomOptions\TPTDisplayType; |
| 6 | +use TierPricingTable\Settings\Sections\GeneralSection\GeneralSection; | |
| 4 | 7 | use TierPricingTable\Settings\CustomOptions\TPTTableColumnsField; |
| 5 | 8 | use TierPricingTable\Settings\CustomOptions\TPTQuantityMeasurementField; |
| 6 | 9 | use TierPricingTable\Settings\CustomOptions\TPTSwitchOption; |
| 7 | 10 | use TierPricingTable\Settings\CustomOptions\TPTTextTemplate; |
| @@ -8,16 +11,23 @@ | ||
| 8 | 11 | use TierPricingTable\Settings\Sections\SubsectionAbstract; |
| 9 | 12 | use TierPricingTable\Settings\Settings; |
| 10 | 13 | use TierPricingTable\TierPricingTablePlugin; |
| 11 | 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 | + */ | |
| 12 | 19 | class LayoutSubsection extends SubsectionAbstract { |
| 13 | 20 | |
| 14 | 21 | public function getTitle(): string { |
| 15 | - return __( 'Pricing Layout Settings', 'tier-pricing-table' ); | |
| 22 | + // the configurator prints its own heading, next to the page switch | |
| 23 | + return LayoutConfiguratorAddon::isActive() ? '' : __( 'Pricing Layout Settings', 'tier-pricing-table' ); | |
| 16 | 24 | } |
| 17 | 25 | |
| 18 | 26 | public function getDescription(): string { |
| 19 | - return __( 'Customize the appearance and behavior of your tiered pricing tables.', 'tier-pricing-table' ); | |
| 27 | + return LayoutConfiguratorAddon::isActive() | |
| 28 | + ? '' | |
| 29 | + : __( 'Customize the appearance and behavior of your tiered pricing tables.', 'tier-pricing-table' ); | |
| 20 | 30 | } |
| 21 | 31 | |
| 22 | 32 | public function getSlug(): string { |
| 23 | 33 | return 'layout'; |
| @@ -23,10 +33,30 @@ | ||
| 23 | 33 | return 'layout'; |
| 24 | 34 | } |
| 25 | 35 | |
| 26 | 36 | public function getSettings(): array { |
| 37 | + return LayoutConfiguratorAddon::isActive() ? $this->getConfiguratorSettings() : $this->getClassicSettings(); | |
| 38 | + } | |
| 39 | + | |
| 40 | + protected function getConfiguratorSettings(): array { | |
| 27 | 41 | return array( |
| 28 | 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( | |
| 29 | 59 | 'title' => __( 'Show tiered pricing automatically', 'tier-pricing-table' ), |
| 30 | 60 | 'id' => Settings::SETTINGS_PREFIX . 'display', |
| 31 | 61 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 32 | 62 | 'default' => 'yes', |
| @@ -47,15 +77,9 @@ | ||
| 47 | 77 | array( |
| 48 | 78 | 'title' => __( 'Options design style', 'tier-pricing-table' ), |
| 49 | 79 | 'id' => Settings::SETTINGS_PREFIX . 'pricing_options_style', |
| 50 | 80 | 'type' => TPTDisplayType::FIELD_TYPE, |
| 51 | - 'options' => array( | |
| 52 | - 'default' => __( 'Default', 'tier-pricing-table' ), | |
| 53 | - 'style-1' => __( 'Style #1', 'tier-pricing-table' ), | |
| 54 | - 'style-2' => __( 'Style #2', 'tier-pricing-table' ), | |
| 55 | - 'style-3' => __( 'Style #3', 'tier-pricing-table' ), | |
| 56 | - 'style-4' => __( 'Style #4', 'tier-pricing-table' ), | |
| 57 | - ), | |
| 81 | + 'options' => GeneralSection::getStyleOptions()['options'], | |
| 58 | 82 | 'desc_tip' => true, |
| 59 | 83 | 'default' => 'default', |
| 60 | 84 | ), |
| 61 | 85 | array( |
| @@ -61,15 +85,9 @@ | ||
| 61 | 85 | array( |
| 62 | 86 | 'title' => __( 'Table design style', 'tier-pricing-table' ), |
| 63 | 87 | 'id' => Settings::SETTINGS_PREFIX . 'pricing_table_style', |
| 64 | 88 | 'type' => TPTDisplayType::FIELD_TYPE, |
| 65 | - 'options' => array( | |
| 66 | - 'default' => __( 'Default', 'tier-pricing-table' ), | |
| 67 | - 'style-1' => __( 'Style #1', 'tier-pricing-table' ), | |
| 68 | - 'style-2' => __( 'Style #2', 'tier-pricing-table' ), | |
| 69 | - 'style-3' => __( 'Style #3', 'tier-pricing-table' ), | |
| 70 | - 'style-4' => __( 'Style #4', 'tier-pricing-table' ), | |
| 71 | - ), | |
| 89 | + 'options' => GeneralSection::getStyleOptions()['table'], | |
| 72 | 90 | 'desc_tip' => true, |
| 73 | 91 | 'default' => 'default', |
| 74 | 92 | ), |
| 75 | 93 | array( |
| @@ -75,21 +93,27 @@ | ||
| 75 | 93 | array( |
| 76 | 94 | 'title' => __( 'Blocks design style', 'tier-pricing-table' ), |
| 77 | 95 | 'id' => Settings::SETTINGS_PREFIX . 'pricing_blocks_style', |
| 78 | 96 | 'type' => TPTDisplayType::FIELD_TYPE, |
| 79 | - 'options' => array( | |
| 80 | - 'default' => __( 'Default', 'tier-pricing-table' ), | |
| 81 | - 'style-1' => __( 'Style #1', 'tier-pricing-table' ), | |
| 82 | - 'style-2' => __( 'Style #2', 'tier-pricing-table' ), | |
| 83 | - 'style-3' => __( 'Style #3', 'tier-pricing-table' ), | |
| 84 | - 'style-4' => __( 'Style #4', 'tier-pricing-table' ), | |
| 85 | - 'style-5' => __( 'Style #5', 'tier-pricing-table' ), | |
| 86 | - 'style-6' => __( 'Style #6', 'tier-pricing-table' ), | |
| 87 | - ), | |
| 97 | + 'options' => GeneralSection::getStyleOptions()['blocks'], | |
| 88 | 98 | 'desc_tip' => true, |
| 89 | 99 | 'default' => 'default', |
| 90 | 100 | ), |
| 91 | 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( | |
| 92 | 116 | 'title' => __( 'Enable compact layout', 'tier-pricing-table' ), |
| 93 | 117 | 'id' => Settings::SETTINGS_PREFIX . 'compact_layout', |
| 94 | 118 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 95 | 119 | 'default' => 'no', |
| @@ -134,8 +158,40 @@ | ||
| 134 | 158 | 'desc_tip' => false, |
| 135 | 159 | 'default' => 'range', |
| 136 | 160 | ), |
| 137 | 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( | |
| 138 | 194 | 'title' => __( 'Active pricing tier color', 'tier-pricing-table' ), |
| 139 | 195 | 'id' => Settings::SETTINGS_PREFIX . 'selected_quantity_color', |
| 140 | 196 | 'type' => 'color', |
| 141 | 197 | 'css' => 'width:6em;', |
| @@ -141,8 +197,23 @@ | ||
| 141 | 197 | 'css' => 'width:6em;', |
| 142 | 198 | 'default' => '#3858e9', |
| 143 | 199 | ), |
| 144 | 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( | |
| 145 | 216 | 'title' => __( 'Tooltip icon color', 'tier-pricing-table' ), |
| 146 | 217 | 'id' => Settings::SETTINGS_PREFIX . 'tooltip_color', |
| 147 | 218 | 'type' => 'color', |
| 148 | 219 | 'default' => '#3858e9', |
| @@ -210,14 +281,32 @@ | ||
| 210 | 281 | 'desc' => __( 'Leave a column title empty to hide that column entirely.', 'tier-pricing-table' ), |
| 211 | 282 | 'type' => TPTTableColumnsField::FIELD_TYPE, |
| 212 | 283 | ), |
| 213 | 284 | array( |
| 214 | - 'title' => __( 'Show percentage discount', 'tier-pricing-table' ), | |
| 285 | + 'title' => __( 'Show discount', 'tier-pricing-table' ), | |
| 215 | 286 | 'id' => Settings::SETTINGS_PREFIX . 'show_discount_column', |
| 216 | 287 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 217 | 288 | 'default' => 'yes', |
| 218 | - 'desc' => __( 'Show the percentage discount in pricing blocks that offer a discount.', | |
| 289 | + 'desc' => __( 'Show the discount in pricing blocks that offer a discount.', | |
| 219 | 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', | |
| 220 | 309 | ), |
| 221 | 310 | array( |
| 222 | 311 | 'title' => __( 'Show original price crossed out', 'tier-pricing-table' ), |
| 223 | 312 | 'id' => Settings::SETTINGS_PREFIX . 'options_show_original_product_price', |