PluginProbe
Tiered Pricing Table for WooCommerce / 7.1.5
Tiered Pricing Table for WooCommerce v7.1.5
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 / ProductPagePriceSubsection.php

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

83 lines 3.5 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\Core\ServiceContainer;
4 use TierPricingTable\Settings\CustomOptions\TPTDisplayType;
5 use TierPricingTable\Settings\CustomOptions\TPTSwitchOption;
6 use TierPricingTable\Settings\Sections\SubsectionAbstract;
7 use TierPricingTable\Settings\Settings;
8
9 class ProductPagePriceSubsection extends SubsectionAbstract {
10
11 public function getTitle(): string {
12 return __( 'Single Product Page Pricing', 'tier-pricing-table' );
13 }
14
15 public function getDescription(): string {
16 return __( 'Manage how tiered prices are displayed and behave on single product pages.',
17 'tier-pricing-table' );
18 }
19
20 public function getSlug(): string {
21 return 'product_page_price';
22 }
23
24 public function getSettings(): array {
25 return array(
26 array(
27 'title' => __( 'Price display format', 'tier-pricing-table' ),
28 'id' => Settings::SETTINGS_PREFIX . 'product_page_price_format',
29 'type' => TPTDisplayType::FIELD_TYPE,
30 'options' => array(
31 'same_as_catalog' => __( 'Match Shop & Categories display (price range or lowest price)', 'tier-pricing-table' ),
32 'custom' => __( 'Actual price for selected quantity', 'tier-pricing-table' ),
33 ),
34 'default' => ServiceContainer::getInstance()->getSettings()->get( 'tiered_price_at_product_page',
35 'no' ) === 'yes' ? 'same_as_catalog' : 'custom',
36 ),
37 array(
38 'title' => __( 'Update price on quantity change', 'tier-pricing-table' ),
39 'id' => Settings::SETTINGS_PREFIX . 'update_price_on_product_page',
40 'type' => TPTSwitchOption::FIELD_TYPE,
41 'default' => 'yes',
42 'desc' => __( 'Automatically update the main product price whenever a customer changes the quantity input.',
43 'tier-pricing-table' ),
44 ),
45 array(
46 'title' => __( 'Show original price crossed out', 'tier-pricing-table' ),
47 'id' => Settings::SETTINGS_PREFIX . 'show_tiered_price_as_discount',
48 'type' => TPTSwitchOption::FIELD_TYPE,
49 'default' => 'yes',
50 'desc' => __( 'Cross out the regular price and show the discounted tiered price next to it when a higher quantity is selected.',
51 'tier-pricing-table' ),
52 ),
53 array(
54 'title' => __( 'Show total price (Price × Quantity)', 'tier-pricing-table' ),
55 'id' => Settings::SETTINGS_PREFIX . 'show_total_price',
56 'type' => TPTSwitchOption::FIELD_TYPE,
57 'default' => 'no',
58 'desc' => __( 'Multiply the main product price by the selected quantity instead of showing the per-item price.',
59 'tier-pricing-table' ),
60 'custom_attributes' => [ 'data-tiered-pricing-premium-option' => true ],
61 ),
62 array(
63 'title' => __( 'Show total price for non-tiered products', 'tier-pricing-table' ),
64 'id' => Settings::SETTINGS_PREFIX . 'show_total_price_non_tiered',
65 'type' => TPTSwitchOption::FIELD_TYPE,
66 'default' => 'no',
67 'desc' => __( 'Multiply the price by quantity even if the product has no tiered pricing rules.',
68 'tier-pricing-table' ),
69 'custom_attributes' => [ 'data-tiered-pricing-premium-option' => true ],
70 ),
71 );
72 }
73
74 public static function getFormatPriceType() {
75
76 $settings = ServiceContainer::getInstance()->getSettings();
77
78 $default = $settings->get( 'tiered_price_at_product_page', 'no' ) === 'yes' ? 'same_as_catalog' : 'custom';
79
80 return $settings->get( 'product_page_price_format', $default );
81 }
82 }
83