Do all Shopify themes have this piece of code?

Solved
Highlighted
Tourist
6 1 0

Hey guys,

I noticed that a lot of Shopify themes have this piece of code: theme.Product.prototype._addItemToCart(form).

I developed and app that interacts with the addToCart method through Ajax API, but seems that it's not working on the new Debut 17.3.0 theme (it works with Debut 16.x.x). However, if we use the above method, it's working.

Do all Shopify themes have this piece of code and this method that can be called or is it better to stick to the Ajax API classic way?

0 Likes
Highlighted
Shopify Expert
9930 105 1766

This is an accepted solution.


Do all Shopify themes have this piece of code and this method that can be called or is it better to stick to the Ajax API classic way?

Not all themes will have that - especially since themes could be heavily modified or even built from scratch. The AJAX api would be the correct method vs trying to hijack an existing function that may not be present.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Tourist
6 1 0

Thank you, Jason. 

Indeed, that's the best solution.

0 Likes