From 3df2fa1a1c9b87eb9a7dd2dc9a6c6fbd9bcfe8f2 Mon Sep 17 00:00:00 2001 From: pgilmore-phi Date: Wed, 23 Oct 2024 09:42:54 -0400 Subject: [PATCH] Adding nullish checks on item values --- blocks/thank-you/thank-you.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/blocks/thank-you/thank-you.js b/blocks/thank-you/thank-you.js index 2600cf5..d8b5bfb 100644 --- a/blocks/thank-you/thank-you.js +++ b/blocks/thank-you/thank-you.js @@ -153,15 +153,15 @@ export default async function decorate() { productTypes.push(pet.nonInsurancePetSummary.membership.itemName); // push each item object to items array dlItems.push({ - item_name: pet.nonInsurancePetSummary.membership.itemName, + item_name: pet.nonInsurancePetSummary?.membership?.itemName ?? '', currency: currencyValue, - discount: pet.nonInsurancePetSummary.discount, + discount: pet.nonInsurancePetSummary?.discount ?? '', item_category: 'membership', // membership item_variant: '', // okay to be left empty - price: pet.nonInsurancePetSummary.amount, - quantity: pet.nonInsurancePetSummary.membership.quantity, - microchip_number: pet.microChipNumber, - product_type: pet.nonInsurancePetSummary.membership.itemName, + price: pet.nonInsurancePetSummary?.amount ?? '', + quantity: pet.nonInsurancePetSummary?.membership?.quantity ?? '1', + microchip_number: pet.microChipNumber ?? '', + product_type: pet.nonInsurancePetSummary?.membership?.itemName ?? '', }); } }); @@ -194,8 +194,8 @@ export default async function decorate() { ecommerce: { transaction_id: externalTransactionID, affiliation: '24petwatch', - value: summary.totalDueToday, - tax: summary.salesTaxes, + value: summary.totalDueToday ?? '', + tax: summary.salesTaxes ?? '', shipping: totalShipping ? totalShipping.toFixed(2) : '0.00', currency: currencyValue, payment_type: paymentMethod,