tier-pricing-table
/
src
/
Settings
/
Sections
/
GeneralSection
/
Subsections
/
LayoutSubsection.php
LayoutSubsection.php in Tiered Pricing Table for WooCommerce 7.1.1, at src/Settings/Sections/GeneralSection/Subsections/LayoutSubsection.php
| 1 | <?php namespace TierPricingTable\Settings\Sections\GeneralSection\Subsections; |
| 2 | |
| 3 | use TierPricingTable\Settings\CustomOptions\TPTDisplayType; |
| 4 | use TierPricingTable\Settings\CustomOptions\TPTTableColumnsField; |
| 5 | use TierPricingTable\Settings\CustomOptions\TPTQuantityMeasurementField; |
| 6 | use TierPricingTable\Settings\CustomOptions\TPTSwitchOption; |
| 7 | use TierPricingTable\Settings\CustomOptions\TPTTextTemplate; |
| 8 | use TierPricingTable\Settings\Sections\SubsectionAbstract; |
| 9 | use TierPricingTable\Settings\Settings; |
| 10 | use TierPricingTable\TierPricingTablePlugin; |
| 11 | |
| 12 | class LayoutSubsection extends SubsectionAbstract { |
| 13 | |
| 14 | public function getTitle(): string { |
| 15 | return __( 'Pricing Layout Settings', 'tier-pricing-table' ); |
| 16 | } |
| 17 | |
| 18 | public function getDescription(): string { |
| 19 | return __( 'Customize the appearance and behavior of your tiered pricing tables.', 'tier-pricing-table' ); |
| 20 | } |
| 21 | |
| 22 | public function getSlug(): string { |
| 23 | return 'layout'; |
| 24 | } |
| 25 | |
| 26 | public function getSettings(): array { |
| 27 | return array( |
| 28 | array( |
| 29 | 'title' => __( 'Show tiered pricing automatically', 'tier-pricing-table' ), |
| 30 | 'id' => Settings::SETTINGS_PREFIX . 'display', |
| 31 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 32 | 'default' => 'yes', |
| 33 | '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.', |
| 34 | 'tier-pricing-table' ), |
| 35 | 'desc_tip' => true, |
| 36 | ), |
| 37 | array( |
| 38 | 'title' => __( 'Default visual layout', 'tier-pricing-table' ), |
| 39 | 'id' => Settings::SETTINGS_PREFIX . 'display_type', |
| 40 | 'type' => TPTDisplayType::FIELD_TYPE, |
| 41 | 'options' => TierPricingTablePlugin::getAvailablePricingLayouts(), |
| 42 | 'desc' => __( 'Choose the default visual layout. You can also customize this individually per product.', |
| 43 | 'tier-pricing-table' ), |
| 44 | 'desc_tip' => true, |
| 45 | 'default' => 'table', |
| 46 | ), |
| 47 | array( |
| 48 | 'title' => __( 'Options design style', 'tier-pricing-table' ), |
| 49 | 'id' => Settings::SETTINGS_PREFIX . 'pricing_options_style', |
| 50 | '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 | ), |
| 58 | 'desc_tip' => true, |
| 59 | 'default' => 'default', |
| 60 | ), |
| 61 | array( |
| 62 | 'title' => __( 'Table design style', 'tier-pricing-table' ), |
| 63 | 'id' => Settings::SETTINGS_PREFIX . 'pricing_table_style', |
| 64 | '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 | ), |
| 72 | 'desc_tip' => true, |
| 73 | 'default' => 'default', |
| 74 | ), |
| 75 | array( |
| 76 | 'title' => __( 'Blocks design style', 'tier-pricing-table' ), |
| 77 | 'id' => Settings::SETTINGS_PREFIX . 'pricing_blocks_style', |
| 78 | '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 | ), |
| 88 | 'desc_tip' => true, |
| 89 | 'default' => 'default', |
| 90 | ), |
| 91 | array( |
| 92 | 'title' => __( 'Enable compact layout', 'tier-pricing-table' ), |
| 93 | 'id' => Settings::SETTINGS_PREFIX . 'compact_layout', |
| 94 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 95 | 'default' => 'no', |
| 96 | 'desc' => __( 'Apply a space-saving compact design for the selected layout.', 'tier-pricing-table' ), |
| 97 | ), |
| 98 | array( |
| 99 | 'title' => __( 'Layout title', 'tier-pricing-table' ), |
| 100 | 'id' => Settings::SETTINGS_PREFIX . 'table_title', |
| 101 | 'type' => 'text', |
| 102 | 'default' => '', |
| 103 | 'desc_tip' => true, |
| 104 | ), |
| 105 | array( |
| 106 | 'title' => __( 'Layout position', 'tier-pricing-table' ), |
| 107 | 'id' => Settings::SETTINGS_PREFIX . 'position_hook', |
| 108 | 'type' => 'select', |
| 109 | 'options' => array( |
| 110 | 'woocommerce_before_add_to_cart_button' => __( 'Above add to cart button', 'tier-pricing-table' ), |
| 111 | 'woocommerce_after_add_to_cart_button' => __( 'Below add to cart button', 'tier-pricing-table' ), |
| 112 | 'woocommerce_before_add_to_cart_form' => __( 'Above add to cart form', 'tier-pricing-table' ), |
| 113 | 'woocommerce_after_add_to_cart_form' => __( 'Below add to cart form', 'tier-pricing-table' ), |
| 114 | 'woocommerce_single_product_summary' => __( 'Above product title', 'tier-pricing-table' ), |
| 115 | 'woocommerce_before_single_product_summary' => __( 'Before product summary', 'tier-pricing-table' ), |
| 116 | 'woocommerce_after_single_product_summary' => __( 'After product summary', 'tier-pricing-table' ), |
| 117 | '____none____' => __( 'I display tiered pricing via shortcode/gutenberg/elementor', |
| 118 | 'tier-pricing-table' ), |
| 119 | ), |
| 120 | 'desc' => __( 'Choose where you what tiered pricing be displayed on the product page.', |
| 121 | 'tier-pricing-table' ), |
| 122 | 'desc_tip' => true, |
| 123 | ), |
| 124 | array( |
| 125 | 'title' => __( 'Quantity format', 'tier-pricing-table' ), |
| 126 | 'id' => Settings::SETTINGS_PREFIX . 'quantity_type', |
| 127 | 'type' => TPTDisplayType::FIELD_TYPE, |
| 128 | 'options' => array( |
| 129 | 'range' => __( 'Range', 'tier-pricing-table' ), |
| 130 | 'static' => __( 'Static values', 'tier-pricing-table' ), |
| 131 | ), |
| 132 | 'desc' => __( '"Range" displays the quantity range a tier applies to. "Static" displays only the minimum quantity required.', |
| 133 | 'tier-pricing-table' ), |
| 134 | 'desc_tip' => false, |
| 135 | 'default' => 'range', |
| 136 | ), |
| 137 | array( |
| 138 | 'title' => __( 'Active pricing tier color', 'tier-pricing-table' ), |
| 139 | 'id' => Settings::SETTINGS_PREFIX . 'selected_quantity_color', |
| 140 | 'type' => 'color', |
| 141 | 'css' => 'width:6em;', |
| 142 | 'default' => '#3858e9', |
| 143 | ), |
| 144 | array( |
| 145 | 'title' => __( 'Tooltip icon color', 'tier-pricing-table' ), |
| 146 | 'id' => Settings::SETTINGS_PREFIX . 'tooltip_color', |
| 147 | 'type' => 'color', |
| 148 | 'default' => '#3858e9', |
| 149 | 'css' => 'width:6em;', |
| 150 | 'desc' => __( 'Color of the icon.', 'tier-pricing-table' ), |
| 151 | 'desc_tip' => true, |
| 152 | ), |
| 153 | array( |
| 154 | 'title' => __( 'Tooltip icon size (px)', 'tier-pricing-table' ), |
| 155 | 'id' => Settings::SETTINGS_PREFIX . 'tooltip_size', |
| 156 | 'type' => 'number', |
| 157 | 'default' => '15', |
| 158 | 'css' => 'width:120px;', |
| 159 | 'desc' => __( 'Size of the icon.', 'tier-pricing-table' ), |
| 160 | 'desc_tip' => true, |
| 161 | ), |
| 162 | array( |
| 163 | 'title' => __( 'Tooltip border', 'tier-pricing-table' ), |
| 164 | 'id' => Settings::SETTINGS_PREFIX . 'tooltip_border', |
| 165 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 166 | 'default' => 'yes', |
| 167 | ), |
| 168 | array( |
| 169 | 'title' => __( 'Quantity unit label', 'tier-pricing-table' ), |
| 170 | 'id' => Settings::SETTINGS_PREFIX . 'table_quantity_measurement', |
| 171 | 'type' => TPTQuantityMeasurementField::FIELD_TYPE, |
| 172 | 'default' => array( |
| 173 | 'singular' => '', |
| 174 | 'plural' => '', |
| 175 | ), |
| 176 | 'desc' => __( 'For example: pieces, boxes, bottles, packs, etc. This will be shown next to quantity values. Leave blank to skip adding a unit label.', |
| 177 | 'tier-pricing-table' ), |
| 178 | ), |
| 179 | array( |
| 180 | 'title' => __( 'Quantity unit label', 'tier-pricing-table' ), |
| 181 | 'id' => Settings::SETTINGS_PREFIX . 'blocks_quantity_measurement', |
| 182 | 'type' => TPTQuantityMeasurementField::FIELD_TYPE, |
| 183 | 'default' => array( |
| 184 | 'singular' => _n( 'piece', 'pieces', 1, 'tier-pricing-table' ), |
| 185 | 'plural' => _n( 'piece', 'pieces', 2, 'tier-pricing-table' ), |
| 186 | ), |
| 187 | 'desc' => __( 'For example: pieces, boxes, bottles, packs, etc. This will be shown next to quantity values. Leave blank to skip adding a unit label.', |
| 188 | 'tier-pricing-table' ), |
| 189 | ), |
| 190 | array( |
| 191 | 'title' => __( 'Table column headers', 'tier-pricing-table' ), |
| 192 | 'id' => Settings::SETTINGS_PREFIX . 'table_columns_titles', |
| 193 | 'options' => array( |
| 194 | array( |
| 195 | 'label' => __( 'Quantity', 'tier-pricing-table' ), |
| 196 | 'id' => Settings::SETTINGS_PREFIX . 'head_quantity_text', |
| 197 | 'default' => __( 'Quantity', 'tier-pricing-table' ), |
| 198 | ), |
| 199 | array( |
| 200 | 'label' => __( 'Discount', 'tier-pricing-table' ), |
| 201 | 'id' => Settings::SETTINGS_PREFIX . 'head_discount_text', |
| 202 | 'default' => __( 'Discount (%)', 'tier-pricing-table' ), |
| 203 | ), |
| 204 | array( |
| 205 | 'label' => __( 'Price', 'tier-pricing-table' ), |
| 206 | 'id' => Settings::SETTINGS_PREFIX . 'head_price_text', |
| 207 | 'default' => __( 'Price', 'tier-pricing-table' ), |
| 208 | ), |
| 209 | ), |
| 210 | 'desc' => __( 'Leave a column title empty to hide that column entirely.', 'tier-pricing-table' ), |
| 211 | 'type' => TPTTableColumnsField::FIELD_TYPE, |
| 212 | ), |
| 213 | array( |
| 214 | 'title' => __( 'Show percentage discount', 'tier-pricing-table' ), |
| 215 | 'id' => Settings::SETTINGS_PREFIX . 'show_discount_column', |
| 216 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 217 | 'default' => 'yes', |
| 218 | 'desc' => __( 'Show the percentage discount in pricing blocks that offer a discount.', |
| 219 | 'tier-pricing-table' ), |
| 220 | ), |
| 221 | array( |
| 222 | 'title' => __( 'Show original price crossed out', 'tier-pricing-table' ), |
| 223 | 'id' => Settings::SETTINGS_PREFIX . 'options_show_original_product_price', |
| 224 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 225 | 'default' => 'yes', |
| 226 | 'desc' => __( 'Pricing options will show a crossed-out regular price next to the discounted tier price.', |
| 227 | 'tier-pricing-table' ), |
| 228 | ), |
| 229 | |
| 230 | array( |
| 231 | 'title' => __( 'Show total calculated price for selected option', 'tier-pricing-table' ), |
| 232 | 'id' => Settings::SETTINGS_PREFIX . 'options_show_total', |
| 233 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 234 | 'default' => 'yes', |
| 235 | 'desc' => __( 'The selected pricing option will dynamically display the total calculated cost.', 'tier-pricing-table' ), |
| 236 | 'custom_attributes' => [ 'data-tiered-pricing-premium-option' => true ], |
| 237 | ), |
| 238 | array( |
| 239 | 'title' => __( 'Pricing option text template', 'tier-pricing-table' ), |
| 240 | 'id' => Settings::SETTINGS_PREFIX . 'options_option_text', |
| 241 | 'default' => __( '<strong>Buy {tp_quantity} pieces and save {tp_rounded_discount}%</strong>', |
| 242 | 'tier-pricing-table' ), |
| 243 | 'placeholders' => array( |
| 244 | 'tp_quantity', |
| 245 | 'tp_discount', |
| 246 | 'tp_rounded_discount', |
| 247 | 'tp_base_unit_name', |
| 248 | ), |
| 249 | 'type' => TPTTextTemplate::FIELD_TYPE, |
| 250 | 'desc' => __( 'Use the variables above to build the template for the pricing option.', |
| 251 | 'tier-pricing-table' ), |
| 252 | ), |
| 253 | array( |
| 254 | 'title' => __( 'Show base price (no discount) option', 'tier-pricing-table' ), |
| 255 | 'id' => Settings::SETTINGS_PREFIX . 'options_show_default_option', |
| 256 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 257 | 'default' => 'yes', |
| 258 | 'desc' => __( 'Display an option for the regular product price (e.g. 1 item) where no tier discount is applied.', |
| 259 | 'tier-pricing-table' ), |
| 260 | ), |
| 261 | array( |
| 262 | 'title' => __( 'Base price option template', 'tier-pricing-table' ), |
| 263 | 'id' => Settings::SETTINGS_PREFIX . 'options_default_option_text', |
| 264 | 'default' => __( '<strong>Buy {tp_quantity} pieces</strong>', 'tier-pricing-table' ), |
| 265 | 'placeholders' => array( |
| 266 | 'tp_quantity', |
| 267 | 'tp_base_unit_name', |
| 268 | ), |
| 269 | 'type' => TPTTextTemplate::FIELD_TYPE, |
| 270 | 'desc' => __( 'Customize the template for the base price option.', |
| 271 | 'tier-pricing-table' ), |
| 272 | ), |
| 273 | array( |
| 274 | 'title' => __( 'Pricing string template', 'tier-pricing-table' ), |
| 275 | 'id' => Settings::SETTINGS_PREFIX . 'plain_text_template', |
| 276 | 'default' => __( '<strong>Buy {tp_quantity} pieces for {tp_price} each and save {tp_rounded_discount}%</strong>', |
| 277 | 'tier-pricing-table' ), |
| 278 | 'placeholders' => array( |
| 279 | 'tp_quantity', |
| 280 | 'tp_discount', |
| 281 | 'tp_price', |
| 282 | 'tp_rounded_discount', |
| 283 | 'tp_base_unit_name', |
| 284 | ), |
| 285 | 'type' => TPTTextTemplate::FIELD_TYPE, |
| 286 | 'desc' => __( 'Use the variables above to build the template for the pricing string.', |
| 287 | 'tier-pricing-table' ), |
| 288 | ), |
| 289 | array( |
| 290 | 'title' => __( 'Show first tier pricing string', 'tier-pricing-table' ), |
| 291 | 'id' => Settings::SETTINGS_PREFIX . 'plain_text_show_first_tier', |
| 292 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 293 | 'default' => 'yes', |
| 294 | 'desc' => __( 'Show the tier with a regular product price. This is the first pricing tier where no discount is offered.', |
| 295 | 'tier-pricing-table' ), |
| 296 | ), |
| 297 | |
| 298 | array( |
| 299 | 'title' => __( 'First tier pricing string template', 'tier-pricing-table' ), |
| 300 | 'id' => Settings::SETTINGS_PREFIX . 'plain_text_first_tier_template', |
| 301 | 'default' => __( '<strong>Buy {tp_quantity} pieces for {tp_price} each</strong>', |
| 302 | 'tier-pricing-table' ), |
| 303 | 'placeholders' => array( |
| 304 | 'tp_quantity', |
| 305 | 'tp_price', |
| 306 | 'tp_base_unit_name', |
| 307 | ), |
| 308 | 'type' => TPTTextTemplate::FIELD_TYPE, |
| 309 | 'desc' => __( 'Set up the first pricing tier template where a discount is not offered.', |
| 310 | 'tier-pricing-table' ), |
| 311 | ), |
| 312 | array( |
| 313 | 'title' => __( 'Make pricing tiers clickable', 'tier-pricing-table' ), |
| 314 | 'id' => Settings::SETTINGS_PREFIX . 'clickable_table_rows', |
| 315 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 316 | 'default' => 'yes', |
| 317 | 'desc' => __( 'Allow customers to click on a pricing tier (table row, block, or option) to automatically select that quantity.', |
| 318 | 'tier-pricing-table' ), |
| 319 | 'custom_attributes' => [ 'data-tiered-pricing-premium-option' => true ], |
| 320 | ), |
| 321 | ); |
| 322 | } |
| 323 | } |
| 324 |