Http access in order-discount extensions

Topic summary

A developer wants to build an order-discount extension for Shopify that retrieves discount configurations from an external application via HTTP requests. They attempted to use fetch() within the run function but encountered issues.

Key limitation identified:

  • Shopify Functions cannot access the Internet or make external API calls during execution.

Recommended solution:

  • Store discount configurations as metafields on the discount node created in Shopify.
  • Query these metafields to pass configuration data as input variables to the function.

Use case context:

  • The developer is building a Shopify app to integrate their SaaS marketing platform with Shopify’s discount system.
Summarized with AI on November 15. AI used: claude-sonnet-4-5-20250929.

Hello everyone,

I want to build order-discount plugin for shopify. I need to get discount configuration from my application via http request. But i am unable to use fetch in run function.
Is there a possible way to handle it?

export function run(input: RunInput): FunctionRunResult {

  //get the configuration from the external api call

  const configuration: Configuration = JSON.parse(
    input?.discountNode?.metafield?.value ?? "{}"
  );

  

  fetch("https://api.github.com/users/hadley/orgs").then((res) => {
    //GET discount configuration from external api 
  });;

  return {
    discountApplicationStrategy: DiscountApplicationStrategy.Maximum,
    discounts: [
      {
        value: {
          percentage: {
            value: 5
          }
        },
        conditions: [
          {
            orderMinimumSubtotal: {
              minimumAmount: 1000,
              targetType: TargetType.OrderSubtotal,
              excludedVariantIds: []
            }
          }
        ],
        targets: [
          {
            orderSubtotal: {
              excludedVariantIds: []
            }
          }
        ],
        message: "5% off"
      },
      {
        value: {
          percentage: {
            value: 10
          }
        },
        targets: [
          {
            orderSubtotal: {
              excludedVariantIds: []
            }
          }
        ],
        message: "10% off"
      }
    ]
  };
};

Functions can’t access the Internet.

You need to store the discount configuration as a metafield on the discount node you create, and then query that configuration as part of the input variables to your function.

Thank Tobebuilds.

We have saas marketing suit, So we just need to build shopify app to integrate our marketing platform.

Thank you again your answer.