Exemplo n.º 1
0
 /**
  * Creates cart from order - useful for cancelling orders.
  *
  * @param $cartId string Cart ID to use.
  * @param $order  Order Order to base cart on.
  *
  * @return \Jigoshop\Entity\Cart The cart.
  */
 public function createFromOrder($cartId, $order)
 {
     $cart = new \Jigoshop\Entity\Cart($this->options->get('tax.classes'));
     $cart->setId($cartId);
     $cart->setCustomer($order->getCustomer());
     $cart->setCustomerNote($order->getCustomerNote());
     $cart->setTaxDefinitions($order->getTaxDefinitions());
     foreach ($order->getItems() as $item) {
         /** @var $item Order\Item */
         $item = clone $item;
         $item->setId(false);
         $item->setKey(false);
         $cart->addItem($item);
     }
     //		foreach ($order->getCoupons() as $coupon) {
     //			$cart->addCoupon()
     //		}
     $shipping = $order->getShippingMethod();
     if ($shipping !== null) {
         $cart->setShippingMethod($shipping);
         $cart->setShippingTax($order->getShippingTax());
     }
     $payment = $order->getPaymentMethod();
     if ($payment !== null) {
         $cart->setPaymentMethod($payment);
     }
     return $cart;
 }