- Posts: 12
- Thank you received: 0
How to Create / Duplicate an order through API?
11 years 8 months ago - 11 years 8 months ago #185564
by cgonline
How to Create / Duplicate an order through API? was created by cgonline
-- 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?
-- 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 8 months ago by cgonline.
Please Log in or Create an account to join the conversation.
11 years 8 months ago #185576
by Xavier
Replied by Xavier on topic How to Create / Duplicate an order through 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:
Then edit the PHP object, remove the order_id, etc and save it thanks to:
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->loadFullOrder($order_id);
Then edit the PHP object, remove the order_id, etc and save it thanks to:
Code:
$orderClass->save($fullOrder);
The following user(s) said Thank You: cgonline
Please Log in or Create an account to join the conversation.
11 years 8 months ago #185784
by cgonline
Replied by cgonline on topic How to Create / Duplicate an order through 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
)..
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?
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
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&task=show&cid='.$target['hs_id'].'&name='.$target['hs_alias'].'&Itemid=738');
Please Log in or Create an account to join the conversation.
11 years 8 months ago #185794
by nicolas
Replied by nicolas on topic How to Create / Duplicate an order through 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:
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.
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->product_canonical = $target['hs_canonical'];
$r = hikashop_contentLink('product&task=show&cid='.$target['hs_id'].'&name='.$target['hs_alias'].'&Itemid=738',$product_object);
Please Log in or Create an account to join the conversation.
Time to create page: 0.251 seconds