Source of file ItemPriceInfo.php
Size: 1,489 Bytes - Last Modified: 2021-12-23T10:25:05+00:00
/var/www/docs.ssmods.com/process/src/src/ItemPriceInfo.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 | <?php namespace SilverShop\Discounts; use SilverShop\Model\OrderItem; /** * Wrap PriceInfo with order item info */ class ItemPriceInfo extends PriceInfo { protected $item; protected $quantity; public function __construct(OrderItem $item) { $this->item = $item; $this->quantity = $item->Quantity; $originalprice = $item->hasMethod('DiscountableAmount') ? $item->DiscountableAmount() : $item->UnitPrice(); parent::__construct($originalprice); } public function getItem() { return $this->item; } public function getQuantity() { return $this->quantity; } public function getOriginalTotal() { return $this->originalprice * $this->quantity; } public function debug() { $discount = $this->getBestDiscount(); $total = $discount * $this->getQuantity(); $val = 'item: ' .$this->getItem()->TableTitle(); $price = $this->getOriginalPrice(); $val .= " price:$price discount:$discount total:$total.\n"; if ($best = $this->getBestAdjustment()) { $val .= $this->getBestAdjustment(). ' '; $val .= $this->getBestAdjustment()->getAdjuster()->Title; } else { $val .= 'No adjustments'; } $val .= "\n"; $val .= implode(',', $this->getAdjustments()); $val .= "\n\n"; return $val; } } |