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

#   onBeforeCartUpdate in HIkashop 3?

##

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

Less More

- Posts: 128
- Thank you received: 2
-
-

9 years 6 months ago [\#267772](#267772) by [sabroso](/forum/user/38789-sabroso "View sabroso's Profile")  *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#267772 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")* was created by *[sabroso](/forum/user/38789-sabroso "View sabroso's Profile")*

-- HikaShop version -- : 3.0.1
-- Joomla version -- : 3.6
-- PHP version -- : 5.6

Hi there,

I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.

According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4

Is there an issue with this trigger?

I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?

Many thanks

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

9 years 6 months ago [\#267774](#267774) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#267774 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hello,

That's right, there is no more "onBeforeCartUpdate" because the Cart::update function is now a transitional function and is "deprecated" in some ways.
It is highly possible that cart can be updated via the new functions and it would mean that the trigger will not be called.

So the usage of the trigger "onBeforeCartSave" will be more appropriated if you want to control the data when the cart is saved (for any kind of modification) ; otherwise there are some triggers in order to control the quantities ( onAfterProductCheckQuantities )
It will depends on what you want to control/check exactly.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

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

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

Less More

- Posts: 128
- Thank you received: 2
-
-

9 years 6 months ago [\#267831](#267831) by [sabroso](/forum/user/38789-sabroso "View sabroso's Profile")  Replied by *[sabroso](/forum/user/38789-sabroso "View sabroso's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#267831 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Ok, my plugin is preventing the user from adding to the cart products with incompatible features ( this feature is a product custom field and I have my rules to check for this). It is working fine in HK 2.6.4

So, is onBeforeCartSave the best trigger to achieve this in HK3?

Can you please let me know what are the parameters that onBeforeCartSave receives?

Many thanks

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4OTg4NS1vbmJlZm9yZWNhcnR1cGRhdGUtaW4taGlrYXNob3AtMz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86289
- Thank you received: 14265
-
-

9 years 6 months ago [\#267833](#267833) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#267833 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hi,

Yes, totally. I've updated the developer documentation with the information regarding that trigger:
[ www.hikashop.com/support/documentation/6...umentation.html#cart](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#cart)

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

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

Less More

- Posts: 128
- Thank you received: 2
-
-

9 years 6 months ago [\#267913](#267913) by [sabroso](/forum/user/38789-sabroso "View sabroso's Profile")  Replied by *[sabroso](/forum/user/38789-sabroso "View sabroso's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#267913 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Ok thanks, I managed to re-write my plugin

The following user(s) said Thank You: [Jerome](/forum/user/80-jerome "View Jerome's Profile")

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

- **[fengel](/forum/user/37465-fengel "View fengel's Profile")**
- [![fengel's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37465.jpg)](/forum/user/37465-fengel "View fengel's Profile")
- [ Offline](/forum/user/37465-fengel)

Less More

- Posts: 27
- Thank you received: 4
-
-

9 years 1 month ago [\#277037](#277037) by [fengel](/forum/user/37465-fengel "View fengel's Profile")  Replied by *[fengel](/forum/user/37465-fengel "View fengel's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#277037 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

I noticed that inside onBeforeCartSave, you are only given the $element and $do parameters, but they do not give any extra information on whether a product was added, quantity added/subtracted, or removed.

In the onBeforeCartUpdate function, this was easy to see by the parameters $add and $product_id.

Is there any other way to know which action was taken besides having to keep track of the cart contents?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4OTg4NS1vbmJlZm9yZWNhcnR1cGRhdGUtaW4taGlrYXNob3AtMz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86289
- Thank you received: 14265
-
-

9 years 1 month ago [\#277041](#277041) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#277041 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hi,

You have the trigger onAfterProductCheckQuantities(&amp;$products, &amp;$cart, $options) which is called after the checks have been done on whether the product can be added to the cart, and before the call to the save of class.cart to store the change in the database (where onBeforeCartSave is called).
Also, note that since the add to cart is always done following an action of the user, you can also look in $_REQUEST for the different variables to know the product_id and quantity of the product being added.

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

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

9 years 4 weeks ago [\#279101](#279101) by [hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")  Replied by *[hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279101 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

I have a problem where onAfterProductCheckQuantities, onBeforeCartSave, and onAfterCartSave causes the add to cart notification to not work, and I dont see the product add to the cart until i refresh the page.

If i remove these triggers from the plugin, everything works find, but if they are there, nothing happens when I click add to cart, except when i manually refresh the page and I can see the product added. Can you help with this?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4OTg4NS1vbmJlZm9yZWNhcnR1cGRhdGUtaW4taGlrYXNob3AtMz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86289
- Thank you received: 14265
-
-

9 years 4 weeks ago [\#279160](#279160) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279160 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hi,

Well, we would need to look at the code you have in these to be able to say anything.

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

9 years 3 weeks ago -  9 years 3 weeks ago [\#279189](#279189) by [hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")  Replied by *[hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279189 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Thanks for the reply nicolas. This is what I have so far;
Code:

class plgHikashopDump_Events extends JPlugin { function __construct(&amp;$subject, $config) { parent::__construct($subject, $config); } function onProductDisplay(&amp;$element,&amp;$html) { echo '&lt;script type="text/javascript"&gt; console.log("onProductDisplay"); &lt;/script&gt;'; } function onProductFormDisplay(&amp;$element,&amp;$html) { echo '&lt;script type="text/javascript"&gt; console.log("onProductFormDisplay"); &lt;/script&gt;'; } function onProductBlocksDisplay(&amp;$element,&amp;$html) { echo '&lt;script type="text/javascript"&gt; console.log("onProductBlocksDisplay"); &lt;/script&gt;'; } function onCheckoutWorkflowLoad(&amp;$checkout_workflow, &amp;$shop_closed, $cart_id) { echo '&lt;script type="text/javascript"&gt; console.log("onCheckoutWorkflowLoad"); &lt;/script&gt;'; } function onAfterProductCheckQuantities(&amp;$products, &amp;$cart, $options) { echo '&lt;script type="text/javascript"&gt; console.log("onAfterProductCheckQuantities"); &lt;/script&gt;'; } function onBeforeCartSave(&amp;$element,&amp;$do) { echo '&lt;script type="text/javascript"&gt; console.log("onBeforeCartSave"); &lt;/script&gt;'; } function onAfterCartSave(&amp;$element) { echo '&lt;script type="text/javascript"&gt; console.log("onAfterCartSave"); &lt;/script&gt;'; } }

The others work except for onAfterProductCheckQuantities, onBeforeCartSave, and onAfterCartSave.
These cause the Add to Cart notification to not show and the shopping cart to not update until you refresh the page.

Last edit: 9 years 3 weeks ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile"). Reason: [code] tag is really really realllyyyyyyy nice !

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4OTg4NS1vbmJlZm9yZWNhcnR1cGRhdGUtaW4taGlrYXNob3AtMz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86289
- Thank you received: 14265
-
-

9 years 3 weeks ago [\#279218](#279218) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279218 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hi,

That's normal. When you click on the "add to cart" buttons with the "add to cart legacy" setting deactivated, HikaShop's javascript sends an AJAX request to the server to process the operation on the server and waits for the answer from the server in the form of a json structure with data about the results of the operation and potential error messages to display.
And when HikaShop receives that request on the server, it process it and call the plugin triggers and finally returns back the result.
If you echo HTML in these triggers you basically mess with the return result which isn't anymore a json structure as there now is HTML before the json. Hence, the javascript can't understand anymore the result of the operation and can't update the cart modules or display the notification popup.

So if you want to do some logging of data in these triggers, you should rather write your text in a file on the server, like we do with the payment methods, using the hikashop_writeToLog($data) function and the setting "payment log file" of the HikaShop configuration. In fact, you can use that function in your code and look at the log in the HikaShop configuration if you want.

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

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

9 years 3 weeks ago [\#279259](#279259) by [hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")  Replied by *[hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279259 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

That makes sense.
Can you please tell me where I can find the code that is called when the AJAX request is sent to the server.
What I ultimately want to do is run FaceBook pixel code when the user clicks on the add to cart button, I thought I could accomplish this with the Hikashop event trigger plugin.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4OTg4NS1vbmJlZm9yZWNhcnR1cGRhdGUtaW4taGlrYXNob3AtMz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86289
- Thank you received: 14265
-
-

9 years 3 weeks ago [\#279264](#279264) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279264 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hi,

In that case, your best bet is to modify the HikaShop cart notification plugin to make your own notification plugin instead of using the default one of HikaShop and add the HTML/JS you want in the popup notification of that custom plugin. So you want to look in /plugins/hikashop/cartnotify/

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

9 years 3 weeks ago [\#279469](#279469) by [hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")  Replied by *[hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279469 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

I'm not sure what you mean create my own notification plugin. Couldn't I just add the code somewhere in the notification pligin itself to run the facebook pixel code?

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

9 years 3 weeks ago [\#279471](#279471) by [hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")  Replied by *[hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279471 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

From the notification plugin, is there a way to get the product that just added?

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

9 years 3 weeks ago -  9 years 3 weeks ago [\#279470](#279470) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279470 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hello,

Modifying the HikaShop core or the core plugins is not something we can recommend since you will loose all your modifications with the next update.
So no, you'd better implement your own custom plugin to be sure that it will continue to work in the future. So basically, make a copy of it, change its name and modify it to suits your needs.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Last edit: 9 years 3 weeks ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

9 years 3 weeks ago [\#279510](#279510) by [hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")  Replied by *[hatchlinks](/forum/user/46828-hatchlinks "View hatchlinks's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279510 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Ok I see. I think I can agree with that.
Can you help me to figure out how to retrieve the item that was just added to the cart within the notification plugin?

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

9 years 3 weeks ago [\#279513](#279513) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#279513 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hello,

The notification plugin is mostly adding Javascript code in the page and all the information about the added item are sent to the Javascript function as its arguments.
If you have a more precise question ; we would be able to answer it but actually, your question is too vaste to allow us to give you a precise information.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

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

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

Less More

- Posts: 282
- Thank you received: 42
-
-

8 years 6 months ago [\#290649](#290649) by [oxido](/forum/user/29793-oxido "View oxido's Profile")  Replied by *[oxido](/forum/user/29793-oxido "View oxido's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#290649 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hi!
I don't know why, but this trigger is not working in my plugin, i don't get nothing in console log.
am I doing something wrong?
Code:

jimport('joomla.plugin.plugin'); class plgHikashopSeniorerp extends JPlugin { public function __construct(&amp;$subject, $config = array()) { // call parent constructor parent::__construct($subject, $config); } function onBeforeCartSave(&amp;$product, &amp;$do) { echo '&lt;script type="text/javascript"&gt; console.log("on Before Cart Save"); &lt;/script&gt;'; } }

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg4OTg4NS1vbmJlZm9yZWNhcnR1cGRhdGUtaW4taGlrYXNob3AtMz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86289
- Thank you received: 14265
-
-

8 years 6 months ago [\#290657](#290657) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onBeforeCartUpdate in HIkashop 3?](/forum/31-development/889885-onbeforecartupdate-in-hikashop-3#290657 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.6 -- PHP version -- : 5.6  Hi there,  I'm finally testing Hikashop version 3 and a plugin I developed for Hikashop 2.6.4 does not seem to be working in HIkashop3.  According to the documentation all the triggers should still work in V3, right? However my onBeforeCartUpdate function does not get called and it works fine on V2.6.4  Is there an issue with this trigger?  I have seen other posts where it is suggested to replace onBeforeCartUpdate by onBeforeCartSave, is that the solution? The developper documentation does not mention onBeforeCartSave and keeps referencing onBeforeCartUpdate. What parameters do you get with onBeforeCartSave?  Many thanks")*

Hi,

If you use the new add to cart system, then the add to cart is done in AJAX and the server returns a JSON with a specific set of data to the browser.
So you can't ouput HTML like that, it just won't be added to the page and it might well even break the javascript handling the add to cart.

What you can do potentially is add an exit; after the echo in your code and use the developer tools' network feature of your browser to look at what is returned by the server for the XHR (AJAX) request sent when you click on the add to cart button.
[ developers.google.com/web/tools/chrome-d...network-performance/](https://developers.google.com/web/tools/chrome-devtools/network-performance/)

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

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

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

[](#top)
