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

#   How to add a product to a order before an order update

##

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

6 years 11 months ago [\#314083](#314083) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  *[How to add a product to a order before an order update](/forum/35-orders-management/898870-how-to-add-a-product-to-a-order-before-an-order-update#314083 "Hi,  We need to add a product to an order using the plugin trigger &quot;onBeforeOrderUpdate&quot;  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")* was created by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")*

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

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

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

6 years 11 months ago [\#314085](#314085) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[How to add a product to a order before an order update](/forum/35-orders-management/898870-how-to-add-a-product-to-a-order-before-an-order-update#314085 "Hi,  We need to add a product to an order using the plugin trigger &quot;onBeforeOrderUpdate&quot;  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")*

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.

The following user(s) said Thank You: [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")

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

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

6 years 11 months ago [\#314096](#314096) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[How to add a product to a order before an order update](/forum/35-orders-management/898870-how-to-add-a-product-to-a-order-before-an-order-update#314096 "Hi,  We need to add a product to an order using the plugin trigger &quot;onBeforeOrderUpdate&quot;  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")*

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg5ODg3MC1ob3ctdG8tYWRkLWEtcHJvZHVjdC10by1hLW9yZGVyLWJlZm9yZS1hbi1vcmRlci11cGRhdGU/dG1wbD1tYXJrZG93bg==) 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: 86583
- Thank you received: 14324
-
-

6 years 11 months ago [\#314114](#314114) 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 add a product to a order before an order update](/forum/35-orders-management/898870-how-to-add-a-product-to-a-order-before-an-order-update#314114 "Hi,  We need to add a product to an order using the plugin trigger &quot;onBeforeOrderUpdate&quot;  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")*

Hi,

You can do it like that: Code:

$orderProductClass = hikashop_get('class.order_product'); $orderProduct = new stdClass(); $orderProduct-&gt;order_id = $order_id; $orderProduct-&gt;order_product_name = 'My product'; $orderProduct-&gt;order_product_price = 10; $orderProduct-&gt;order_product_quantity = 1; $orderProductClass-&gt;update($orderProduct);

Then yes, you need to recalculate the total in $order-&gt;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).

The following user(s) said Thank You: [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")

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

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