예제 #1
0
 /**
  * Create checkout quote.
  *
  * @param OrderInjectable $order
  * @return void
  * @throws \Exception
  */
 protected function createQuote(OrderInjectable $order)
 {
     $url = $_ENV['app_frontend_url'] . 'rest/V1/customers/' . $order->getCustomerId()->getId() . '/carts';
     $data = '{"customerId": "' . $order->getCustomerId()->getId() . '"}';
     $this->webapiTransport->write($url, $data);
     $response = json_decode($this->webapiTransport->read(), true);
     $this->webapiTransport->close();
     if (!is_numeric($response)) {
         $this->eventManager->dispatchEvent(['webapi_failed'], [$response]);
         throw new \Exception('Could not create a checkout quote using web API.');
     }
     $this->quote = $response;
 }