I have created a discount app that uses a resource picker to only apply the discount to selected products.
The problem is that when I select more than 4 products I get an error generated from by the Shopify function.
Error parsing selectedProducts: TypeError: cannot read property 'reduce' of undefined
It works fine with any combination of variants and in the admin interface the product list saves with more than 4 products selected so the products are being stored in the metafield there’s just a problem when the discount function retrieves them when there’s more than 4.
I’ve tried to get the discount metfields from GRaphicQL but I couldn’t work it out.
here’s my input query for the discount function.
query Input {
cart {
lines {
quantity
merchandise {
__typename
...on ProductVariant {
id
}
}
}
buyerIdentity {
email
customer{
metafield(namespace: "loyalty-discount", key: "loyalty_tier") {
value
}
}
}
}
discountNode {
functionConfiguration: metafield(namespace: "$app:loyalty-discount", key: "function-configuration") {
value
}
selectedProducts: metafield(namespace: "$app:loyalty-discount", key: "selected-products") {
value
}
}
}
Thanks Dan