Custom Pricing for Line Item

mjdth
Shopify Partner
13 1 3

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 10 (10)
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
New Member
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
91 7 55

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
38 0 9

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
142 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_
New Member
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
New Member
2 0 0

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

simonhaenisch
Shopify Partner
10 1 19

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
New Member
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
213 6 43

@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
Product Inventory Information | Geolocation, Store Pickup & More

Order Related Documents | Link Documents to Products Or Countries