Additional charge and fixed Shipping charge on Checkout page

I’m building a custom app where I need to apply additional charges when a user marks a product as a Gift.

Here are the requirements:

  • Service Charge: A fixed $5 fee when the product is marked as a Gift.

  • Delivery Charge: A fixed $10 fee when the product is marked as a Gift.

So, both charges only apply if the product is purchased as a Gift.

I initially tried implementing this using a Discount Function along with the Shopify Function “Hide/Modify Shipping Rates”, but it’s not working as expected.

Currently, I’m unable to:

  1. Add the fixed $10 delivery charge conditionally when the product is marked as a Gift.

  2. Add the fixed $5 service charge directly to the cart.

What would be the best approach to implement this logic?

1 Like

Hey @mukesh :waving_hand: The approach I’d recommend here would be to actually model the fees as hidden, non-physical “fee” products (that are active, but not displayed on the storefront) and add/remove them programmatically when the buyer selects “Gift,” for example via Checkout UI Extensions cart changes at https://shopify.dev/docs/apps/checkout or via the Storefront API cart endpoints at https://shopify.dev/docs/api/storefront.

If you do need to ensure that he fees can’t be bypassed, you could add a Checkout Validation Function that blocks checkout if any gift-marked lines exist without the corresponding fee products: https://shopify.dev/docs/api/functions/reference/cart-checkout-validation.

If the merchant requires the $10 to appear inside the shipping line item itself, the best approach is to use a custom shipping rate provider (CarrierService) to return rates that already include the surcharge when a “gift” attribute is present: carrierService - GraphQL Admin

Third‑party calculated shipping is required for CarrierService to work, so I just wanted to mention that as well. Hope this helps, let me know if I can clarify anything further on our end here. :slight_smile:

Hey @mukesh , just wanted to follow up here to see if the above helped/if we can solve out this thread :slight_smile:

Hey @Alan_G This great idea, I tested it and it’s working. I have followup Questions but for that I’ll create new thread.

Hey @mukesh - glad to hear that worked! Let me know if I can help out further. :slight_smile: