For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
Hi all,
I am using the Cart Transform API to modify pricing depending on the user selections within a product builder, think dimensions/colour etc. It is not possible to use variants as the breakpoints are quite dynamic and there are multiple variables and price points at play.
I have all of the logic for pricing worked out. And i know how to modify the price with the Cart Transform API. But for the life of me i cannot see how to get the pricing data needed for the transformation into my cart transformation function.
Here is my RunInput,
query RunInput { presentmentCurrencyRate cart { lines { id merchandise { ... on ProductVariant { id __typename product { title } } } attribute { key value } } } shop { metafield(namespace: "prices", key: "pricing") { type value } } }
I am getting the currencyRate, the cart items and attempting to get the pricing metafield which i created on the Shop metafields on a custom namespace using
mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) { metafieldsSet(metafields: $metafields) { metafields { key namespace value createdAt updatedAt } userErrors { field message code } } }
with the appropriate variables, and when calling
query { shop { id metafields(first: 10 namespace: "prices") { nodes { id namespace key value definition { access { admin customerAccount grants { access } storefront } } } } } }
I can see the metafield, happy days!
However, when i get the output after the transformation takes place, i get the following:
"cart": { "lines": [ { ... }, { ... } ] }, "shop": { "metafield": null }
I am thinking maybe it is null due to access permissions? I have tried to create a definition on the shop level metafield, but alas you cannot modify the access permissions of this owner type.
Other methods i've tried: API call from within the run.ts (not possible due to network restriction). This includes the use of async functions too. which aren't allowed.
Appreciate any input, thanks.