- Posts: 54
- Thank you received: 2
onBeforeOrderCreate plugin to add product.
- consultech
-
Topic Author
- Offline
Less
More
12 years 7 months ago #143685
by consultech
onBeforeOrderCreate plugin to add product. was created by consultech
-- HikaShop version -- : 2.2.3
-- Joomla version -- : 2.5.x
-- PHP version -- : x.x.x
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- : Error_message
Hello,
I build a plugin : the idea is to add a hidden product into the current cart when, during the checkout an option (custom field order) is checked in additonal information.
with onBeforeOrderCreate I've no problem to verify if this option is checked and in this case, add product with php code $cartClass->update(product_id,quantity), the cart contain the new added product but not the order.
why ? it's before order create no ?
Thanks !
-- Joomla version -- : 2.5.x
-- PHP version -- : x.x.x
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- : Error_message
Hello,
I build a plugin : the idea is to add a hidden product into the current cart when, during the checkout an option (custom field order) is checked in additonal information.
with onBeforeOrderCreate I've no problem to verify if this option is checked and in this case, add product with php code $cartClass->update(product_id,quantity), the cart contain the new added product but not the order.
why ? it's before order create no ?
Thanks !
Please Log in or Create an account to join the conversation.
12 years 7 months ago #143755
by nicolas
Replied by nicolas on topic onBeforeOrderCreate plugin to add product.
Hi,
The first parameter of the onBeforeOrderCreate is the content of the order which is going to be saved just after that function. At that point, the cart has already been converted into the order object of the first parameter. So changing the cart content at that point has no influence on that object as the conversion between the cart and the order object has already been done before.
So if you want to use that trigger, you'll have to add your product in $order->products and recalculate the $order->order_full_price of the order yourself.
The first parameter of the onBeforeOrderCreate is the content of the order which is going to be saved just after that function. At that point, the cart has already been converted into the order object of the first parameter. So changing the cart content at that point has no influence on that object as the conversion between the cart and the order object has already been done before.
So if you want to use that trigger, you'll have to add your product in $order->products and recalculate the $order->order_full_price of the order yourself.
Please Log in or Create an account to join the conversation.
- consultech
-
Topic Author
- Offline
Less
More
- Posts: 54
- Thank you received: 2
12 years 7 months ago #143791
by consultech
Replied by consultech on topic onBeforeOrderCreate plugin to add product.
Thank you for your clarifications.
Regards,
Regards,
Please Log in or Create an account to join the conversation.
Time to create page: 0.173 seconds