Exemplo n.º 1
0
 /**
  * Create cart data object based on given quote
  *
  * @param Quote $quote
  * @return Cart
  */
 protected function createCartDataObject(Quote $quote)
 {
     $this->cartBuilder->populateWithArray($this->cartMapper->map($quote));
     $this->customerBuilder->populateWithArray($this->customerMapper->map($quote));
     $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote));
     $this->totalsBuilder->setItems($this->fetchItemTotalsData($quote));
     $this->cartBuilder->setCustomer($this->customerBuilder->create());
     $this->cartBuilder->setTotals($this->totalsBuilder->create());
     $this->cartBuilder->setCurrency($this->currencyMapper->extractDto($quote));
     return $this->cartBuilder->create();
 }
Exemplo n.º 2
0
 /**
  * Fetch base quote data and map it to DTO fields
  *
  * @param Quote $quote
  * @return array
  */
 public function map(Quote $quote)
 {
     $this->cartBuilder->populateWithArray([Cart::ID => $quote->getId(), Cart::STORE_ID => $quote->getStoreId(), Cart::CREATED_AT => $quote->getCreatedAt(), Cart::UPDATED_AT => $quote->getUpdatedAt(), Cart::CONVERTED_AT => $quote->getConvertedAt(), Cart::IS_ACTIVE => $quote->getIsActive(), Cart::IS_VIRTUAL => $quote->getIsVirtual(), Cart::ITEMS_COUNT => $quote->getItemsCount(), Cart::ITEMS_QUANTITY => $quote->getItemsQty(), Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), Cart::ORIG_ORDER_ID => $quote->getOrigOrderId()]);
     $this->customerBuilder->populateWithArray($this->customerMapper->map($quote));
     $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote));
     $items = [];
     foreach ($quote->getAllItems() as $item) {
         $items[] = $this->itemTotalsMapper->extractDto($item);
     }
     $this->totalsBuilder->setItems($items);
     $this->cartBuilder->setCustomer($this->customerBuilder->create());
     $this->cartBuilder->setTotals($this->totalsBuilder->create());
     $this->cartBuilder->setCurrency($this->currencyMapper->extractDto($quote));
     return $this->cartBuilder->create();
 }