Hi,
How can I get an “Auto Free Shipping” discount in cart Ajax API?
I can get other automatic discounts in cart Ajax API, but we can get an “Auto free shipping” discount.
https://prnt.sc/iQQfWdyVqBLD
I am not receiving the “Auto free shipping” value: https://prnt.sc/famCpcMUFtYw
API link: https://shopify.dev/docs/api/ajax/reference/cart#get-locale-cart-js
Could you please investigate this matter promptly and provide me with a solution or guidance on how to retrieve the “Auto Free Shipping” value using the cart Ajax API?
Thanks.
Hi,
Need to create a discount code with the free shipping option enabled in your Shopify store admin and use the Shopify AJAX API to apply a discount code
// Assume you have the discount code stored in a variable called discountCode
var discountCode = 'FREESHIP';
// Make an AJAX request to apply the discount code to the cart
$.ajax({
type: 'POST',
url: '/cart/update.js', // Endpoint to update the cart
data: {
note: discountCode // Pass the discount code in the note field
},
dataType: 'json',
success: function(cart) {
// Handle the success response
console.log('Discount code applied successfully:', cart);
},
error: function(XMLHttpRequest, textStatus) {
// Handle errors
console.error('Error applying discount code:', textStatus);
}
});
Hi,
Let’s suppose, the merchant has already created an “Auto free shipping” discount.
When a user adds a few products to the cart then the created “Auto free shipping” discount is going to apply automatically.
So how can I get an “Auto free shipping” discount applied to that cart?
We are getting details of the “Auto discount” in this block of cart.js’s call: https://prnt.sc/m68ALVISO8cI But not getting any details of the “Auto free shipping” discount.
Thanks.