Skip to content

Commit

Permalink
Fix offer price in shopping list
Browse files Browse the repository at this point in the history
  • Loading branch information
jrlarano committed Jul 30, 2024
1 parent 69a4562 commit bdba11d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/kits/core-ui/components/helpers/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ export const updateShoppingList = (offer, action: 'plus' | 'minus') => {
is_ticked: false
};

const allPricesAreTheSame = offer.products?.every(
(product, index, array) => product.price === array[0].price
);

const useOfferPrice =
allPricesAreTheSame && offer.price !== offer.products[0].price;

if (offer.basket?.productId) {
const product = offer.products?.find(
({id}) => id == offer.basket?.productId
Expand All @@ -335,7 +342,9 @@ export const updateShoppingList = (offer, action: 'plus' | 'minus') => {
id: product.id,
name: product.title,
pricing: {
price: product.price,
price: useOfferPrice
? offer.price || offer.pricing.price
: product?.price,
currency: offer.currency_code
},
quantity: 1,
Expand Down

0 comments on commit bdba11d

Please sign in to comment.