Ejemplo n.º 1
0
 /**
  * Compares the properties of the given price item with its own one.
  *
  * This method compare only the essential price properties:
  * * Value
  * * Costs
  * * Rebate
  * * Tax rate
  * * Tax flag
  * * Quantity
  * * Currency ID
  *
  * All other item properties are not compared.
  *
  * @param \Aimeos\MShop\Price\Item\Iface $price Price item to compare with
  * @return boolean True if equal, false if not
  * @since 2014.09
  */
 public function compare(\Aimeos\MShop\Price\Item\Iface $price)
 {
     if ($this->getValue() === $price->getValue() && $this->getCosts() === $price->getCosts() && $this->getRebate() === $price->getRebate() && $this->getTaxRate() === $price->getTaxRate() && $this->getTaxFlag() === $price->getTaxFlag() && $this->getQuantity() === $price->getQuantity() && $this->getCurrencyId() === $price->getCurrencyId()) {
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Tests if the shipping threshold is reached and updates the price accordingly
  *
  * @param \Aimeos\MShop\Order\Item\Base\Iface $order Basket object
  * @param \Aimeos\MShop\Price\Item\Iface $price Delivery price item
  * @param array $threshold Associative list of currency/threshold pairs
  */
 protected function checkThreshold(\Aimeos\MShop\Order\Item\Base\Iface $order, \Aimeos\MShop\Price\Item\Iface $price, array $threshold)
 {
     $currency = $price->getCurrencyId();
     if (!isset($threshold[$currency])) {
         return;
     }
     $sum = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price')->createItem();
     foreach ($order->getProducts() as $product) {
         $sum->addItem($product->getPrice(), $product->getQuantity());
     }
     if ($sum->getValue() + $sum->getRebate() >= $threshold[$currency] && $price->getCosts() > '0.00') {
         $price->setRebate($price->getCosts());
         $price->setCosts('0.00');
     } else {
         if ($sum->getValue() + $sum->getRebate() < $threshold[$currency] && $price->getRebate() > '0.00') {
             $price->setCosts($price->getRebate());
             $price->setRebate('0.00');
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns the calculated amount of the price item
  *
  * @param \Aimeos\MShop\Price\Item\Iface $price Price item
  * @return string Formatted money amount
  */
 protected function getAmount(\Aimeos\MShop\Price\Item\Iface $price)
 {
     $amount = $price->getValue() + $price->getCosts();
     if ($price->getTaxFlag() === false) {
         $amount += $price->getTaxValue();
     }
     return number_format($amount, 2, '.', '');
 }
Ejemplo n.º 4
0
 /**
  * Returns the calculated amount of the price item
  *
  * @param \Aimeos\MShop\Price\Item\Iface $price Price item
  * @param boolean $costs Include costs per item
  * @param boolean $tax Include tax
  * @return string Formatted money amount
  */
 protected function getAmount(\Aimeos\MShop\Price\Item\Iface $price, $costs = true, $tax = true)
 {
     $amount = $price->getValue();
     if ($costs === true) {
         $amount += $price->getCosts();
     }
     if ($tax === true && $price->getTaxFlag() === false) {
         $tmp = clone $price;
         if ($costs === false) {
             $tmp->clear();
             $tmp->setValue($price->getValue());
             $tmp->setTaxRate($price->getTaxRate());
             $tmp->setQuantity($price->getQuantity());
         }
         $amount += $tmp->getTaxValue();
     }
     return number_format($amount, 2, '.', '');
 }