Skip to main content

Triggering javascript after add to cart ajax call

12 years 1 month ago #173440 by mj
-- url of the page with the problem -- : 69.28.90.77/~macautomation/index.php/onl...d06-detachable-chute
-- HikaShop version -- : 3.3.3
-- Joomla version -- : 3.3.3
-- PHP version -- : 5.4.29
-- Browser(s) name and version -- : chrome
-- Error-message(debug-mod must be tuned on) -- : None - I want to add some code

I'm trying to add another javascript function after the add to cart ajax function completes. I can find the function in my browser debugger, but I can't find what's writing certain parts of it into the <head> tag of my pages.

Basically, after clicking add to cart on the product detail page, I would like to trigger my cart to display.
Here's the code I'd like to add:
jQuery("html, body").animate({ scrollTop: 0 }, "slow");
jQuery("#hikashop_cart_module").show();

Could you please let me know the file /line number which I could add this?

Thank you!

Please Log in or Create an account to join the conversation.

12 years 1 month ago #173460 by Jerome
Hi,

It is currently not possible unless you modify the HikaShop core.
We planned to rewrite the "add to cart" system and add some javascript events (triggers) in order to add new features and also let you (and the other users) implement your own javascript code using the events.

But for the moment, the best is to modify the HikaShop core to add your code.

regards,

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

Please Log in or Create an account to join the conversation.

12 years 1 month ago #173500 by mj
So which file would that be?

Please Log in or Create an account to join the conversation.

12 years 1 month ago #173518 by mj
Nevermind, I found it in /com_hikashop/helpers/cart.php.

Please Log in or Create an account to join the conversation.

4 years 10 months ago #338002 by mabdelaziz
Hi,

If this feature is implemented, any reference or documentation there?
I mean " add to cart javascript events (triggers)"

Please Log in or Create an account to join the conversation.

4 years 10 months ago #338003 by nicolas
Hi,

This has been implemented yes.
We actually have plugins using that mechanism like the cart slide notification ( www.hikashop.com/marketplace/product/120-cartnotify_slide.html ) and the HikaShop cart notify plugin (pre installed with HikaShop).
That second plugin is responsible for displaying the add to cart notification box after the add to cart process is done.
It's basically done with this code:
Code:
if(window.Oby) { window.Oby.registerAjax(["cart.updated","wishlist.updated"],function(params){ ... your javascript code ... } }
You can see an example in the file plugins/hikashop/cartnotify/media/notify.js (for the HikaShop cart notify plugin)
The following user(s) said Thank You: mabdelaziz

Please Log in or Create an account to join the conversation.

4 years 10 months ago #338013 by mabdelaziz
Thank you, I liked this feature too much.

It will be very helpful to have a page on your developer documentation section.

Please Log in or Create an account to join the conversation.

4 years 10 months ago #338020 by nicolas
The following user(s) said Thank You: ButterflyPixel, mabdelaziz

Please Log in or Create an account to join the conversation.

4 years 10 months ago #338029 by mabdelaziz
Great!
Thank you for your fantastic work

Please Log in or Create an account to join the conversation.

Time to create page: 0.076 seconds
Powered by Kunena Forum