Re: 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 3 (3)

Jonathan_Harlap
Shopify Staff
3 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.

zkun
Shopify Partner
1 0 0

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