Scaling Shopify Product Discount Functions: Limits on Creating One DiscountNode Per Variant

Topic summary

Topic: Implementing campaign-based, tiered pricing discounts for product variants using Shopify Functions (Rust), with rules stored in variant metafields (JSON) including start/end times, quantity tiers, discount type/value, and customer segments.

Current approach: Consolidate all variant rules into a single discountNode for performance. Constraint: difficulty validating time-based conditions in-function due to limited access to current date/time.

Proposed pivot: Create one discountNode per variant to simplify per-variant time checks and control. Scale example: 100 products × 50 variants = ~5,000 discountNodes.

Key asks:

  • Are there limits on the number of discountNodes (or discount functions) that can be created/applied?
  • Performance implications of thousands of nodes in a large store.
  • API rate limits, Functions API quotas, and storage constraints relevant to generating and managing these nodes.
  • Best practices for managing large-scale, time-sensitive discount configurations.

Artifacts: Example JSON structure provided to illustrate rule schema. No images/videos.

Status: Information request; no resolution yet. Seeks guidance to evaluate feasibility and design choices.

Summarized with AI on December 11. AI used: gpt-5.

Hi Shopify community,

I’m building a Shopify app that implements campaign-based tiered pricing discounts for product variants using Shopify Functions. The rules are stored in variant metafields as JSON, including time-based conditions for start/end dates, quantity thresholds, discount types (e.g., percentage), values, and customer segments.

Quick Setup Recap:

  • Metafield: Namespace test, Key rules, Owner variant, JSON type.

  • Example JSON:

    {
      "cn": "Special Offer",
      "sd": "2025-09-22T10:14:00Z",
      "ed": "",
      "r": [
        {
          "q": "4",
          "t": "p",
          "v": "20",
          "c": "all"
        },
        {
          "q": "8",
          "t": "p",
          "v": "25",
          "c": "vip"
        }
      ]
    }
    
  • Tech Stack: Shopify Functions with Rust.

  • Goal: Apply dynamic, time-sensitive tiered discounts across variants efficiently.

The Concern:

In our current approach, we’re consolidating rules into a single discountNode for all variants to optimize performance. However, due to challenges with accessing current date/time in the function (as discussed in related threads), we’re considering a pivot to creating one discountNode per variant’s rules. This would ensure more granular control and easier time validation per variant.

For a large store, this could mean significant scale: e.g., 100 products with 50 variants each = 5,000 potential discountNodes.

Question:

Is there a limit on the number of discountNodes (or discount functions) we can create and apply in Shopify? What are the performance implications, API rate limits, or best practices for handling thousands of such nodes? Any guidance on quotas for Functions API calls or storage would be super helpful to evaluate feasibility.

Thanks for your expertise—looking forward to your thoughts!