PluginProbe
Tiered Pricing Table for WooCommerce / 6.5.0
Tiered Pricing Table for WooCommerce v6.5.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.5.0, at src/Settings/Sections/CalculationLogic/CalculationLogic.php

123 lines 4.1 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' => __( 'Calculations', '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' => __( 'Combine variations for quantity calculation',
36 'tier-pricing-table' ),
37 'id' => Settings::SETTINGS_PREFIX . 'summarize_variations',
38 'type' => TPTSwitchOption::FIELD_TYPE,
39 'default' => 'no',
40 'extended_description' => __( 'Treat all variations of a variable product as the same item when calculating the total cart quantity for tiered pricing rules.',
41 'tier-pricing-table' ),
42 'desc_tip' => true,
43 ),
44 array(
45 'title' => __( 'Calculate percentage discounts from regular price',
46 'tier-pricing-table' ),
47 'id' => Settings::SETTINGS_PREFIX . 'calculate_discount_based_on_regular_price',
48 'type' => TPTSwitchOption::FIELD_TYPE,
49 'extended_description' => $this->getCalculateDiscountDescription(),
50 'default' => 'no',
51 ),
52 array(
53 'title' => __( 'Round calculated prices', 'tier-pricing-table' ),
54 'id' => Settings::SETTINGS_PREFIX . 'round_price',
55 'type' => TPTSwitchOption::FIELD_TYPE,
56 'default' => 'yes',
57 'extended_description' => __( 'Round calculated percentage discounts to prevent minor display discrepancies with standard WooCommerce pricing.',
58 'tier-pricing-table' ),
59 'desc_tip' => true,
60 ),
61 );
62 }
63
64 public function getCalculateDiscountDescription() {
65 ob_start();
66 ?>
67 <p>
68 <?php
69 esc_html_e( 'Calculate percentage discounts using the product\'s regular price, ignoring any active sale prices.',
70 'tier-pricing-table' );
71 ?>
72 </p>
73 <p>
74 <?php
75 esc_html_e( 'Example: Regular price is $100.00, sale price is $90.00. Rule: 20% off.',
76 'tier-pricing-table' );
77 ?>
78 <br>
79 <?php
80 esc_html_e( 'Disabled (Default): Discount applies to the sale price ($90.00 - 20% = $72.00).',
81 'tier-pricing-table' );
82 ?>
83 <br>
84 <?php
85 esc_html_e( 'Enabled: Discount applies to the regular price ($100.00 - 20% = $80.00).',
86 'tier-pricing-table' );
87 ?>
88 </p>
89 <?php
90
91 return ob_get_clean();
92 }
93
94 public function getSlug(): string {
95 return 'calculation_logic';
96 }
97
98 public function getName(): string {
99 return __( 'Calculations', 'tier-pricing-table' );
100 }
101
102 protected function getGlobalPricingRulesOptions(): array {
103 return array(
104 array(
105 'title' => __( 'Global pricing rules', 'tier-pricing-table' ),
106 'desc' => __( 'How global pricing rules behave.', 'tier-pricing-table' ),
107 'type' => 'title',
108 ),
109 array(
110 'title' => __( 'Prioritize global pricing rules', 'tier-pricing-table' ),
111 'id' => Settings::SETTINGS_PREFIX . 'override_prices_by_global_rules',
112 'extended_description' => __( 'Apply global pricing rules before product-level rules. If disabled, individual product rules take precedence over global rules.',
113 'tier-pricing-table' ),
114 'type' => TPTSwitchOption::FIELD_TYPE,
115 'default' => 'no',
116 ),
117 array(
118 'type' => 'sectionend',
119 ),
120 );
121 }
122
123 }