"/discount/CODE?redirect=" triggers a popup on checkout

Hello Everyone,

A Shopify merchant made a product discount + shipping discount on our app which runs on the Shopify Functions API. Whenever the discount is accessed via the /discount/CODE?redirect=… URL, a popup (price update ) shows up on the Checkout page (screenshot attached).

We are certain the popup is not from our app.

The Discount ID: 1746637128008

We think it’s VAT related. Please observe these two Checkout screenshots;

Notice how it’s 6.67 VAT when there’s no discount, and then it becomes 0.00 once the discount was applied via /discount/CODE and we go to the checkout and the price gets changed to 33.33 by some mechanism in Shopify.We’ve also viewed Functions error logs and found that the price is 40.00 (the original price) when the Function is invoked, so it seems the VAT stuff happens after the discount.

Please note that;

  1. this behavior doesn’t happen with built-in shopify discounts.
  2. this behavior doesn’t happen if you enter the code directly on checkout. Only when you access the discount via /discount/CODE?redirect=…

We’d appreciate any guidance we can receive.

Thank you in Advance

I wanted to follow up with more information:

We’ve found that the price change happens before our app’s Discount Function is executed. The invocation 9b65266b-b8e7-408e-b3dd-a171cb51dd5d demonstrates the item’s amountPerQuantity has already been changed to 33.33 (the original price is 40) by the time the discount calculation happens. I’ve attached the input data:

{
  "cart": {
    "buyerIdentity": null,
    "lines": [
      {
        "id": "gid://shopify/CartLine/0",
        "quantity": 1,
        "cost": {
          "amountPerQuantity": {
            "amount": "33.33"
          },
          "compareAtAmountPerQuantity": null
        },
        "merchandise": {
          "__typename": "ProductVariant",
          "id": "gid://shopify/ProductVariant/51286840148296",
          "product": {
            "id": "gid://shopify/Product/9650913116488",
            "inCollections": [],
            "hasTags": [],
            "vendor": "(Vendor name redacted)"
          }
        },
        "sellingPlanAllocation": null
      }
    ]
  },
  "discountNode": {
    "metafield": {
      "jsonValue": {
        "message": "",
        "isEnabled": true,
        "customLogic": {
          "id": "<root>",
          "type": "ROOT",
          "entryPoint": {
            "id": "entrypoint",
            "type": "CHECK_IF",
            "matchType": "AND",
            "conditions": [
              {
                "type": "PRODUCT_ELIGIBILITY",
                "includeOrExclude": "INCLUDE",
                "eligibility": {
                  "type": "SPECIFIC_PRODUCTS",
                  "selectedProducts": [],
                  "asListOfIds": "9650913116488"
                }
              }
            ],
            "then": {
              "id": "check-if730",
              "type": "CHECK_IF",
              "matchType": "AND",
              "then": {
                "id": "entrypoint-then-apply-discount",
                "type": "APPLY_DISCOUNT",
                "title": "BIRETIX Double Correction Serum Free Trial",
                "value": {
                  "type": "PERCENTAGE",
                  "percentage": "100"
                },
                "dimensions": {
                  "width": 332,
                  "height": 308
                },
                "position": {
                  "x": 943.4493210454646,
                  "y": -9.052053023566032
                }
              },
              "otherwise": null,
              "conditions": [
                {
                  "type": "PURCHASE_REQUIREMENTS",
                  "minOrMax": "MAX",
                  "requirements": {
                    "requirementType": "QUANTITY",
                    "quantity": "1",
                    "subtotal": "0",
                    "appliesTo": "ELIGIBLE_LINE_ITEMS"
                  }
                }
              ],
              "position": {
                "x": 611.4493210454646,
                "y": -9.052053023566032
              },
              "dimensions": {
                "width": 261,
                "height": 160
              },
              "tooltips": {}
            },
            "otherwise": null,
            "tooltips": {},
            "dimensions": {
              "width": 292,
              "height": 180
            },
            "position": {
              "x": 246,
              "y": 0
            }
          },
          "dimensions": {
            "width": 150,
            "height": 0
          },
          "position": {
            "x": 0,
            "y": 0
          }
        },
        "customerEligibility": {
          "type": "ALL_CUSTOMERS"
        },
        "productEligibility": {
          "type": "ALL_PRODUCTS"
        },
        "developerOptions": {
          "alwaysThrow": false
        },
        "minimumPurchaseRequirements": {
          "requirementType": "NONE",
          "quantity": "0",
          "subtotal": "0",
          "appliesTo": "ELIGIBLE_LINE_ITEMS"
        },
        "maximumPurchaseRequirements": {
          "requirementType": "NONE",
          "quantity": "0",
          "subtotal": "0",
          "appliesTo": "ELIGIBLE_LINE_ITEMS"
        },
        "value": {
          "type": "PERCENTAGE",
          "percentage": "0"
        },
        "appliesToSellingPlans": "ALL_SELLING_PLANS",
        "salePriceHandlingStrategy": "APPLY_TO_COMPARE_AT_PRICE",
        "cartLineSortOrder": "HIGHEST_PRICED_PRODUCTS"
      }
    }
  },
  "localization": {
    "country": {
      "isoCode": "GB"
    },
    "market": {
      "id": "gid://shopify/Market/78743306568"
    }
  },
  "presentmentCurrencyRate": "1.0"
}

This price change popup appears for shops using dynamic tax-inclusive pricing when the buyer is in a location that does not expect product prices to include taxes. The Discount Function will get the adjusted price in the Cart input because of the Function execution order, in which Functions that change the pricing of items in the cart run before the Discount Function.

Thank you so much! We’ll be sure to update the merchant.

Thank you @Linda-Shopify