Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I've seen this question asked several times and haven't found a definitive answer. I know it will involve creating a custom app (public or private, that's fine), but what is the best way to allow for custom pricing on a product during a checkout?
For example, have a $20 shirt, want the option to add $7 embellishment to the shirt so it will check out for $27. Not using variants, since there will be too many options, and the variants are used for sizing.
It can't really be done through the REST Admin API unless I created new variants for each checkout and then delete them. Can't be done using the Shopify Ajax API since prices cannot be modified.
It MIGHT be possible with the Checkout API using custom Line Items, but then I'd have to build the entire store process instead of using the shopify checkout process, I think?
Can someone point me in the direction of "this is how you can add an item to the cart with a custom price" no matter which API/SDK I need to use to properly achieve it?
Thanks
Some non-app options:
You could add a second $7 product with the same add to cart click and some JS and an "add embellishment" checkbox.
The product could start out at $27, but use the Line Item Script to discount it most of the time. (Scripts can not increase the price. Also requires Plus account.)
There are Liquid techniques to combine products to have many variants available on the product page, beyond the usual limits on variant counts.
Too bad something that basic made so complicated, or imposible, finger down
@Patrick_Phelan wrote:Some non-app options:
You could add a second $7 product with the same add to cart click and some JS and an "add embellishment" checkbox.
The product could start out at $27, but use the Line Item Script to discount it most of the time. (Scripts can not increase the price. Also requires Plus account.)
There are Liquid techniques to combine products to have many variants available on the product page, beyond the usual limits on variant counts.
to shopify
The way I do this is as followed:
I model all my checkouts using DraftOrders in my own app. DraftOrders can be modeled to have a variant_id, but a different price.
The nice thing about DraftOrders is that Shopify provides an invoice_url field that will turn your DraftOrder into a checkout, with the special pricing attached to it.
The only problem when doing this, is that you will need to create a custom cart app that will use DraftOrder API instead of Checkout API.
Hi @tolgapaksoy,
From what i understand, when customer reached the cart page, you will run an API that use DraftOrders Endpoint, and when they click checkout, instead of redirecting them to '/checkout', you will redirect them to the invoice_url field.
Where can i find this invoice_url ?
Can you please explain what you mean when you said "you will need to create a custom cart app that will use DraftOrder API instead of Checkout API."
Thank you
Interesting solution.
Public Apps | Theme customization & App development
- Was my reply useful? Like it to let me know!
- Did I answer your question? Please mark as Accepted Solution.
- Need more help? Contact us.
@tolgapaksoy can you please share payload example?
I'm creating draft order with this payload and it ignores the price:
{
"draft_order": {
"line_items": [
{
"variant_id": 123456789,
"quantity": 1,
"price": "125.00"
}
]
}
}
I've checked all the API docs and all of them suggest that it's not possible, however I've also noticed that there are some apps out there that can do this (e. g. Amazon Integration Plus).
When creating a draft order via GraphQL API:
Is it possible to edit this after creating the draft order? I've checked the docs and nothing suggests it would be 😕
I don't know for editing after creation. But I ended up by using custom line item, and since I need to know the original product_id and variant_id for later processing. I put both of info as properties.
@mjdth wrote:I've seen this question asked several times and haven't found a definitive answer. I know it will involve creating a custom app (public or private, that's fine), but what is the best way to allow for custom pricing on a product during a checkout?
For example, have a $20 shirt, want the option to add $7 embellishment to the shirt so it will check out for $27. Not using variants, since there will be too many options, and the variants are used for sizing.
It can't really be done through the REST Admin API unless I created new variants for each checkout and then delete them. Can't be done using the Shopify Ajax API since prices cannot be modified.
It MIGHT be possible with the Checkout API using custom Line Items, but then I'd have to build the entire store process instead of using the shopify checkout process, I think?
Can someone point me in the direction of "this is how you can add an item to the cart with a custom price" no matter which API/SDK I need to use to properly achieve it?
Thanks
I might be late to the party here, but I was looking for getting this working as well, I love the draft order api for it's tax calculation (since there is no other way to get tax overrides etc..)
But one of my apps needs the ability to change the price for the line_items, since we import orders from different marketplaces.
So I have decided for now we will:
- Create draft order, to get the correct tax rates for each line_item
- Delete the draft order
- Create an order with the correct line_item prices and calculate the tax based on the retrieved draft information
best of both worlds, and for now the only viable solution 🙂
Would this process work to apply a pricing adjustment from the draft order prices to a the prices in new order we create?
Also, is this still adjusting inventory quantities?
Hey @casey21 - creating a draft order wouldn't adjust inventory quantity - this happens only when a draft order is completed, when a new order is created without it being a draft first or when a customer completes payment for an order/draft order via a web checkout.
In terms of applying a price adjustment - this should work as you'd just need to input the new prices when you make your Order Creation API call. One thing that you may want to note is that if the shop has any pricing-specific discount rules or shipping rates, it could affect the final tax calculation for the order.
Let us know if we can clarify anything on our end - hope this helps!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Can you explain how could I make that Order api call? I am creating a headless frontend using next-commerce. I thought about creating an app, adding an endpoint to the app and interacting with the admin API through the app. But I am not sure whether I can do that or if there is a better way. I want to add a order with a custom price depending on the size attributes. Variants are not custom enough and the Shopify Function for editing cart orders is on developer preview
Thanks for this, I was scratching my head over how to do this as I need to inject orders into my store with custom prices. I hate this disparity between the 'new school' GraphQL and 'old school' REST API's. Evidently all the apps are using REST to handle injecting orders to stores.
Hi I'am late, But it's ok
For the items in the cart, whatever price and title we've adjusted using JavaScript, we get that data in the array. When we click on checkout, we can create a draft order and redirect to the checkout through the invoice URL. So far, that's fine.
But if we want to show the product image, we need to send the variant ID. However, if we use the variant ID in the draft order, we can't set a custom price because it will take the variant's default price.
If we don't send the variant ID and save it as a custom item, the image won't show, and Shopify's analytics won't track the product data (like how many items were sold and which ones).
There should be a solution to this.