PluginProbe
Tiered Pricing Table for WooCommerce / 6.4.0
Tiered Pricing Table for WooCommerce v6.4.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 / PricingRule.php

PricingRule.php in Tiered Pricing Table for WooCommerce 6.4.0, at src/PricingRule.php

86 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable;
2
3 class PricingRule {
4
5 protected $minimum = null;
6 protected $rules = array();
7 protected $type = 'fixed';
8 protected $productId;
9
10 public $provider = 'product';
11 public $providerData = array();
12
13 protected $modificationLog = array();
14
15 public $data = array();
16
17 public $customColumnsData = array();
18
19 public $pricingData = array(
20 'regular_price' => null,
21 'sale_price' => null,
22 'discount' => null,
23 'pricing_type' => null, // fixed or percentage
24 'tax_status' => null,
25 'tax_class' => null,
26 );
27
28 public function __construct( $productId ) {
29 $this->productId = intval( $productId );
30 }
31
32 public function getProductId(): int {
33 return $this->productId;
34 }
35
36 public function getMinimum( $forceValue = false ): ?int {
37
38 if ( $forceValue ) {
39 return $this->minimum ?: 1;
40 }
41
42 return $this->minimum;
43 }
44
45 public function setMinimum( ?int $minimum ) {
46 $this->minimum = $minimum > 0 ? $minimum : null;
47 }
48
49 public function getRules(): array {
50 return $this->rules;
51 }
52
53 public function setRules( array $rules ) {
54 $this->rules = $rules;
55 }
56
57 public function getType(): string {
58 return $this->type;
59 }
60
61 public function setType( string $type ) {
62 $this->type = in_array( $type, array( 'fixed', 'percentage' ) ) ? $type : 'fixed';
63 }
64
65 public function isPercentage(): bool {
66 return $this->getType() === 'percentage';
67 }
68
69 public function isFixed(): bool {
70 return $this->getType() === 'fixed';
71 }
72
73 public function getTierPrice( $quantity, bool $withTaxes = true, $place = 'shop', ?bool $round = null ) {
74 return PriceManager::getPriceByRules( $quantity, $this->getProductId(), 'view', $place, $withTaxes, $this,
75 $round );
76 }
77
78 public function logPricingModification( string $modification ) {
79 $this->modificationLog[] = $modification;
80 }
81
82 public function getPricingLog() {
83 return $this->modificationLog;
84 }
85 }
86