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))
removing the conditions field makes everything work properly.
