apply loyalty discount logic
This commit is contained in:
@@ -109,6 +109,8 @@ export default function YouMightAlsoLike() {
|
||||
image: item.image,
|
||||
description: item.description,
|
||||
variant: "None",
|
||||
isHasLoyalty: item.isHasLoyalty,
|
||||
no_of_stamps_give: item.no_of_stamps_give,
|
||||
},
|
||||
quantity: 1,
|
||||
}),
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { message } from "antd";
|
||||
import { clearCart, selectCart } from "features/order/orderSlice";
|
||||
import {
|
||||
clearCart,
|
||||
selectCart,
|
||||
selectCartTotalWithLoyaltyDiscount,
|
||||
selectHighestPricedLoyaltyItem,
|
||||
} from "features/order/orderSlice";
|
||||
import { useCallback } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
@@ -29,6 +34,10 @@ export default function useOrder() {
|
||||
orderType,
|
||||
giftDetails,
|
||||
} = useAppSelector(selectCart);
|
||||
const highestLoyaltyItem = useAppSelector(selectHighestPricedLoyaltyItem);
|
||||
const { useLoyaltyPoints } = useAppSelector(selectCart);
|
||||
|
||||
const orderPrice = useAppSelector(selectCartTotalWithLoyaltyDiscount);
|
||||
|
||||
const [createOrder] = useCreateOrderMutation();
|
||||
|
||||
@@ -59,10 +68,8 @@ export default function useOrder() {
|
||||
pickup_comments: "",
|
||||
pickup_time: estimateTime,
|
||||
delivery_pickup_interval: "",
|
||||
orderPrice: items.reduce(
|
||||
(acc, item) => acc + item.price * item.quantity,
|
||||
0,
|
||||
),
|
||||
orderPrice: orderPrice,
|
||||
use_loylaty: useLoyaltyPoints && highestLoyaltyItem ? 1 : 0,
|
||||
useWallet: 0,
|
||||
tip,
|
||||
...(orderType === "gift"
|
||||
@@ -74,7 +81,7 @@ export default function useOrder() {
|
||||
senderEmail: giftDetails?.senderEmail,
|
||||
senderPhone: giftDetails?.senderPhone,
|
||||
senderName: giftDetails?.senderName,
|
||||
dineType: orderType
|
||||
dineType: orderType,
|
||||
}
|
||||
: {}),
|
||||
})
|
||||
@@ -120,6 +127,7 @@ export default function useOrder() {
|
||||
user_uuid,
|
||||
estimateTime,
|
||||
tip,
|
||||
orderPrice,
|
||||
t,
|
||||
navigate,
|
||||
dispatch,
|
||||
|
||||
@@ -69,6 +69,8 @@ export default function ProductFooter({
|
||||
variant: variantId,
|
||||
extras: selectedExtras,
|
||||
extrasgroup: selectedGroups,
|
||||
isHasLoyalty: product?.isHasLoyalty,
|
||||
no_of_stamps_give: product?.no_of_stamps_give,
|
||||
},
|
||||
quantity: quantity,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user