A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi
I am trying to retreive Company object custom metafield using graphql on custom apps(cart and checkout validation based) for implementing credit limit feature in the B2B store.
I updated Input to Company in the schema.graphl file Below I added all the files
I get this error when I try to deploy the app:
Command failed with exit code 1: npm exec -- graphql-code-generator --config package.json
[FAILED] GraphQL Document Validation failed with 1 errors;
[FAILED] Error 0: Cannot query field "company" on type "Input".
[FAILED] at C:/Users/xyz/shopify-functions/lucrative-consumer-app/extensions/cart-checkout-validatio
n/src/run.graphql:14:3
Kindly let me know how this can be resolved.
Thanks
Khasim
Solved! Go to the solution
This is an accepted solution.
Hi there
The company inside in the buyerIdentity -purchasingCompany-company
so you should rewrite your input to as below.
{
cart: {
buyerIdentity: {
customer{
numberOfOrders
}
purchasingCompany{
company{
metafield{
key(xxx)
namespace
}
}
}
}
cost{
}
}
This is an accepted solution.
Hi there
The company inside in the buyerIdentity -purchasingCompany-company
so you should rewrite your input to as below.
{
cart: {
buyerIdentity: {
customer{
numberOfOrders
}
purchasingCompany{
company{
metafield{
key(xxx)
namespace
}
}
}
}
cost{
}
}
FYI I ran this query to get the metafield value of Company object
Hi @Eric-HAN
Can you let me know if the validation can be done on checkout page instead of cart page(https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql) . At present I am blocking the customer on the cart page if their credit limit is less than order total, I want them to proceed to checkout but block them only if they select net payment option in the checkout. And allow them to place order if they select credit card payment option.
Thanks
Khasim
H i,there
i suggest you use Payment Customization API (https://shopify.dev/docs/api/functions/reference/payment-customization) to do this feature . when your customer credit limit is less than order total, you could limit their payment options or hide some of them . otherwise show the available options.
Hi @Eric-HAN
Is it possible to accept split payments, such as deducting from the available credit limit and charging the remaining amount from a credit card?
sorry
Can you please help on how we can target "choose payment later" option using the payment customization, in the hide function I tried to add using these "Choose payment later", "Net-7", Net-15" but still payment method shows on the checkout. I wanted to hide choose payment method later based on some order total and show only credit card option