PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
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 / Addons / TieredPricingCart / CartOptionsSubsection.php

CartOptionsSubsection.php in Tiered Pricing Table for WooCommerce 8.0.2, at src/Addons/TieredPricingCart/CartOptionsSubsection.php

93 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\Addons\TieredPricingCart;
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 __( 'Cart Page Pricing', 'tier-pricing-table' );
11 }
12
13 public function getDescription(): string {
14 return __( 'Manage how tiered pricing and discounts appear on the cart page.', '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 original item price crossed out', 'tier-pricing-table' ),
25 'id' => Settings::SETTINGS_PREFIX . 'show_discount_in_cart',
26 'desc' => __( 'Show a crossed-out regular price next to the discounted tiered price in the cart. 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 original subtotal crossed out', 'tier-pricing-table' ),
33 'id' => Settings::SETTINGS_PREFIX . 'show_subtotal_as_discount_in_cart',
34 'desc' => __( 'Show a crossed-out regular subtotal next to the discounted subtotal in the cart.',
35 'tier-pricing-table' ),
36 'type' => TPTSwitchOption::FIELD_TYPE,
37 'default' => 'yes',
38 ),
39 array(
40 'title' => __( 'Cross out regular price instead of sale price', 'tier-pricing-table' ),
41 'id' => Settings::SETTINGS_PREFIX . 'consider_sale_price_as_discount_in_cart',
42 'desc' => __( 'When crossing out a price, always display the regular price rather than a sale price.',
43 'tier-pricing-table' ),
44 'type' => TPTSwitchOption::FIELD_TYPE,
45 'default' => 'no',
46 ),
47 array(
48 'title' => __( 'Show a total savings row', 'tier-pricing-table' ),
49 'id' => Settings::SETTINGS_PREFIX . 'cart_total_savings',
50 'desc' => __( 'A row in the cart totals and in the classic checkout\'s order review with the amount the tiered prices take off the cart. Not available with the Checkout block.', 'tier-pricing-table' ),
51 'type' => TPTSwitchOption::FIELD_TYPE,
52 'default' => 'no',
53 ),
54 array(
55 'title' => __( 'Total savings row label', 'tier-pricing-table' ),
56 'id' => Settings::SETTINGS_PREFIX . 'cart_total_savings_label',
57 'type' => 'text',
58 'default' => __( 'Total savings', 'tier-pricing-table' ),
59 'css' => 'width: 20em;',
60 ),
61 );
62 }
63
64 public static function showTotalSavings(): bool {
65 return get_option( Settings::SETTINGS_PREFIX . 'cart_total_savings', 'no' ) === 'yes';
66 }
67
68 public static function getTotalSavingsLabel(): string {
69 $label = (string) get_option( Settings::SETTINGS_PREFIX . 'cart_total_savings_label', '' );
70
71 return '' !== trim( $label ) ? $label : __( 'Total savings', 'tier-pricing-table' );
72 }
73
74
75 /**
76 * When a cart item has a tiered price, show its subtotal as a discount with the original subtotal crossed out.
77 *
78 * @return bool
79 */
80 public static function showSubtotalInCartAsDiscount(): bool {
81 return get_option( Settings::SETTINGS_PREFIX . 'show_subtotal_as_discount_in_cart', 'yes' ) === 'yes';
82 }
83
84 /**
85 * Do global pricing rules have a higher priority than product level rules?
86 *
87 * @return bool
88 */
89 public static function globalRulesOverrideProductLevelRules(): bool {
90 return get_option( Settings::SETTINGS_PREFIX . 'override_prices_by_global_rules', 'no' ) === 'yes';
91 }
92 }
93