[Skip to main content](#vessel-content)

#   Create order with current cart

##

- **[julio.royo](/forum/user/34079-julio-royo "View julio.royo's Profile")**
- [![julio.royo's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34079-julio-royo "View julio.royo's Profile") Topic Author
- [ Offline](/forum/user/34079-julio-royo)

Less More

- Posts: 3
- Thank you received: 0
-
-

9 years 3 months ago [\#274652](#274652) by [julio.royo](/forum/user/34079-julio-royo "View julio.royo's Profile")  *[Create order with current cart](/forum/31-development/891272-create-order-with-current-cart#274652 "Hi  I'm developing a simple plugin and I need to get the current cart and create an order. How can I add the cart product array to the new order.  function onCheckoutWorkflowLoad(&amp;$checkout&#95;workflow, &amp;$shop&#95;closed, $cart&#95;id){  //Get the cart product array $cartClass = hikashop&#95;get('class.cart'); $cart = $cartClass-&gt;loadFullCart(); $products = $cart-&gt;products;  //create the order and set default settings $order = new stdClass(); $order-&gt;order&#95;status = confirmed; $order-&gt;products= array($products); $orderClass = hikashop&#95;get('class.order'); $orderClass-&gt;save($order);  The order is created but the product list does not update. How can i do it?  Thank you!")* was created by *[julio.royo](/forum/user/34079-julio-royo "View julio.royo's Profile")*

Hi

I'm developing a simple plugin and I need to get the current cart and create an order. How can I add the cart product array to the new order.

function onCheckoutWorkflowLoad(&amp;$checkout_workflow, &amp;$shop_closed, $cart_id){

//Get the cart product array
$cartClass = hikashop_get('class.cart');
$cart = $cartClass-&gt;loadFullCart();
$products = $cart-&gt;products;

//create the order and set default settings
$order = new stdClass();
$order-&gt;order_status = confirmed;
$order-&gt;products= array($products);
$orderClass = hikashop_get('class.order');
$orderClass-&gt;save($order);

The order is created but the product list does not update. How can i do it?

Thank you!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5MTI3Mi1jcmVhdGUtb3JkZXItd2l0aC1jdXJyZW50LWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

9 years 3 months ago [\#274653](#274653) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Create order with current cart](/forum/31-development/891272-create-order-with-current-cart#274653 "Hi  I'm developing a simple plugin and I need to get the current cart and create an order. How can I add the cart product array to the new order.  function onCheckoutWorkflowLoad(&amp;$checkout&#95;workflow, &amp;$shop&#95;closed, $cart&#95;id){  //Get the cart product array $cartClass = hikashop&#95;get('class.cart'); $cart = $cartClass-&gt;loadFullCart(); $products = $cart-&gt;products;  //create the order and set default settings $order = new stdClass(); $order-&gt;order&#95;status = confirmed; $order-&gt;products= array($products); $orderClass = hikashop&#95;get('class.order'); $orderClass-&gt;save($order);  The order is created but the product list does not update. How can i do it?  Thank you!")*

Hello,

Please indicate the HikaShop version number you're using.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5MTI3Mi1jcmVhdGUtb3JkZXItd2l0aC1jdXJyZW50LWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[julio.royo](/forum/user/34079-julio-royo "View julio.royo's Profile")**
- [![julio.royo's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34079-julio-royo "View julio.royo's Profile") Topic Author
- [ Offline](/forum/user/34079-julio-royo)

Less More

- Posts: 3
- Thank you received: 0
-
-

9 years 3 months ago [\#274708](#274708) by [julio.royo](/forum/user/34079-julio-royo "View julio.royo's Profile")  Replied by *[julio.royo](/forum/user/34079-julio-royo "View julio.royo's Profile")* on topic *[Create order with current cart](/forum/31-development/891272-create-order-with-current-cart#274708 "Hi  I'm developing a simple plugin and I need to get the current cart and create an order. How can I add the cart product array to the new order.  function onCheckoutWorkflowLoad(&amp;$checkout&#95;workflow, &amp;$shop&#95;closed, $cart&#95;id){  //Get the cart product array $cartClass = hikashop&#95;get('class.cart'); $cart = $cartClass-&gt;loadFullCart(); $products = $cart-&gt;products;  //create the order and set default settings $order = new stdClass(); $order-&gt;order&#95;status = confirmed; $order-&gt;products= array($products); $orderClass = hikashop&#95;get('class.order'); $orderClass-&gt;save($order);  The order is created but the product list does not update. How can i do it?  Thank you!")*

We are using HikaShop Business: 3.1.1

Regards

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5MTI3Mi1jcmVhdGUtb3JkZXItd2l0aC1jdXJyZW50LWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

9 years 3 months ago [\#274723](#274723) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Create order with current cart](/forum/31-development/891272-create-order-with-current-cart#274723 "Hi  I'm developing a simple plugin and I need to get the current cart and create an order. How can I add the cart product array to the new order.  function onCheckoutWorkflowLoad(&amp;$checkout&#95;workflow, &amp;$shop&#95;closed, $cart&#95;id){  //Get the cart product array $cartClass = hikashop&#95;get('class.cart'); $cart = $cartClass-&gt;loadFullCart(); $products = $cart-&gt;products;  //create the order and set default settings $order = new stdClass(); $order-&gt;order&#95;status = confirmed; $order-&gt;products= array($products); $orderClass = hikashop&#95;get('class.order'); $orderClass-&gt;save($order);  The order is created but the product list does not update. How can i do it?  Thank you!")*

Hello,

By using HikaShop 3, you can use the new Cart and Order features and also the new API.
The HikaShop Order Class now have a function : createFromCart($cart_id) which allow to process a cart (from its id) and make an order. It will also call all required triggers regarding the shipping and payment methods, perform the redirection to the payment platform if required, etc.

You can use that function if you want ; but you can also use the code in that function if you want to handle all elements when you want to create an order from a cart.
Please note that if you pass the $cart_id " 0 ", the system will load the customer current cart.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5MTI3Mi1jcmVhdGUtb3JkZXItd2l0aC1jdXJyZW50LWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.164 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
