{"id":72211,"date":"2017-01-20T16:14:10","date_gmt":"2017-01-20T16:14:10","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=72211"},"modified":"2017-01-20T16:14:10","modified_gmt":"2017-01-20T16:14:10","slug":"use-cart-api-opencart","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/","title":{"rendered":"How to use cart api in Opencart"},"content":{"rendered":"<p>In our previous blog :<a href=\"http:\/\/webkul.com\/blog\/use-customer-api-opencart\/\"> http:\/\/webkul.com\/blog\/use-customer-api-opencart\/\u00a0<\/a> , we learnt how to use customer\u00a0api in opencart . Today we will learn , how use cart api in opencart \u00a0.<\/p>\n<p>Opencart uses the cart api in the product section while adding or editing\u00a0the order from the admin end . After adding the customer from the \u00a0sales-&gt;orders then add\/edit \u00a0when we click the continue button , then it goes to the product section .<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-72216\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/product-3.png\" alt=\"\" width=\"1290\" height=\"668\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/product-3.png 1290w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/product-3-250x129.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/product-3-300x155.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/product-3-768x398.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/product-3-1200x621.png 1200w\" sizes=\"(max-width: 1290px) 100vw, 1290px\" loading=\"lazy\" \/><\/p>\n<p>After selecting the product when , we click on add product button , Two\u00a0methods of the cart api will be called \u00a0.First is &#8216;add&#8217; . The add method is used to add the product into the cart . The code is given below:<\/p>\n<pre class=\"brush:php\">\/**\r\n * Webkul Software.\r\n *\r\n * @category Webkul\r\n * @package api\r\n * @author Webkul\r\n * @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https:\/\/webkul.com)\r\n * @license https:\/\/store.webkul.com\/license.html\r\n *\/\r\npublic function add() {\r\n\t$this-&gt;load-&gt;language('api\/cart');\r\n\r\n\t$json = array();\r\n\r\n\t\/\/Check for api login\r\n\tif (!isset($this-&gt;session-&gt;data['api_id'])) {\r\n\t\t$json['error']['warning'] = $this-&gt;language-&gt;get('error_permission');\r\n\t} else {\r\n\t\t\/\/Condition is true when when we edit the order from the admin end\r\n\t\tif (isset($this-&gt;request-&gt;post['product'])) {\r\n\t\t\t$this-&gt;cart-&gt;clear();\r\n\r\n\t\t\tforeach ($this-&gt;request-&gt;post['product'] as $product) {\r\n\t\t\t\tif (isset($product['option'])) {\r\n\t\t\t\t\t$option = $product['option'];\r\n\t\t\t\t} else {\r\n\t\t\t\t\t$option = array();\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$this-&gt;cart-&gt;add($product['product_id'], $product['quantity'], $option);\r\n\t\t\t}\r\n\r\n\t\t\t$json['success'] = $this-&gt;language-&gt;get('text_success');\r\n\r\n\t\t\tunset($this-&gt;session-&gt;data['shipping_method']);\r\n\t\t\tunset($this-&gt;session-&gt;data['shipping_methods']);\r\n\t\t\tunset($this-&gt;session-&gt;data['payment_method']);\r\n\t\t\tunset($this-&gt;session-&gt;data['payment_methods']);\r\n\t\t\/\/Condition is true when we add the product in the order from the admin end\r\n\t\t} elseif (isset($this-&gt;request-&gt;post['product_id'])) {\r\n\t\t\t$this-&gt;load-&gt;model('catalog\/product');\r\n\r\n\t\t\t\/\/Get the product information\r\n\t\t\t$product_info = $this-&gt;model_catalog_product-&gt;getProduct($this-&gt;request-&gt;post['product_id']);\r\n\r\n\t\t\tif ($product_info) {\r\n\t\t\t\tif (isset($this-&gt;request-&gt;post['quantity'])) {\r\n\t\t\t\t\t$quantity = $this-&gt;request-&gt;post['quantity'];\r\n\t\t\t\t} else {\r\n\t\t\t\t\t$quantity = 1;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (isset($this-&gt;request-&gt;post['option'])) {\r\n\t\t\t\t\t$option = array_filter($this-&gt;request-&gt;post['option']);\r\n\t\t\t\t} else {\r\n\t\t\t\t\t$option = array();\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$product_options = $this-&gt;model_catalog_product-&gt;getProductOptions($this-&gt;request-&gt;post['product_id']);\r\n\r\n\t\t\t\tforeach ($product_options as $product_option) {\r\n\t\t\t\t\tif ($product_option['required'] &amp;&amp; empty($option[$product_option['product_option_id']])) {\r\n\t\t\t\t\t\t$json['error']['option'][$product_option['product_option_id']] = sprintf($this-&gt;language-&gt;get('error_required'), $product_option['name']);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (!isset($json['error']['option'])) {\r\n\t\t\t\t\t$this-&gt;cart-&gt;add($this-&gt;request-&gt;post['product_id'], $quantity, $option);\r\n\r\n\t\t\t\t\t$json['success'] = $this-&gt;language-&gt;get('text_success');\r\n\r\n\t\t\t\t\tunset($this-&gt;session-&gt;data['shipping_method']);\r\n\t\t\t\t\tunset($this-&gt;session-&gt;data['shipping_methods']);\r\n\t\t\t\t\tunset($this-&gt;session-&gt;data['payment_method']);\r\n\t\t\t\t\tunset($this-&gt;session-&gt;data['payment_methods']);\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t$json['error']['store'] = $this-&gt;language-&gt;get('error_store');\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t\/\/Response in json format\r\n\t$this-&gt;response-&gt;addHeader('Content-Type: application\/json');\r\n\t$this-&gt;response-&gt;setOutput(json_encode($json));\r\n}<\/pre>\n<p>If product is added successfully then add method will return the success message.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-72217\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/success.png\" alt=\"\" width=\"505\" height=\"40\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/success.png 505w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/success-250x20.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/success-300x24.png 300w\" sizes=\"(max-width: 505px) 100vw, 505px\" loading=\"lazy\" \/><\/p>\n<p>After adding the product , &#8216;products&#8217; method will be called . The &#8216;products&#8217; method is used to fetch the cart products .The code is given below:<\/p>\n<pre class=\"brush:php\">\/**\r\n * Webkul Software.\r\n *\r\n * @category Webkul\r\n * @package api\r\n * @author Webkul\r\n * @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https:\/\/webkul.com)\r\n * @license https:\/\/store.webkul.com\/license.html\r\n *\/\r\npublic function products() {\r\n\t$this-&gt;load-&gt;language('api\/cart');\r\n\r\n\t$json = array();\r\n\r\n\t\/\/Check for api login\r\n\tif (!isset($this-&gt;session-&gt;data['api_id'])) {\r\n\t\t$json['error']['warning'] = $this-&gt;language-&gt;get('error_permission');\r\n\t} else {\r\n\t\t\/\/ Stock\r\n\t\tif (!$this-&gt;cart-&gt;hasStock() &amp;&amp; (!$this-&gt;config-&gt;get('config_stock_checkout') || $this-&gt;config-&gt;get('config_stock_warning'))) {\r\n\t\t\t$json['error']['stock'] = $this-&gt;language-&gt;get('error_stock');\r\n\t\t}\r\n\r\n\t\t\/\/ Products\r\n\t\t$json['products'] = array();\r\n\r\n\t\t$products = $this-&gt;cart-&gt;getProducts();\r\n\r\n\t\tforeach ($products as $product) {\r\n\t\t\t$product_total = 0;\r\n\r\n\t\t\tforeach ($products as $product_2) {\r\n\t\t\t\tif ($product_2['product_id'] == $product['product_id']) {\r\n\t\t\t\t\t$product_total += $product_2['quantity'];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif ($product['minimum'] &gt; $product_total) {\r\n\t\t\t\t$json['error']['minimum'][] = sprintf($this-&gt;language-&gt;get('error_minimum'), $product['name'], $product['minimum']);\r\n\t\t\t}\r\n\r\n\t\t\t$option_data = array();\r\n\r\n\t\t\tforeach ($product['option'] as $option) {\r\n\t\t\t\t$option_data[] = array(\r\n\t\t\t\t\t'product_option_id'       =&gt; $option['product_option_id'],\r\n\t\t\t\t\t'product_option_value_id' =&gt; $option['product_option_value_id'],\r\n\t\t\t\t\t'name'                    =&gt; $option['name'],\r\n\t\t\t\t\t'value'                   =&gt; $option['value'],\r\n\t\t\t\t\t'type'                    =&gt; $option['type']\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\t$json['products'][] = array(\r\n\t\t\t\t'cart_id'    =&gt; $product['cart_id'],\r\n\t\t\t\t'product_id' =&gt; $product['product_id'],\r\n\t\t\t\t'name'       =&gt; $product['name'],\r\n\t\t\t\t'model'      =&gt; $product['model'],\r\n\t\t\t\t'option'     =&gt; $option_data,\r\n\t\t\t\t'quantity'   =&gt; $product['quantity'],\r\n\t\t\t\t'stock'      =&gt; $product['stock'] ? true : !(!$this-&gt;config-&gt;get('config_stock_checkout') || $this-&gt;config-&gt;get('config_stock_warning')),\r\n\t\t\t\t'shipping'   =&gt; $product['shipping'],\r\n\t\t\t\t'price'      =&gt; $this-&gt;currency-&gt;format($this-&gt;tax-&gt;calculate($product['price'], $product['tax_class_id'], $this-&gt;config-&gt;get('config_tax')), $this-&gt;session-&gt;data['currency']),\r\n\t\t\t\t'total'      =&gt; $this-&gt;currency-&gt;format($this-&gt;tax-&gt;calculate($product['price'], $product['tax_class_id'], $this-&gt;config-&gt;get('config_tax')) * $product['quantity'], $this-&gt;session-&gt;data['currency']),\r\n\t\t\t\t'reward'     =&gt; $product['reward']\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\t\/\/ Voucher\r\n\t\t$json['vouchers'] = array();\r\n\r\n\t\tif (!empty($this-&gt;session-&gt;data['vouchers'])) {\r\n\t\t\tforeach ($this-&gt;session-&gt;data['vouchers'] as $key =&gt; $voucher) {\r\n\t\t\t\t$json['vouchers'][] = array(\r\n\t\t\t\t\t'code'             =&gt; $voucher['code'],\r\n\t\t\t\t\t'description'      =&gt; $voucher['description'],\r\n\t\t\t\t\t'from_name'        =&gt; $voucher['from_name'],\r\n\t\t\t\t\t'from_email'       =&gt; $voucher['from_email'],\r\n\t\t\t\t\t'to_name'          =&gt; $voucher['to_name'],\r\n\t\t\t\t\t'to_email'         =&gt; $voucher['to_email'],\r\n\t\t\t\t\t'voucher_theme_id' =&gt; $voucher['voucher_theme_id'],\r\n\t\t\t\t\t'message'          =&gt; $voucher['message'],\r\n\t\t\t\t\t'price'            =&gt; $this-&gt;currency-&gt;format($voucher['amount'], $this-&gt;session-&gt;data['currency']),\t\t\t\r\n\t\t\t\t\t'amount'           =&gt; $voucher['amount']\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t\/\/ Totals\r\n\t\t$this-&gt;load-&gt;model('extension\/extension');\r\n\r\n\t\t$totals = array();\r\n\t\t$taxes = $this-&gt;cart-&gt;getTaxes();\r\n\t\t$total = 0;\r\n\r\n\t\t\/\/ Because __call can not keep var references so we put them into an array. \r\n\t\t$total_data = array(\r\n\t\t\t'totals' =&gt; &amp;$totals,\r\n\t\t\t'taxes'  =&gt; &amp;$taxes,\r\n\t\t\t'total'  =&gt; &amp;$total\r\n\t\t);\r\n\t\t\r\n\t\t$sort_order = array();\r\n\r\n\t\t$results = $this-&gt;model_extension_extension-&gt;getExtensions('total');\r\n\r\n\t\tforeach ($results as $key =&gt; $value) {\r\n\t\t\t$sort_order[$key] = $this-&gt;config-&gt;get($value['code'] . '_sort_order');\r\n\t\t}\r\n\r\n\t\tarray_multisort($sort_order, SORT_ASC, $results);\r\n\r\n\t\tforeach ($results as $result) {\r\n\t\t\tif ($this-&gt;config-&gt;get($result['code'] . '_status')) {\r\n\t\t\t\t$this-&gt;load-&gt;model('total\/' . $result['code']);\r\n\t\t\t\t\r\n\t\t\t\t\/\/ We have to put the totals in an array so that they pass by reference.\r\n\t\t\t\t$this-&gt;{'model_total_' . $result['code']}-&gt;getTotal($total_data);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t$sort_order = array();\r\n\r\n\t\tforeach ($totals as $key =&gt; $value) {\r\n\t\t\t$sort_order[$key] = $value['sort_order'];\r\n\t\t}\r\n\r\n\t\tarray_multisort($sort_order, SORT_ASC, $totals);\r\n\r\n\t\t$json['totals'] = array();\r\n\r\n\t\tforeach ($totals as $total) {\r\n\t\t\t$json['totals'][] = array(\r\n\t\t\t\t'title' =&gt; $total['title'],\r\n\t\t\t\t'text'  =&gt; $this-&gt;currency-&gt;format($total['value'], $this-&gt;session-&gt;data['currency'])\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t\/\/Response in json format\r\n\t$this-&gt;response-&gt;addHeader('Content-Type: application\/json');\r\n\t$this-&gt;response-&gt;setOutput(json_encode($json));\r\n}<\/pre>\n<p>If products fetched successfully , then it will return the details of the product that are currently in the cart . The response will look like as follows :<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-72218\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/success1.png\" alt=\"\" width=\"818\" height=\"66\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/success1.png 818w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/success1-250x20.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/success1-300x24.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/success1-768x62.png 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" loading=\"lazy\" \/><\/p>\n<p>We can also remove the added product by clicking the remove button placed in the action column of product table . When we click the remove button , remove method of cart api will be called . The code for remove method is :<\/p>\n<pre class=\"brush:php\">\/**\r\n * Webkul Software.\r\n *\r\n * @category Webkul\r\n * @package api\r\n * @author Webkul\r\n * @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https:\/\/webkul.com)\r\n * @license https:\/\/store.webkul.com\/license.html\r\n *\/\r\npublic function remove() {\r\n\t$this-&gt;load-&gt;language('api\/cart');\r\n\r\n\t$json = array();\r\n\r\n\tif (!isset($this-&gt;session-&gt;data['api_id'])) {\r\n\t\t$json['error'] = $this-&gt;language-&gt;get('error_permission');\r\n\t} else {\r\n\t\t\/\/ Remove\r\n\t\tif (isset($this-&gt;request-&gt;post['key'])) {\r\n\t\t\t$this-&gt;cart-&gt;remove($this-&gt;request-&gt;post['key']);\r\n\r\n\t\t\tunset($this-&gt;session-&gt;data['vouchers'][$this-&gt;request-&gt;post['key']]);\r\n\r\n\t\t\t$json['success'] = $this-&gt;language-&gt;get('text_success');\r\n\r\n\t\t\tunset($this-&gt;session-&gt;data['shipping_method']);\r\n\t\t\tunset($this-&gt;session-&gt;data['shipping_methods']);\r\n\t\t\tunset($this-&gt;session-&gt;data['payment_method']);\r\n\t\t\tunset($this-&gt;session-&gt;data['payment_methods']);\r\n\t\t\tunset($this-&gt;session-&gt;data['reward']);\r\n\t\t}\r\n\t}\r\n\r\n\t\/\/Resonse in json format\r\n\t$this-&gt;response-&gt;addHeader('Content-Type: application\/json');\r\n\t$this-&gt;response-&gt;setOutput(json_encode($json));\r\n}<\/pre>\n<p>If product successfully removed , then it will return the success method as given below :<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-72224\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/cart_remove.png\" alt=\"\" width=\"481\" height=\"33\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/cart_remove.png 481w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/cart_remove-250x17.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/cart_remove-300x21.png 300w\" sizes=\"(max-width: 481px) 100vw, 481px\" loading=\"lazy\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our previous blog : http:\/\/webkul.com\/blog\/use-customer-api-opencart\/\u00a0 , we learnt how to use customer\u00a0api in opencart . Today we will learn , how use cart api in opencart \u00a0. Opencart uses the cart api in the product section while adding or editing\u00a0the order from the admin end . After adding the customer from the \u00a0sales-&gt;orders then <a href=\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":124,"featured_media":41008,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[305],"tags":[2253],"class_list":["post-72211","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-opencart","tag-rest-api"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use cart api in Opencart - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use cart api in Opencart - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"In our previous blog : http:\/\/webkul.com\/blog\/use-customer-api-opencart\/\u00a0 , we learnt how to use customer\u00a0api in opencart . Today we will learn , how use cart api in opencart \u00a0. Opencart uses the cart api in the product section while adding or editing\u00a0the order from the admin end . After adding the customer from the \u00a0sales-&gt;orders then [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-01-20T16:14:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Sarang Agrawal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sarang Agrawal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/\"},\"author\":{\"name\":\"Sarang Agrawal\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3fe787f5e9200d06d3ebf9aa86af1558\"},\"headline\":\"How to use cart api in Opencart\",\"datePublished\":\"2017-01-20T16:14:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/\"},\"wordCount\":237,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"keywords\":[\"REST API\"],\"articleSection\":[\"opencart\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/\",\"url\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/\",\"name\":\"How to use cart api in Opencart - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"datePublished\":\"2017-01-20T16:14:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use cart api in Opencart\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3fe787f5e9200d06d3ebf9aa86af1558\",\"name\":\"Sarang Agrawal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/463bd0dd4a24de98604547719c1903e8af6b4133153ba8cc08799c7b2e3a5ce6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/463bd0dd4a24de98604547719c1903e8af6b4133153ba8cc08799c7b2e3a5ce6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Sarang Agrawal\"},\"sameAs\":[\"http:\/\/webkul.com\/blog\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/sarang-agrawal032\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use cart api in Opencart - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/","og_locale":"en_US","og_type":"article","og_title":"How to use cart api in Opencart - Webkul Blog","og_description":"In our previous blog : http:\/\/webkul.com\/blog\/use-customer-api-opencart\/\u00a0 , we learnt how to use customer\u00a0api in opencart . Today we will learn , how use cart api in opencart \u00a0. Opencart uses the cart api in the product section while adding or editing\u00a0the order from the admin end . After adding the customer from the \u00a0sales-&gt;orders then [...]","og_url":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2017-01-20T16:14:10+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","type":"image\/png"}],"author":"Sarang Agrawal","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sarang Agrawal","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/"},"author":{"name":"Sarang Agrawal","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3fe787f5e9200d06d3ebf9aa86af1558"},"headline":"How to use cart api in Opencart","datePublished":"2017-01-20T16:14:10+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/"},"wordCount":237,"commentCount":3,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","keywords":["REST API"],"articleSection":["opencart"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/","url":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/","name":"How to use cart api in Opencart - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","datePublished":"2017-01-20T16:14:10+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/use-cart-api-opencart\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/use-cart-api-opencart\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to use cart api in Opencart"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3fe787f5e9200d06d3ebf9aa86af1558","name":"Sarang Agrawal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/463bd0dd4a24de98604547719c1903e8af6b4133153ba8cc08799c7b2e3a5ce6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/463bd0dd4a24de98604547719c1903e8af6b4133153ba8cc08799c7b2e3a5ce6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Sarang Agrawal"},"sameAs":["http:\/\/webkul.com\/blog"],"url":"https:\/\/webkul.com\/blog\/author\/sarang-agrawal032\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/72211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/124"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=72211"}],"version-history":[{"count":5,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/72211\/revisions"}],"predecessor-version":[{"id":72225,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/72211\/revisions\/72225"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/41008"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=72211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=72211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=72211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}