PluginProbe
Tiered Pricing Table for WooCommerce / 6.1.0
Tiered Pricing Table for WooCommerce v6.1.0
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 / CalculationLogic / CalculationLogic.php

CalculationLogic.php in Tiered Pricing Table for WooCommerce 6.1.0, at src/Settings/Sections/CalculationLogic/CalculationLogic.php

135 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Settings\Sections\CalculationLogic;
2
3 use TierPricingTable\Settings\CustomOptions\TPTSwitchOption;
4 use TierPricingTable\Settings\Sections\SectionAbstract;
5 use TierPricingTable\Settings\Settings;
6
7 class CalculationLogic extends SectionAbstract {
8
9 public function getSettings() {
10
11 $settings = array();
12 $advanced = apply_filters( 'tiered_pricing_table/settings/calculation_logic', $this->getMainSettings() );
13
14 $sectionTitle = array(
15 'title' => __( 'Calculation logic', 'tier-pricing-table' ),
16 'desc' => __( 'This section controls how tiered pricing does calculations.', 'tier-pricing-table' ),
17 'id' => Settings::SETTINGS_PREFIX . 'calculation_logic',
18 'type' => 'title',
19 );
20
21 $sectionEnd = array(
22 'type' => 'sectionend',
23 );
24
25 $settings[] = $sectionTitle;
26 $settings = array_merge( $settings, $advanced );
27 $settings[] = $sectionEnd;
28
29 return array_merge( $settings, $this->getGlobalPricingRulesOptions() );
30 }
31
32 public function getMainSettings(): array {
33 return array(
34 array(
35 'title' => __( 'Consider product variations as one product', 'tier-pricing-table' ),
36 'id' => Settings::SETTINGS_PREFIX . 'summarize_variations',
37 'type' => TPTSwitchOption::FIELD_TYPE,
38 'default' => 'no',
39 'extended_description' => __( 'For the same variable product, the plugin will consider all its variations as the same product when calculating tiered pricing.',
40 'tier-pricing-table' ),
41 'desc_tip' => true,
42 ),
43 array(
44 'title' => __( 'Always use regular price to calculate percentage discounts',
45 'tier-pricing-table' ),
46 'id' => Settings::SETTINGS_PREFIX . 'calculate_discount_based_on_regular_price',
47 'type' => TPTSwitchOption::FIELD_TYPE,
48 'extended_description' => $this->getCalculateDiscountDescription(),
49 'default' => 'no',
50 ),
51 array(
52 'title' => __( 'Round price', 'tier-pricing-table' ),
53 'id' => Settings::SETTINGS_PREFIX . 'round_price',
54 'type' => TPTSwitchOption::FIELD_TYPE,
55 'default' => 'yes',
56 'extended_description' => __( 'WooCommerce rounds prices when showing them to users. To avoid possible rounding errors with displaying and calculation, the plugin rounds prices when calculating percentage discounts.',
57 'tier-pricing-table' ),
58 'desc_tip' => true,
59 ),
60 );
61 }
62
63 public function getCalculateDiscountDescription() {
64 ob_start();
65 ?>
66 <p>
67 <?php
68 esc_html_e( 'If enabled, the plugin will always use the regular price to calculate percentage discounts. By default, the plugin uses the sale price if it exists.',
69 'tier-pricing-table' );
70 ?>
71 </p>
72 <br>
73 <p>
74 <?php
75 esc_html_e( 'For example: if the regular product price is $100.00, the sale price is $90.00, and there is a tiered
76 pricing rule', 'tier-pricing-table' );
77 ?>
78 <br>
79 <b>
80 <?php esc_html_e( '20 pieces → 20% off', 'tier-pricing-table' ); ?>:
81 </b>
82 <br>
83 <?php
84 esc_html_e( 'When the option is disabled, 20% will be calculated based on the sale price, in this case — ',
85 'tier-pricing-table' );
86 ?>
87 <b>$90.00 - 20% = $72.00</b>.
88 <br>
89 <?php
90 esc_html_e( 'When the option is enabled, 20% will be calculated based on the regular price, in this case — ',
91 'tier-pricing-table' );
92 ?>
93 <b>$100.00 - 20% = $80.00</b>.
94 <br>
95 <br>
96 <?php
97 esc_html_e( 'This option is also affecting discount calculation in role-based and global pricing rules.',
98 'tier-pricing-table' );
99 ?>
100 </p>
101 <?php
102
103 return ob_get_clean();
104 }
105
106 public function getSlug(): string {
107 return 'calculation_logic';
108 }
109
110 public function getName(): string {
111 return __( 'Calculation Logic', 'tier-pricing-table' );
112 }
113
114 protected function getGlobalPricingRulesOptions(): array {
115 return array(
116 array(
117 'title' => __( 'Global pricing rules', 'tier-pricing-table' ),
118 'desc' => __( 'How global pricing rules behave.', 'tier-pricing-table' ),
119 'type' => 'title',
120 ),
121 array(
122 'title' => __( 'Override product level rules', 'tier-pricing-table' ),
123 'id' => Settings::SETTINGS_PREFIX . 'override_prices_by_global_rules',
124 'extended_description' => __( 'Make global rule override product level and role-based rules. When this option is disabled, product level rules will have a higher priority.',
125 'tier-pricing-table' ),
126 'type' => TPTSwitchOption::FIELD_TYPE,
127 'default' => 'no',
128 ),
129 array(
130 'type' => 'sectionend',
131 ),
132 );
133 }
134
135 }