Skip to content

Commit

Permalink
updated pdp added api
Browse files Browse the repository at this point in the history
  • Loading branch information
KostiantynFandeliuk committed Feb 26, 2025
1 parent adfd81a commit 16f6c96
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions blocks/product-details/product-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export default async function decorate(block) {
const $description = fragment.querySelector(".product-details__description");
const $attributes = fragment.querySelector(".product-details__attributes");
const $giftOptions = fragment.querySelector(".product-details__gift-options");
const $giftOptions2 = fragment.querySelector(".product-details__gift-options2");
const $giftOptions2 = fragment.querySelector(
".product-details__gift-options2"
);

block.appendChild(fragment);

Expand Down Expand Up @@ -248,29 +250,39 @@ export default async function decorate(block) {
sessionStorage.getItem("updatedGiftOptions")
);

const {
recipientName,
senderName,
message,
giftWrappingId,
isGiftWrappingSelected,
} = updatedGiftOptions;

const giftOptions = {
gift_message: {
to: recipientName,
from: senderName,
if (updatedGiftOptions) {
const dropinCartData = JSON.parse(
sessionStorage.getItem("DROPIN__CART__CART__DATA")
)?.items.find((el) => el.sku === values.sku);

console.log("dropinCartData :>> ", dropinCartData);

const {
recipientName,
senderName,
message,
},
gift_wrapping_id: isGiftWrappingSelected ? giftWrappingId : null,
};
await updateProductsFromCart([
{
uid: values.uid,
quantity: values.quantity,
giftOptions,
},
]);
giftWrappingId,
isGiftWrappingSelected,
} = updatedGiftOptions;

const giftOptions = {
gift_message: {
to: recipientName,
from: senderName,
message,
},
gift_wrapping_id: isGiftWrappingSelected
? giftWrappingId
: null,
};
await updateProductsFromCart([
{
uid: values.uid,
quantity: values.quantity,
giftOptions,
},
]);
}
}

// reset any previous alerts if successful
Expand Down

0 comments on commit 16f6c96

Please sign in to comment.