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

#   How to Create / Duplicate an order through API?

##

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

Less More

- Posts: 12
- Thank you received: 0
-
-

11 years 9 months ago -  11 years 9 months ago [\#185564](#185564) by [cgonline](/forum/user/34948-cgonline "View cgonline's Profile")  *[How to Create / Duplicate an order through API?](/forum/31-development/874067-how-to-create-duplicate-an-order-through-api#185564 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.5 -- Browser(s) name and version -- : XXX -- Error-message(debug-mod must be tuned on) -- : Hi  Hi  Im trying to figure out a way to convert a product into a recurring payment, but cannot find out how to create/duplicate a whole order. There is plenty of examples to interact with an order, but that part is already in place.  So, How to create a new or duplicate an existing (whole) order through HS API?")* was created by *[cgonline](/forum/user/34948-cgonline "View cgonline's Profile")*

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.5
-- Browser(s) name and version -- : XXX
-- Error-message(debug-mod must be tuned on) -- : Hi

Hi

Im trying to figure out a way to convert a product into a recurring payment, but cannot find out how to create/duplicate a whole order.
There is plenty of examples to interact with an order, but that part is already in place.

So, How to create a new or duplicate an existing (whole) order through HS API?

Last edit: 11 years 9 months ago by [cgonline](/forum/user/34948-cgonline "View cgonline's Profile").

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

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

11 years 9 months ago [\#185576](#185576) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[How to Create / Duplicate an order through API?](/forum/31-development/874067-how-to-create-duplicate-an-order-through-api#185576 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.5 -- Browser(s) name and version -- : XXX -- Error-message(debug-mod must be tuned on) -- : Hi  Hi  Im trying to figure out a way to convert a product into a recurring payment, but cannot find out how to create/duplicate a whole order. There is plenty of examples to interact with an order, but that part is already in place.  So, How to create a new or duplicate an existing (whole) order through HS API?")*

Hi,

Please give us more details on when you want to create / duplicate and order, on creation of the main order, when status updated, any time ?

If its any time, for any order you can use the order class. Get the desired order thanks to: Code:

$order_id = 1; // desired value $orderClass = hikashop_get('class.hikashop'); $fullOrder = $orderClass-&gt;loadFullOrder($order_id);

Then edit the PHP object, remove the order_id, etc and save it thanks to: Code:

$orderClass-&gt;save($fullOrder);

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

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

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

Less More

- Posts: 12
- Thank you received: 0
-
-

11 years 9 months ago [\#185784](#185784) by [cgonline](/forum/user/34948-cgonline "View cgonline's Profile")  Replied by *[cgonline](/forum/user/34948-cgonline "View cgonline's Profile")* on topic *[How to Create / Duplicate an order through API?](/forum/31-development/874067-how-to-create-duplicate-an-order-through-api#185784 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.5 -- Browser(s) name and version -- : XXX -- Error-message(debug-mod must be tuned on) -- : Hi  Hi  Im trying to figure out a way to convert a product into a recurring payment, but cannot find out how to create/duplicate a whole order. There is plenty of examples to interact with an order, but that part is already in place.  So, How to create a new or duplicate an existing (whole) order through HS API?")*

Hi Xavier

It is actually not from within any hikashop process I want to duplicate an order, but from the outside (from my own plugin triggered remotely).
It looks quite easy from your example though.
Will the call to save() trigger the normal HS plugins/events or must I do that afterwards (nice to know regarding email notifications sent off when a payment automaticly occurs after a month/an interval)?

And - One final question (I hope ![:)](/media/kunena/emoticons/8.png ":)") )..
Is it possible to get a direct link to a product, with regards to the sef setting "use canonical and generate if missing"?
Im using this in my email template, but it looks like this method (or any of the other route methods) do not return any canonical links set on products? Code:

$r = hikashop_completeLink('product&amp;task=show&amp;cid='.$target['hs_id'].'&amp;name='.$target['hs_alias'].'&amp;Itemid=738');

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg3NDA2Ny1ob3ctdG8tY3JlYXRlLWR1cGxpY2F0ZS1hbi1vcmRlci10aHJvdWdoLWFwaT90bXBsPW1hcmtkb3du) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

11 years 9 months ago [\#185794](#185794) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to Create / Duplicate an order through API?](/forum/31-development/874067-how-to-create-duplicate-an-order-through-api#185794 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.5 -- Browser(s) name and version -- : XXX -- Error-message(debug-mod must be tuned on) -- : Hi  Hi  Im trying to figure out a way to convert a product into a recurring payment, but cannot find out how to create/duplicate a whole order. There is plenty of examples to interact with an order, but that part is already in place.  So, How to create a new or duplicate an existing (whole) order through HS API?")*

Hi,

Yes, the call to save will trigger the normal HikaShop plugins/events.
For a direct link which handles the canonical URLs, you want to use: Code:

$product_object = new stdClass(); $product_object-&gt;product_canonical = $target['hs_canonical']; $r = hikashop_contentLink('product&amp;task=show&amp;cid='.$target['hs_id'].'&amp;name='.$target['hs_alias'].'&amp;Itemid=738',$product_object);

The best though would be to have a $product_object coming from the database with all the product data as the object attributes, like we do in HikaShop since hikashop_contentLink expect an object, not an array.

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

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

[](#top)
