- Posts: 640
- Thank you received: 16
How to add a product to a order before an order update
- PeterChain
-
Topic Author
- Offline
Less
More
6 years 9 months ago #314083
by PeterChain
How to add a product to a order before an order update was created by PeterChain
Hi,
We need to add a product to an order using the plugin trigger "onBeforeOrderUpdate"
Is that possible?
If its possible, how we have to do it? It will have to recalculate the total price for the order?
Thanks.
--
Victor
We need to add a product to an order using the plugin trigger "onBeforeOrderUpdate"
Is that possible?
If its possible, how we have to do it? It will have to recalculate the total price for the order?
Thanks.
--
Victor
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
6 years 9 months ago #314085
by Mohamed Thelji
Replied by Mohamed Thelji on topic How to add a product to a order before an order update
Hello Victor,
Sure you can edit the $order variable and properly adapt every aspect of the order (taxes, quantities,...), can you give us more information about what you want to achieve so that we can give you more information about it ?
Kind regards,
Mohamed.
Sure you can edit the $order variable and properly adapt every aspect of the order (taxes, quantities,...), can you give us more information about what you want to achieve so that we can give you more information about it ?
Kind regards,
Mohamed.
The following user(s) said Thank You: PeterChain
Please Log in or Create an account to join the conversation.
- PeterChain
-
Topic Author
- Offline
Less
More
- Posts: 640
- Thank you received: 16
6 years 9 months ago #314096
by PeterChain
Replied by PeterChain on topic How to add a product to a order before an order update
Hi,
We need to insert a product to an order when a certain requirements are complimented (for example, when a specific payment type is selected by the customer).
We wanted to know the proper way to insert it into the $order variable and if we have to change anything more (as you said, if we have to recalculate the taxes and the full order price).
Thanks.
--
Victor
We need to insert a product to an order when a certain requirements are complimented (for example, when a specific payment type is selected by the customer).
We wanted to know the proper way to insert it into the $order variable and if we have to change anything more (as you said, if we have to recalculate the taxes and the full order price).
Thanks.
--
Victor
Please Log in or Create an account to join the conversation.
6 years 9 months ago #314114
by nicolas
Replied by nicolas on topic How to add a product to a order before an order update
Hi,
You can do it like that:
Then yes, you need to recalculate the total in $order->order_full_price (basically, you just add the amount to the value you already have in order_full_price in the database for that order).
You can do it like that:
Code:
$orderProductClass = hikashop_get('class.order_product');
$orderProduct = new stdClass();
$orderProduct->order_id = $order_id;
$orderProduct->order_product_name = 'My product';
$orderProduct->order_product_price = 10;
$orderProduct->order_product_quantity = 1;
$orderProductClass->update($orderProduct);
The following user(s) said Thank You: PeterChain
Please Log in or Create an account to join the conversation.
Time to create page: 0.158 seconds