Custom Pricing for Line Item

mjdth
Shopify Partner
13 1 4

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

Replies 14 (14)

Patrick_Phelan
Shopify Partner
5 1 2

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.

 

GeniosWeb
Visitor
1 0 1

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

tolgapaksoy
Shopify Partner
105 7 64

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.

I_KNOW_NOTHING
Shopify Partner
45 0 11

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

PublicApps
Shopify Partner
146 5 34

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.

artem_
Visitor
1 0 0

@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"
      }
    ]
  }
}
ugifractal
Visitor
2 0 0

@artem_ I got same issue, the new price just ignored

simonhaenisch
Shopify Partner
16 1 35

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:

  • If I add a custom line item, it won't be linked to the product (which means I'd have to deal with inventory updates as well).
  • If I add a line item with a a `variantId` and `originalUnitPrice`, it'll ignore the unit price (as stated in the docs).

Is it possible to edit this after creating the draft order? I've checked the docs and nothing suggests it would be 😕

ugifractal
Visitor
2 0 0

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. 

Thomas_Lang1
Shopify Partner
234 6 55

@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 🙂

 

Software Developer | Owner of Tom IT - We build shopify apps
Marketplace Order Connector | Amazon bol.com & Walmart DSV
Order Related Documents | Print documents, Email document &Autoprint
Blog Product Spotlight | Add products to your blog articles!

casey21
Visitor
2 0 0

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?

ShopifyDevSup
Shopify Staff
1321 216 456

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

mateop
Shopify Partner
1 0 0

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 

NSEImports
Excursionist
33 0 10

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.

Doing many things all day everyday