示例#1
0
 /**
  * Update cart status
  *
  * @param Cart $cart
  *
  * @return CartStrategy
  */
 protected function updateCartStatus(Cart $cart)
 {
     // allow to modify status only for "open" carts
     // because magento can only expire cart, so for different statuses this useless
     if ($this->existingEntity->getStatus()->getName() !== CartStatus::STATUS_OPEN) {
         $status = $this->existingEntity->getStatus();
     } else {
         $status = $cart->getStatus();
     }
     $cart->setStatus($status);
     return $this;
 }
示例#2
0
 /**
  * @param                 $billing
  * @param                 $shipping
  * @param Customer        $customer
  * @param ArrayCollection $item
  * @param CartStatus      $status
  *
  * @return Cart
  */
 protected function createCart($billing, $shipping, Customer $customer, ArrayCollection $item, $status)
 {
     $cart = new Cart();
     $cart->setChannel($this->integration);
     $cart->setDataChannel($this->channel);
     $cart->setBillingAddress($billing);
     $cart->setShippingAddress($shipping);
     $cart->setCustomer($customer);
     $cart->setEmail('*****@*****.**');
     $cart->setCreatedAt(new \DateTime('now'));
     $cart->setUpdatedAt(new \DateTime('now'));
     $cart->setCartItems($item);
     $cart->setStatus($status);
     $cart->setItemsQty(0);
     $cart->setItemsCount(1);
     $cart->setBaseCurrencyCode('code');
     $cart->setStoreCurrencyCode('code');
     $cart->setQuoteCurrencyCode('usd');
     $cart->setStoreToBaseRate(12);
     $cart->setGrandTotal(2.54);
     $cart->setIsGuest(0);
     $cart->setStore($this->store);
     $cart->setOwner($this->getUser());
     $cart->setOrganization($this->organization);
     $this->em->persist($cart);
     return $cart;
 }
示例#3
0
 /**
  * @param ObjectManager $om
  * @param Store         $store
  * @param Integration   $integration
  * @param Customer      $customer
  * @param CartStatus    $status
  * @param int           $origin
  * @param string        $currency
  * @param int           $rate
  *
  * @return Cart
  */
 protected function generateShoppingCart(ObjectManager $om, Store $store, Integration $integration, Customer $customer, CartStatus $status, $origin, $currency = 'USD', $rate = 1)
 {
     $cart = new Cart();
     $cart->setOrganization($this->organization);
     $cart->setChannel($integration);
     $cart->setCustomer($customer);
     $cart->setOwner($customer->getOwner());
     $cart->setStatus($status);
     $cart->setStore($store);
     $cart->setBaseCurrencyCode($currency);
     $cart->setStoreCurrencyCode($currency);
     $cart->setQuoteCurrencyCode($currency);
     $cart->setStoreToBaseRate($rate);
     $cart->setStoreToQuoteRate($rate);
     $cart->setIsGuest(0);
     $cart->setEmail($customer->getEmail());
     $cart->setCreatedAt(new \DateTime('now'));
     $cart->setUpdatedAt(new \DateTime('now'));
     $cart->setOriginId($origin);
     $cart->setDataChannel($this->dataChannel);
     $om->persist($cart);
     return $cart;
 }
示例#4
0
 /**
  * Update cart status
  *
  * @param Cart       $existingEntity
  * @param CartStatus $status
  */
 protected function updateCartStatus(Cart $existingEntity, CartStatus $status)
 {
     // allow to modify status only for "open" carts
     // because magento can only expire cart, so for different statuses this useless
     if ($existingEntity->getStatus()->getName() !== 'open') {
         $status = $existingEntity->getStatus();
     }
     $status = $this->strategyHelper->getEntityManager(MagentoConnectorInterface::CART_STATUS_TYPE)->getReference(MagentoConnectorInterface::CART_STATUS_TYPE, $status->getName());
     $existingEntity->setStatus($status);
 }
示例#5
0
 /**
  * @param Cart  $cart
  * @param array $data
  */
 protected function updateStatus(Cart $cart, array $data)
 {
     $statusClass = MagentoConnectorInterface::CART_STATUS_TYPE;
     $isActive = isset($data['is_active']) ? (bool) $data['is_active'] : true;
     $cart->setStatus(new $statusClass($isActive ? 'open' : 'expired'));
 }