Exemplo n.º 1
0
 private function getNewOrderItem(Address $address = null, CartItem $cartItem, ShippingOption $shippingOption = null)
 {
     $product = $cartItem->getProduct();
     $feeType = $address ? $address->getFeeType() : null;
     /** @var \App\Modules\OrderModule\Entities\OrderItem $orderItem */
     $orderItem = $this->orderItemRepository->createModel(['product_name' => $product->name, 'price' => $product->price, 'sale_price' => $product->sale_price, 'products_total' => $cartItem->products_total ?? 0, 'shipping_total' => $shippingOption && $feeType ? $shippingOption->{$feeType} * $cartItem->quantity : 0, 'quantity' => $cartItem->quantity]);
     $orderItem->setAttributes($cartItem->getAttributeOptions());
     if ($shippingOption && $address) {
         $orderItem->setShiping($shippingOption->snapshot($feeType, $cartItem->quantity));
     }
     $orderItem->setProduct($cartItem->getProduct());
     $this->cartItemRepository->delete($cartItem);
     return $orderItem;
 }
Exemplo n.º 2
0
 private function increaseQuantity(CartItem $cartItem, $quantity)
 {
     $this->cartItemRepository->increaseQuantity($cartItem, $quantity);
     return $this->success('add');
 }