tier-pricing-table
/
src
/
Settings
/
Sections
/
GeneralSection
/
Subsections
/
CartOptionsSubsection.php
CartOptionsSubsection.php in Tiered Pricing Table for WooCommerce 6.1.0, at src/Settings/Sections/GeneralSection/Subsections/CartOptionsSubsection.php
| 1 | <?php namespace TierPricingTable\Settings\Sections\GeneralSection\Subsections; |
| 2 | |
| 3 | use TierPricingTable\Settings\CustomOptions\TPTSwitchOption; |
| 4 | use TierPricingTable\Settings\Sections\SubsectionAbstract; |
| 5 | use TierPricingTable\Settings\Settings; |
| 6 | |
| 7 | class CartOptionsSubsection extends SubsectionAbstract { |
| 8 | |
| 9 | public function getTitle(): string { |
| 10 | return __( 'Tiered pricing in the cart', 'tier-pricing-table' ); |
| 11 | } |
| 12 | |
| 13 | public function getDescription(): string { |
| 14 | return __( 'Control how tiered pricing will be shown in the cart.', 'tier-pricing-table' ); |
| 15 | } |
| 16 | |
| 17 | public function getSlug(): string { |
| 18 | return 'cart'; |
| 19 | } |
| 20 | |
| 21 | public function getSettings(): array { |
| 22 | return array( |
| 23 | array( |
| 24 | 'title' => __( 'Show cart item price as a discount', 'tier-pricing-table' ), |
| 25 | 'id' => Settings::SETTINGS_PREFIX . 'show_discount_in_cart', |
| 26 | 'desc' => __( 'When a product in the cart has a tiered price, show it as a discount with a crossed-out original price near it. For example: ', |
| 27 | 'tier-pricing-table' ) . ' <b><del>$10.00</del> <ins>$8.00</ins><b>', |
| 28 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 29 | 'default' => 'yes', |
| 30 | ), |
| 31 | array( |
| 32 | 'title' => __( 'Show cart item subtotal as a discount', 'tier-pricing-table' ), |
| 33 | 'id' => Settings::SETTINGS_PREFIX . 'show_subtotal_as_discount_in_cart', |
| 34 | 'desc' => __( 'When a product in the cart has a tiered price, show its subtotal as a discount, similar to the option above.', |
| 35 | 'tier-pricing-table' ), |
| 36 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 37 | 'default' => 'yes', |
| 38 | ), |
| 39 | array( |
| 40 | 'title' => __( 'Always cross out the regular price', 'tier-pricing-table' ), |
| 41 | 'id' => Settings::SETTINGS_PREFIX . 'consider_sale_price_as_discount_in_cart', |
| 42 | 'desc' => __( 'When showing a crossed-out price, always use the regular price.', |
| 43 | 'tier-pricing-table' ), |
| 44 | 'type' => TPTSwitchOption::FIELD_TYPE, |
| 45 | 'default' => 'no', |
| 46 | ), |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | |
| 51 | /** |
| 52 | * When a cart item has a tiered price, show its subtotal as a discount with the original subtotal crossed out. |
| 53 | * |
| 54 | * @return bool |
| 55 | */ |
| 56 | public static function showSubtotalInCartAsDiscount(): bool { |
| 57 | return get_option( Settings::SETTINGS_PREFIX . 'show_subtotal_as_discount_in_cart', 'yes' ) === 'yes'; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Do global pricing rules have a higher priority than product level rules? |
| 62 | * |
| 63 | * @return bool |
| 64 | */ |
| 65 | public static function globalRulesOverrideProductLevelRules(): bool { |
| 66 | return get_option( Settings::SETTINGS_PREFIX . 'override_prices_by_global_rules', 'no' ) === 'yes'; |
| 67 | } |
| 68 | } |
| 69 |