What's your biggest current challenge? Have your say in Community Polls along the right column.

Modifying the Cart Total Without Adding Products – Is It Possible?

Modifying the Cart Total Without Adding Products – Is It Possible?

gigimurgia
Shopify Partner
2 0 0

Hi everyone,

I'm working on a solution to manage voluntary donations in my Shopify store, and I have a specific requirement:
I would like to modify the cart total without adding a physical or virtual product to the cart. The idea is to allow customers to make a donation, but without creating a specific product (like a variant or an item in the cart).

I'm wondering if there's a way to directly modify the cart total through the API or any advanced Shopify settings, without necessarily adding a product.

Has anyone encountered a similar situation or has any suggestions on how to proceed?

Thanks in advance for your help! 🙏

Reply 1 (1)

isque
Shopify Partner
7 0 1

Hi @gigimurgia 

I'm not sure it can be done without putting *something* in the cart. Is the use case that you want to allow people to enter a donation amount and don't want to have to deal with tons of variants representing different donation amounts?

 

You might be able to have just a single "Donation" product with a base amount of 0. When a donation is made, if that product is not already in the cart, then add it, otherwise update a cart attribute that contains the donation amount. Then use the cart-transform api (update) to read the cart attribute and change the price of the donation product to match.

https://shopify.dev/docs/api/functions/reference/cart-transform#example-update-operation

 

-- Adam