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

#   When creating order from cart - cart stays filled with order

##

- **[nuntius](/forum/user/29512-nuntius "View nuntius's Profile")**
- [![nuntius's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar29512.jpg)](/forum/user/29512-nuntius "View nuntius's Profile") Topic Author
- [ Offline](/forum/user/29512-nuntius)
- nuntius.nl

Less More

- Posts: 62
- Thank you received: 1
-
-
-
-

7 years 11 months ago [\#301624](#301624) by [nuntius](/forum/user/29512-nuntius "View nuntius's Profile")  *[When creating order from cart - cart stays filled with order](/forum/35-orders-management/896455-when-creating-order-from-cart-cart-stays-filled-with-order#301624 "-- HikaShop version -- : 4.0.1 -- Joomla version -- : 3.9.1 -- PHP version -- : 7.2 -- Browser(s) name and version -- : Chrome latest -- Error-message(debug-mod must be tuned on) -- : none  -- HikaShop version -- : 4.0.1 -- HikaMarket version -- : 3.0.0 -- Joomla version -- : 3.9.1 -- PHP version -- : 7.2 -- Browser(s) name and version -- : Chrome latest -- Error-message(debug-mod must be tuned on) -- : none  I've created a cronjob checking for EDI orders and creating them when one is there. The webshop has hikashop and hikamarket. See also   www.hikashop.com/forum/23-market-how-to/...kmarket-vendors.html  It all works like a charm, but there is one annoying side-effect. When creating the order from the cart in this cronjob, the order is created but the cart is not emptied so it seems.  The code is as below:  I am sure I am doing something wrong, any idea how to debug?")* was created by *[nuntius](/forum/user/29512-nuntius "View nuntius's Profile")*

-- HikaShop version -- : 4.0.1
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.2
-- Browser(s) name and version -- : Chrome latest
-- Error-message(debug-mod must be tuned on) -- : none

-- HikaShop version -- : 4.0.1
-- HikaMarket version -- : 3.0.0
-- Joomla version -- : 3.9.1
-- PHP version -- : 7.2
-- Browser(s) name and version -- : Chrome latest
-- Error-message(debug-mod must be tuned on) -- : none

I've created a cronjob checking for EDI orders and creating them when one is there. The webshop has hikashop and hikamarket.
See also [ www.hikashop.com/forum/23-market-how-to/...kmarket-vendors.html](https://www.hikashop.com/forum/23-market-how-to/894840-order-by-cronjob-including-hikmarket-vendors.html)

It all works like a charm, but there is one annoying side-effect. When creating the order from the cart in this cronjob, the order is created but the cart is not emptied so it seems.

The code is as below: Code:

$cart = new stdClass(); $cart-&gt;user_id = $user_id; $cart-&gt;cart_shipping_address_ids = $shipping_address; // Save an entry to DB to be able to get cart_id $cartClass-&gt;save($cart); $cart_id = $cartClass-&gt;getCurrentCartId('cart'); // Add all selected products at once $cartClass-&gt;addProduct($cart_id, $product_data); // Create basic order from cart $orderClass = hikashop_get('class.order'); $order = $orderClass-&gt;createFromCart($cart_id); // Retrieve current order to update for custom fields $updateOrder = new stdClass(); $updateOrder = $orderClass-&gt;get($order-&gt;order_id); // Update custom field date values (...) // some extra code for custom fields and such // Save order with custom field values $orderClass-&gt;save($updateOrder);

I am sure I am doing something wrong, any idea how to debug?

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86584
- Thank you received: 14325
-
-

7 years 11 months ago [\#301638](#301638) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[When creating order from cart - cart stays filled with order](/forum/35-orders-management/896455-when-creating-order-from-cart-cart-stays-filled-with-order#301638 "-- HikaShop version -- : 4.0.1 -- Joomla version -- : 3.9.1 -- PHP version -- : 7.2 -- Browser(s) name and version -- : Chrome latest -- Error-message(debug-mod must be tuned on) -- : none  -- HikaShop version -- : 4.0.1 -- HikaMarket version -- : 3.0.0 -- Joomla version -- : 3.9.1 -- PHP version -- : 7.2 -- Browser(s) name and version -- : Chrome latest -- Error-message(debug-mod must be tuned on) -- : none  I've created a cronjob checking for EDI orders and creating them when one is there. The webshop has hikashop and hikamarket. See also   www.hikashop.com/forum/23-market-how-to/...kmarket-vendors.html  It all works like a charm, but there is one annoying side-effect. When creating the order from the cart in this cronjob, the order is created but the cart is not emptied so it seems.  The code is as below:  I am sure I am doing something wrong, any idea how to debug?")*

Hi,

Well, you need to clear the cart after you've created the order out of it: Code:

$cartClass = hikashop_get('class.cart'); $cartClass-&gt;cleanCartFromSession();

The following user(s) said Thank You: [nuntius](/forum/user/29512-nuntius "View nuntius's Profile")

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

- **[nuntius](/forum/user/29512-nuntius "View nuntius's Profile")**
- [![nuntius's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar29512.jpg)](/forum/user/29512-nuntius "View nuntius's Profile") Topic Author
- [ Offline](/forum/user/29512-nuntius)
- nuntius.nl

Less More

- Posts: 62
- Thank you received: 1
-
-
-
-

7 years 11 months ago [\#301690](#301690) by [nuntius](/forum/user/29512-nuntius "View nuntius's Profile")  Replied by *[nuntius](/forum/user/29512-nuntius "View nuntius's Profile")* on topic *[When creating order from cart - cart stays filled with order](/forum/35-orders-management/896455-when-creating-order-from-cart-cart-stays-filled-with-order#301690 "-- HikaShop version -- : 4.0.1 -- Joomla version -- : 3.9.1 -- PHP version -- : 7.2 -- Browser(s) name and version -- : Chrome latest -- Error-message(debug-mod must be tuned on) -- : none  -- HikaShop version -- : 4.0.1 -- HikaMarket version -- : 3.0.0 -- Joomla version -- : 3.9.1 -- PHP version -- : 7.2 -- Browser(s) name and version -- : Chrome latest -- Error-message(debug-mod must be tuned on) -- : none  I've created a cronjob checking for EDI orders and creating them when one is there. The webshop has hikashop and hikamarket. See also   www.hikashop.com/forum/23-market-how-to/...kmarket-vendors.html  It all works like a charm, but there is one annoying side-effect. When creating the order from the cart in this cronjob, the order is created but the cart is not emptied so it seems.  The code is as below:  I am sure I am doing something wrong, any idea how to debug?")*

Well, that makes perfectly sense. I had the assumption it would clear itself (silly perhaps?).

Thanks for the quick reply!

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86584
- Thank you received: 14325
-
-

7 years 11 months ago [\#301692](#301692) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[When creating order from cart - cart stays filled with order](/forum/35-orders-management/896455-when-creating-order-from-cart-cart-stays-filled-with-order#301692 "-- HikaShop version -- : 4.0.1 -- Joomla version -- : 3.9.1 -- PHP version -- : 7.2 -- Browser(s) name and version -- : Chrome latest -- Error-message(debug-mod must be tuned on) -- : none  -- HikaShop version -- : 4.0.1 -- HikaMarket version -- : 3.0.0 -- Joomla version -- : 3.9.1 -- PHP version -- : 7.2 -- Browser(s) name and version -- : Chrome latest -- Error-message(debug-mod must be tuned on) -- : none  I've created a cronjob checking for EDI orders and creating them when one is there. The webshop has hikashop and hikamarket. See also   www.hikashop.com/forum/23-market-how-to/...kmarket-vendors.html  It all works like a charm, but there is one annoying side-effect. When creating the order from the cart in this cronjob, the order is created but the cart is not emptied so it seems.  The code is as below:  I am sure I am doing something wrong, any idea how to debug?")*

Hi,

We don't clear the cart right away usually. We do it when the customer comes back on the website after the payment. That way, if the user cancelled the payment on the payment gateway, we can easily redirect him back to the checkout with his cart after cancelling the order. It depends on how you configure the "clear cart when order is" setting of the HikaShop configuration.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg5NjQ1NS13aGVuLWNyZWF0aW5nLW9yZGVyLWZyb20tY2FydC1jYXJ0LXN0YXlzLWZpbGxlZC13aXRoLW9yZGVyP3RtcGw9bWFya2Rvd24=) 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.068 seconds

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