public function mergeWithCart(\Shop\Models\Carts $cart) { $cart_array = $cart->cast(); unset($cart_array['_id']); unset($cart_array['type']); unset($cart_array['metadata']); unset($cart_array['name']); $this->bind($cart_array); $this->number = $this->createNumber(); $this->grand_total = $cart->total(); $this->sub_total = $cart->subtotal(); $this->tax_total = $cart->taxTotal(); $this->shipping_total = $cart->shippingTotal(); $this->discount_total = $cart->discountTotal(); $this->shipping_discount_total = $cart->shippingDiscountTotal(); $this->credit_total = $cart->creditTotal(); $this->giftcard_total = $cart->giftCardTotal(); $user = (new \Users\Models\Users())->load(array('_id' => $this->user_id)); $this->customer = $user->cast(); $this->customer_name = $user->fullName(); $real_email = $user->email(true); if ($real_email != $this->user_email) { $this->user_email = $real_email; } // $order->is_guest = $cart->isGuest(); ? or is that from the checkout object? // $order->ip_address = $cart->ipAddress(); ? or is that from the checkout object? $this->comments = $cart->{'checkout.order_comments'}; // Shipping fields $this->shipping_required = $cart->shippingRequired(); if ($shipping_method = $cart->shippingMethod()) { $this->shipping_method = $shipping_method->cast(); } $this->shipping_address = $cart->{'checkout.shipping_address'}; // TODO Payment/Billing fields $this->billing_address = $cart->{'checkout.billing_address'}; $this->payment_required = $cart->paymentRequired(); return $this; }