tier-pricing-table
/
src
/
Settings
/
Sections
/
GeneralSection
/
Subsections
/
ProductPagePriceSubsection.php
ProductPagePriceSubsection.php in Tiered Pricing Table for WooCommerce 6.1.0, at src/Settings/Sections/GeneralSection/Subsections/ProductPagePriceSubsection.php
| 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 __( 'Price on the product page', 'tier-pricing-table' ); |
| 13 | } |
| 14 | |
| 15 | public function getDescription(): string { |
| 16 | return __( 'Control how the product price with tiered pricing will look and behave on the product page.', |
| 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 behaviour', '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 catalog display (price range or lowest price)', 'tier-pricing-table' ), |
| 32 | 'custom' => __( 'Dynamic', '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' => __( 'Show actual price', 'tier-pricing-table' ), |
| 39 | 'id' => Settings::SETTINGS_PREFIX . 'update_price_on_product_page', |
| 40 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 41 | 'default' => 'yes', |
| 42 | 'desc' => __( 'The product price is automatically updated when a new price tier is reached.', |
| 43 | 'tier-pricing-table' ), |
| 44 | ), |
| 45 | array( |
| 46 | 'title' => __( 'Show tiered price as a discount', 'tier-pricing-table' ), |
| 47 | 'id' => Settings::SETTINGS_PREFIX . 'show_tiered_price_as_discount', |
| 48 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 49 | 'default' => 'yes', |
| 50 | 'desc' => __( 'When a tiered price is applied, the original price will be crossed out and the discounted price shown.', |
| 51 | 'tier-pricing-table' ), |
| 52 | ), |
| 53 | array( |
| 54 | 'title' => __( 'Show total price', 'tier-pricing-table' ), |
| 55 | 'id' => Settings::SETTINGS_PREFIX . 'show_total_price', |
| 56 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 57 | 'default' => 'no', |
| 58 | 'desc' => __( 'The product price will be shown as a total price based on the selected pricing tier and quantity.', |
| 59 | 'tier-pricing-table' ), |
| 60 | 'custom_attributes' => [ 'data-tiered-pricing-premium-option' => true ], |
| 61 | ), |
| 62 | ); |
| 63 | } |
| 64 | |
| 65 | public static function getFormatPriceType() { |
| 66 | |
| 67 | $settings = ServiceContainer::getInstance()->getSettings(); |
| 68 | |
| 69 | $default = $settings->get( 'tiered_price_at_product_page', 'no' ) === 'yes' ? 'same_as_catalog' : 'custom'; |
| 70 | |
| 71 | return $settings->get( 'product_page_price_format', $default ); |
| 72 | } |
| 73 | } |
| 74 |