Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

Issue facing while using Shopify function for Product Discount

yedla_dinesh
Shopify Partner
9 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
1788 264 384

Hey @yedla_dinesh 

 

Checking on this.

Scott | Developer Advocate @ Shopify 

yedla_dinesh
Shopify Partner
9 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
1788 264 384

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