Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Order Discount API with orderMinimumSubtotal condition not working as expected

Order Discount API with orderMinimumSubtotal condition not working as expected

mizzimizzi
Shopify Partner
5 0 0

Hi,

 

I'm trying to create an Order Discount Function with `orderMinimumSubtotal` condition but the result is different from the expected behavior.

I'm using this example  as a reference. Here is the code of my function that runs when the coupon code "ctest" is applied to checkout

 

// @ts-check
import { DiscountApplicationStrategy, TargetType } from "../generated/api";

/**
 * @typedef {import("../generated/api").RunInput} RunInput
 * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult
 */

/**
 * @returns {FunctionRunResult}
 */
export function run() {
  return {
    discountApplicationStrategy: DiscountApplicationStrategy.First,
    discounts: [
      {
        // without conditions field everything works good
        conditions: [
          {
            orderMinimumSubtotal: {
              minimumAmount: 50,
              targetType: TargetType.OrderSubtotal,
              excludedVariantIds: [],
            },
          },
        ],
        targets: [
          {
            orderSubtotal: {
              excludedVariantIds: [],
            },
          },
        ],
        value: {
          fixedAmount: {
            amount: 5,
          },
        },
      },
    ],
  };
}

The expected behavior is the application of a fixed discount of 5 euros if the order subtotal is greater than or equal to 50 euros. The discount should be applied regardless of any product discounts. Here is the input of the `discountCodeAppCreate` mutation used to created the discount

{
  "codeAppDiscount": {
    "code": "ctest",
    "title": "ctest",
    "functionId": "...",
    "appliesOncePerCustomer": false,
    "combinesWith": {
      "orderDiscounts": true,
      "productDiscounts": true,
      "shippingDiscounts": true
    },
    "startsAt": "2021-02-02T17:09:21Z",
    "usageLimit": null
  }
}

however the discount is not applied if there is an automatic discount on the products (PRODUCT DISCOUT API (-€50.00))

Screenshot 2024-07-15 at 22.33.37.png

removing the `conditions` field makes everything work properly.

 

Replies 4 (4)

Jonathan_Harlap
Shopify Staff
4 1 3

Thanks for reporting this issue. We expect to have a fix out for this within the next day.

mizzimizzi
Shopify Partner
5 0 0

To be clear: after almost a month the bug has still not been fixed.

Jonathan_Harlap
Shopify Staff
4 1 3

Apologies, it took much longer than anticipated. The bug fix for this shipped about a month ago now - please let me know if you continue to have issues.

zkun
Shopify Partner
1 0 0

Pls is there any progress, I'm currently having the same problem