Issue facing while using Shopify function for Product Discount

Issue facing while using Shopify function for Product Discount

yedla_dinesh
Shopify Partner
11 0 1

Facing an issue with product discounts using the 'discountAutomaticAppCreate' mutation. When dealing with a large volume of JSON data within metafields, the discounts don't seem to apply.

For example: 

const discount = {
    functionId,
    combinesWith: form.combinesWith,
    startsAt: form.startDate,
    endsAt: form.endDate,
    metafields: [
        {
            namespace: metafields.config.namespace,
            key: metafields.config.key,
            type: "json",
            value: JSON.stringify({
                quantity: parseInt(form.config.quantity),
                percentage: parseFloat(form.config.percentage)
            })
        }
    ]
};


Suppose I have a large volume of data stored within a single metafield in that case the discount isn't applying. However, when I removed some data from the metafield, the discount applied perfectly. Has anyone else experienced a similar problem, or might there be something crucial that I might have overlooked in this context?


Any suggestions on how to resolve this,  @Liam @Nick_Wesselman 

Shopify Expert
Helping thousands of @Shopify store owners to achieve sustainable growth & increase revenue 2-3x 
Replies 3 (3)

SBD_
Shopify Staff
1829 271 414

Hey @yedla_dinesh 

 

Checking on this.

Scott | Developer Advocate @ Shopify 

yedla_dinesh
Shopify Partner
11 0 1

I've reviewed the Shopify documentation, and it appears that there are limitations regarding Metafields values.

Here's the link for reference: https://shopify.dev/docs/apps/functions/input-output#limitations

Has anyone else encountered a similar issue? How have you tackled this kind of problem?

yedla_dinesh_0-1700737158802.png

 

yedla_dinesh_1-1700737366261.png

 

Shopify Expert
Helping thousands of @Shopify store owners to achieve sustainable growth & increase revenue 2-3x 
SBD_
Shopify Staff
1829 271 414

Hey @yedla_dinesh 

Thanks for your patience.

 

You're spot on. Team said:


> They are likely hitting the 10KB metafield value limit, and their discount isn’t applying because the metafield value appears null in that case.

Asking for workarounds and will report back.

Scott | Developer Advocate @ Shopify