How to fetch prices from a catalog when creating B2B draft orders using APIs?

We are successfully creating B2B draft orders using Shopify API but the price is getting fetched from the product page when we pass a product variant ID.

How can we fetch prices from a given catalog instead?

For example, let’s say we have :backhand_index_pointing_down:

  • a company A,
  • a product B
  • and a catalog C.

Product B price is defined as $10 in the product page and as $8 in the catalog C assigned to the company A.

When we create a draft order containing product B for the company A using API, the $10 price is fetched.

How can we fetch the $8 price from the catalog C instead?

Hi :waving_hand:

Could you share the API request, and data you are using to create the draft order?

Hi @lizk

Please find below the API request we are using to create a B2B draft order.

{
	"query": "mutation draftOrderCreate($input: DraftOrderInput!) { draftOrderCreate(input: $input) { draftOrder { id } userErrors { message field } } }",
	 "variables": {
		"input": {
			"purchasingEntity": {
				"purchasingCompany": {
					"companyContactId": "gid://shopify/CompanyContact/XXXXXXXX",
					"companyId": "gid://shopify/Company/XXXXXXXX",
					"companyLocationId": "gid://shopify/CompanyLocation/XXXXXXXX"
				}
			},
			"note": "Test B2B draft order",
			"email": "XXXXXXXX",
			"shippingAddress": {
				"address1": "XXXXXXXX",
				"city": "XXXXXXXX",
				"province": "XXXXXXXX",
				"country": "XXXXXXXX",
				"zip": "XXXXXXXX"
			},
			"billingAddress": {
				"address1": "XXXXXXXX",
				"city": "XXXXXXXX",
				"province": "XXXXXXXX",
				"country": "XXXXXXXX",
				"zip": "XXXXXXXX"
			},
			"lineItems": [{"variantId":"gid:\/\/shopify\/ProductVariant\/XXXXXXXX","quantity":1}]
		}
	}
}

(API URL we’re using is /admin/api/2023-04/graphql.json)

Hi there :waving_hand:
Thank you for that!

I just tested this out, and I was able to get the correctly calculated prices on my end. So my thinking is there probably is a small issue with configuration.

I would suggest that you verify

  • The variant is in the the catalog
  • The catalog is active
  • Ordering is approved for the company

Hope this helps!