/** * Finds order specified by ID. * * @param $id int Order ID. * * @return Order */ public function find($id) { $post = null; if ($id !== null) { $post = $this->wp->getPost($id); } return $this->wp->applyFilters('jigoshop\\service\\order\\find', $this->factory->fetch($post), $id); }
/** * Find and fetches saved cart. * If cart is not found - returns new empty one. * * @param $id string Id of cart to fetch. * * @return \Jigoshop\Entity\Cart Prepared cart instance. */ public function get($id) { if (!isset($this->carts[$id])) { $cart = new Cart($this->options->get('tax.classes')); $cart->setCustomer($this->customerService->getCurrent()); $cart->getCustomer()->selectTaxAddress($this->options->get('taxes.shipping') ? 'shipping' : 'billing'); // Fetch data from session if available $cart->setId($id); $state = $this->getStateFromSession($id); if (isset($_POST['jigoshop_order']) && Pages::isCheckout()) { $state = $this->getStateFromCheckout($state); } // TODO: Support for transients? $cart = $this->orderFactory->fill($cart, $state); $this->carts[$id] = $this->wp->applyFilters('jigoshop\\service\\cart\\get', $cart, $state); } return $this->carts[$id]; }