Shopify themes, liquid, logos, and UX
I am trying to add a button that says "Donate" to Shopify and when clicked will increase the carts total by 10% and add a product to the cart called Donation. I would like customers to be able to click this before they start shopping.
Hi landgrove,
If you understand the code please use the below script code to add the functionality in click of button.
let formData = {
'items': [{
'id': 36110175633573,
'quantity': 1
}]
};
fetch(window.Shopify.routes.root + 'cart/add.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formData)
})
.then(response => {
return response.json();
})
.catch((error) => {
console.error('Error:', error);
});
Don't forget to replace the I'd with your real donation product id.
For more detail please refer to the below URL.
https://shopify.dev/docs/api/ajax/reference/cart
Hope this will help...
Let me know if you are willing to hire someone to accomplish the same.
I do not understand code. I have sent you an email to possibly work together to solve this.
User | RANK |
---|---|
198 | |
171 | |
61 | |
52 | |
47 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023