/** * @param Basket $basket * * @return array */ public function products(Basket $basket) { $products = []; foreach ($basket->products() as $product) { $products[] = ['sku' => $product->sku, 'name' => $product->name, 'price' => $product->price, 'rate' => $product->rate, 'quantity' => $product->quantity, 'freebie' => $product->freebie, 'taxable' => $product->taxable, 'delivery' => $product->delivery, 'coupons' => $product->coupons, 'tags' => $product->tags, 'discounts' => $product->discounts, 'category' => $product->category, 'total_value' => $this->reconciler->value($product), 'total_discount' => $this->reconciler->discount($product), 'total_delivery' => $this->reconciler->delivery($product), 'total_tax' => $this->reconciler->tax($product), 'subtotal' => $this->reconciler->subtotal($product), 'total' => $this->reconciler->total($product)]; } return $products; }
/** * @param Basket $basket * * @return Money */ public function generate(Basket $basket) { $total = new Money(0, $basket->currency()); foreach ($basket->products() as $product) { $total = $total->add($this->reconciler->delivery($product)); } return $total; }
/** * @param Basket $basket * * @return int */ public function generate(Basket $basket) { $total = 0; foreach ($basket->products() as $product) { $total = $total + $product->quantity; } return $total; }