Triggering javascript after add to cart ajax call

  • Posts: 18
  • Thank you received: 2
9 years 6 months ago #173440

-- 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.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
9 years 6 months ago #173460

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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 18
  • Thank you received: 2
9 years 6 months ago #173500

So which file would that be?

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

  • Posts: 18
  • Thank you received: 2
9 years 6 months ago #173518

Nevermind, I found it in /com_hikashop/helpers/cart.php.

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

  • Posts: 7
  • Thank you received: 0
2 years 3 months ago #338002

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.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
2 years 3 months ago #338003

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:

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.

  • Posts: 7
  • Thank you received: 0
2 years 3 months ago #338013

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.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
2 years 3 months ago #338020

Hi,

It's a good idea. I've worked on that :
www.hikashop.com/support/documentation/6...ocumentation.html#js

The following user(s) said Thank You: ButterflyPixel, mabdelaziz

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

  • Posts: 7
  • Thank you received: 0
2 years 3 months ago #338029

Great!
Thank you for your fantastic work

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

Time to create page: 0.078 seconds
Powered by Kunena Forum