Reputation: 89
I am using the code below to add a product variant to the cart. However, it doesn't work if the product doesn't have any variants.
How can I add a product without variants to the cart? I tried using the Product ID, but that doesn't work.
Any assistance would be greatly appreciated.
jQuery.post('/cart/add.js', {
items: [
{
quantity: 1,
id: 39486502174869,
properties: {
'Length': metres_required
}
}]
});
Upvotes: 1
Views: 1357
Reputation: 2584
When you have no variation in the product, you can use it this way.
product.selected_or_first_available_variant.id
while using the Shopify AJAX cart API.
Upvotes: 1