I am trying to get some more product data in the add-to-cart event (using ajax). So far, I can see the form works like this:
$(document).on('ajax:addToCart', function (event, data) {
console.log(event);
console.log(data);
});
I can see that there is some information in the “data” object already:
Object { sku: 8215, productIds: (1) […], form: {…}, response: [] }
form: Object { 0: form, context: form
, length: 1, … }
productIds: Array [ "15" ]
response: Array []
sku: 8215
The sku f.e. is now accessible in a script like this:
var sku = data.sku;
But I also need to know the price, the name and if possible the URL of the product I just added to the cart. How can I extend the data
Object so it contains this kind of information?