Beispiel #1
0
 /**
  * Add new item taxes to the tax register
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @param ShoppCartItem $Item The cart item from shopp_cart_item_retotal
  * @return void
  **/
 public function itemtaxes(ShoppCartItem $Item)
 {
     $itemid = $Item->fingerprint();
     if (!$this->exists($itemid)) {
         return;
     }
     foreach ($Item->taxes as $id => &$ItemTax) {
         $this->Totals->register(new OrderAmountItemTax($ItemTax, $itemid));
     }
 }
Beispiel #2
0
 public function __construct(ShoppCartItem $Item)
 {
     $this->amount =& $Item->quantity;
     $this->id = $Item->fingerprint();
 }
Beispiel #3
0
 /**
  * Adds an item discount amount entry to the applied item discounts list
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @param ShoppCartItem $Item The item object to calculate a discount from
  * @return float The item discount amount
  **/
 public function item(ShoppCartItem $Item)
 {
     // These must result in the discount applied to the *unit price*!
     switch ($this->type) {
         case self::PERCENT_OFF:
             $amount = $Item->unitprice * ($this->discount() / 100);
             break;
         case self::AMOUNT_OFF:
             $amount = $this->discount();
             break;
         case self::SHIP_FREE:
             $Item->freeshipping = true;
             $this->shipping = true;
             $amount = 0;
             break;
         case self::BOGOF:
             list($buy, $get) = $this->discount();
             // The total quantity per discount
             $buying = $buy + $get;
             // The number of times the discount will apply
             $amount = $Item->quantity / $buying;
             // Keep the BOGOF factor floored when quantity over buying has remainders
             if ($Item->quantity % $buying) {
                 $amount = (int) floor($amount);
             }
             break;
     }
     $this->items[$Item->fingerprint()] = (double) $amount;
     return $amount;
 }