| 1 |
<?php namespace TierPricingTable; |
| 2 |
|
| 3 |
use TierPricingTable\Settings\Settings; |
| 4 |
|
| 5 |
class CalculationLogic { |
| 6 |
|
| 7 |
/** |
| 8 |
* If product is on sale, calculate the discount based on the sale or regular price |
| 9 |
* |
| 10 |
* @return bool |
| 11 |
*/ |
| 12 |
public static function calculateDiscountBasedOnRegularPrice(): bool { |
| 13 |
return get_option( Settings::SETTINGS_PREFIX . 'calculate_discount_based_on_regular_price', 'no' ) === 'yes'; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Consider all variations from the same product as the same product, when tiered pricing calculates the price for a variation |
| 18 |
* |
| 19 |
* @return bool |
| 20 |
*/ |
| 21 |
public static function considerProductVariationAsOneProduct(): bool { |
| 22 |
return get_option( Settings::SETTINGS_PREFIX . 'summarize_variations', 'no' ) === 'yes'; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Round the final price, when tiered pricing calculates a percentage discount |
| 27 |
* |
| 28 |
* @return bool |
| 29 |
*/ |
| 30 |
public static function roundPrice(): bool { |
| 31 |
return get_option( Settings::SETTINGS_PREFIX . 'round_price', 'yes' ) === 'yes'; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Do global pricing rules have a higher priority than product level rules. |
| 36 |
* |
| 37 |
* @return bool |
| 38 |
*/ |
| 39 |
public static function globalRulesOverrideProductLevelRules(): bool { |
| 40 |
return get_option( Settings::SETTINGS_PREFIX . 'override_prices_by_global_rules', 'no' ) === 'yes'; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* When cart item has a tiered price, show it as a discount with the original price crossed out. |
| 45 |
* |
| 46 |
* @return bool |
| 47 |
*/ |
| 48 |
public static function showTieredPriceInCartAsDiscount(): bool { |
| 49 |
return get_option( Settings::SETTINGS_PREFIX . 'show_discount_in_cart', 'yes' ) === 'yes'; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Mix and match minimum order quantity for variable products |
| 54 |
* |
| 55 |
* @return bool |
| 56 |
*/ |
| 57 |
public static function isMixAndMatchMinimumEnabled(): bool { |
| 58 |
return get_option( Settings::SETTINGS_PREFIX . 'mix_and_match_minimum', 'no' ) === 'yes'; |
| 59 |
} |
| 60 |
} |
| 61 |
|