Last active
July 16, 2019 08:19
-
-
Save devdarren7/9bde9623c1a9dae1f72f59df3ea24d7d to your computer and use it in GitHub Desktop.
Deon add multiple ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function(){ | |
| $( ".product" ).each(function(index) { | |
| // hi ---> .product is the class name that represents the product element. | |
| var title = $(this).find('a.title-5').html(); | |
| // I have above said we are now looking inside the current product div before looking in the next one | |
| // this represents the current product div the loop is in / on. we then use jquery .find() to look for elements inside this div and then .html() grabs the content | |
| // Add to cart code here. | |
| $.post('/cart/add.js', { | |
| quantity: 1, | |
| id: 794864229, | |
| properties: { | |
| 'title': title | |
| } | |
| // i've used my variable of title to set an additional property as an example | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment