| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Description of PriceFormulaSet |
| 5 |
* |
| 6 |
* @author Ali2Woo Team |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace AliNext_Lite;; |
| 10 |
|
| 11 |
class PriceFormulaSet |
| 12 |
{ |
| 13 |
public const NAME_FIELD = 'name'; |
| 14 |
public const DEFAULT_FORMULA_FIELD = 'default_formula'; |
| 15 |
public const FORMULA_LIST_FIELD = 'formula_list'; |
| 16 |
public const PRICE_CENTS_FIELD = 'price_cents'; |
| 17 |
public const PRICE_COMPARED_CENTS_FIELD = 'price_compared_cents'; |
| 18 |
public const USE_EXTENDED_PRICE_MARKUP_FIELD = 'use_extended_price_markup'; |
| 19 |
public const USE_COMPARED_PRICE_MARKUP_FIELD = 'use_compared_price_markup'; |
| 20 |
public const ADD_SHIPPING_TO_PRICE_FIELD = 'add_shipping_to_price'; |
| 21 |
public const APPLY_PRICE_RULES_AFTER_SHIPPING_COST_FIELD = 'apply_price_rules_after_shipping_cost'; |
| 22 |
public const PRICING_RULES_TYPE_FIELD = 'pricing_rules_type'; |
| 23 |
|
| 24 |
private string $name; |
| 25 |
|
| 26 |
private PriceFormula $PriceFormulaDefault; |
| 27 |
|
| 28 |
/** |
| 29 |
* @var array|PriceFormula[] |
| 30 |
*/ |
| 31 |
private array $PriceFormulasExtended = []; |
| 32 |
|
| 33 |
private int $cents = -1; |
| 34 |
private int $comparedCents = -1; |
| 35 |
|
| 36 |
private bool $useExtendedPriceMarkup = false; |
| 37 |
|
| 38 |
private bool $useComparedPriceMarkup = false; |
| 39 |
|
| 40 |
private bool $addShippingToPrice = false; |
| 41 |
|
| 42 |
private bool $applyPriceRulesAfterShippingCost = false; |
| 43 |
|
| 44 |
public string $pricingRulesType; |
| 45 |
|
| 46 |
public function getName(): string |
| 47 |
{ |
| 48 |
return $this->name; |
| 49 |
} |
| 50 |
|
| 51 |
public function setName(string $name): self |
| 52 |
{ |
| 53 |
$this->name = $name; |
| 54 |
|
| 55 |
return $this; |
| 56 |
} |
| 57 |
|
| 58 |
public function getDefaultFormula(): PriceFormula |
| 59 |
{ |
| 60 |
return $this->PriceFormulaDefault; |
| 61 |
} |
| 62 |
|
| 63 |
public function setDefaultFormula(PriceFormula $PriceFormula): self |
| 64 |
{ |
| 65 |
$this->PriceFormulaDefault = $PriceFormula; |
| 66 |
|
| 67 |
return $this; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* @return PriceFormula[]|array |
| 72 |
*/ |
| 73 |
public function getExtendedFormulas(): array |
| 74 |
{ |
| 75 |
return $this->PriceFormulasExtended; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* @param PriceFormula[]|array $PriceFormulas |
| 80 |
* @return $this |
| 81 |
*/ |
| 82 |
public function setExtendedFormulas(array $PriceFormulas): self |
| 83 |
{ |
| 84 |
$this->PriceFormulasExtended = $PriceFormulas; |
| 85 |
|
| 86 |
return $this; |
| 87 |
} |
| 88 |
|
| 89 |
public function getCents(): int |
| 90 |
{ |
| 91 |
return $this->cents; |
| 92 |
} |
| 93 |
|
| 94 |
public function setCents(int $cents): self |
| 95 |
{ |
| 96 |
$this->cents = $cents; |
| 97 |
|
| 98 |
return $this; |
| 99 |
} |
| 100 |
|
| 101 |
public function getComparedCents(): int |
| 102 |
{ |
| 103 |
return $this->comparedCents; |
| 104 |
} |
| 105 |
|
| 106 |
public function setComparedCents(int $comparedCents): self |
| 107 |
{ |
| 108 |
$this->comparedCents = $comparedCents; |
| 109 |
|
| 110 |
return $this; |
| 111 |
} |
| 112 |
|
| 113 |
public function getUseExtendedPriceMarkup(): bool |
| 114 |
{ |
| 115 |
return $this->useExtendedPriceMarkup; |
| 116 |
} |
| 117 |
|
| 118 |
public function setUseExtendedPriceMarkup(bool $useExtendedPriceMarkup): self |
| 119 |
{ |
| 120 |
$this->useExtendedPriceMarkup = $useExtendedPriceMarkup; |
| 121 |
|
| 122 |
return $this; |
| 123 |
} |
| 124 |
|
| 125 |
public function getUseComparedPriceMarkup(): bool |
| 126 |
{ |
| 127 |
return $this->useComparedPriceMarkup; |
| 128 |
} |
| 129 |
|
| 130 |
public function setUseComparedPriceMarkup(bool $useComparedPriceMarkup): self |
| 131 |
{ |
| 132 |
$this->useComparedPriceMarkup = $useComparedPriceMarkup; |
| 133 |
|
| 134 |
return $this; |
| 135 |
} |
| 136 |
|
| 137 |
public function getAddShippingToPrice(): bool |
| 138 |
{ |
| 139 |
return $this->addShippingToPrice; |
| 140 |
} |
| 141 |
|
| 142 |
public function setAddShippingToPrice(bool $addShippingToPrice): self |
| 143 |
{ |
| 144 |
$this->addShippingToPrice = $addShippingToPrice; |
| 145 |
|
| 146 |
return $this; |
| 147 |
} |
| 148 |
|
| 149 |
public function getApplyPriceRulesAfterShippingCost(): bool |
| 150 |
{ |
| 151 |
return $this->applyPriceRulesAfterShippingCost; |
| 152 |
} |
| 153 |
|
| 154 |
public function setApplyPriceRulesAfterShippingCost(bool $applyPriceRulesAfterShippingCost): self |
| 155 |
{ |
| 156 |
$this->applyPriceRulesAfterShippingCost = $applyPriceRulesAfterShippingCost; |
| 157 |
|
| 158 |
return $this; |
| 159 |
} |
| 160 |
|
| 161 |
public function getPricingRulesType(): string |
| 162 |
{ |
| 163 |
return $this->pricingRulesType; |
| 164 |
} |
| 165 |
|
| 166 |
public function setPricingRulesType(string $pricingRulesType): self |
| 167 |
{ |
| 168 |
$this->pricingRulesType = $pricingRulesType; |
| 169 |
|
| 170 |
return $this; |
| 171 |
} |
| 172 |
|
| 173 |
public function toArray(): array |
| 174 |
{ |
| 175 |
$extendedFormulas = []; |
| 176 |
|
| 177 |
foreach ($this->getExtendedFormulas() as $PriceFormula) { |
| 178 |
$extendedFormulas[] = $PriceFormula->toArray(); |
| 179 |
} |
| 180 |
|
| 181 |
return [ |
| 182 |
self::NAME_FIELD => $this->getName(), |
| 183 |
self::DEFAULT_FORMULA_FIELD => $this->getDefaultFormula()->toArray(), |
| 184 |
self::FORMULA_LIST_FIELD => $extendedFormulas, |
| 185 |
self::PRICE_CENTS_FIELD => $this->getCents(), |
| 186 |
self::PRICE_COMPARED_CENTS_FIELD => $this->getComparedCents(), |
| 187 |
self::USE_EXTENDED_PRICE_MARKUP_FIELD => $this->getUseExtendedPriceMarkup(), |
| 188 |
self::USE_COMPARED_PRICE_MARKUP_FIELD => $this->getUseComparedPriceMarkup(), |
| 189 |
self::ADD_SHIPPING_TO_PRICE_FIELD => $this->getAddShippingToPrice(), |
| 190 |
self::APPLY_PRICE_RULES_AFTER_SHIPPING_COST_FIELD => $this->getApplyPriceRulesAfterShippingCost(), |
| 191 |
self::PRICING_RULES_TYPE_FIELD => $this->getPricingRulesType(), |
| 192 |
]; |
| 193 |
} |
| 194 |
|
| 195 |
} |
| 196 |
|