From e786a76bca98abcc586d81b383c235b83d147941 Mon Sep 17 00:00:00 2001 From: jcalcaben Date: Tue, 12 Nov 2024 15:19:18 -0600 Subject: [PATCH] Clean up code --- .../amasty-order-attributes.js | 6 ++-- .../commerce-checkout/gift-options-field.js | 2 +- .../__dropins__/storefront-cart/fragments.js | 32 +++++++++++-------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/blocks/commerce-checkout/amasty-order-attributes.js b/blocks/commerce-checkout/amasty-order-attributes.js index 2d9d484e87..2575bc5803 100644 --- a/blocks/commerce-checkout/amasty-order-attributes.js +++ b/blocks/commerce-checkout/amasty-order-attributes.js @@ -64,7 +64,6 @@ class AmastyOrderAttributes extends HTMLElement { } set orderAttributes(value) { - console.log("orderAttributes", value); this._orderAttributes = value; if(!value) return; @@ -77,7 +76,7 @@ class AmastyOrderAttributes extends HTMLElement { (attribute) => attribute.attribute_code === "ddate" ); - if (deliveryDate) { + if (deliveryDate && deliveryDate.value) { deliveryDateInput.setAttribute("value", convertToDatetimeLocal(deliveryDate.value)); } } @@ -93,7 +92,7 @@ class AmastyOrderAttributes extends HTMLElement { (attribute) => attribute.attribute_code === "ddate" ); - deliveryDate && deliveryDateInput.setAttribute("value", convertToDatetimeLocal(deliveryDate.value)); + deliveryDate && deliveryDate.value && deliveryDateInput.setAttribute("value", convertToDatetimeLocal(deliveryDate.value)); deliveryDateInput.addEventListener("change", (event) => { deliveryDateInput.setAttribute('disabled', ''); @@ -108,7 +107,6 @@ class AmastyOrderAttributes extends HTMLElement { } render() { - console.log("Rendering AmastyOrderAttributes", this._orderAttributes); const sdkStyleElement = sdkStyle.cloneNode(true); const checkoutStyleElement = checkoutStyle.cloneNode(true); const style = document.createElement("style"); diff --git a/blocks/commerce-checkout/gift-options-field.js b/blocks/commerce-checkout/gift-options-field.js index bfbe71afb4..ac0fcc1acf 100644 --- a/blocks/commerce-checkout/gift-options-field.js +++ b/blocks/commerce-checkout/gift-options-field.js @@ -23,7 +23,7 @@ class GiftOptionsField extends HTMLElement { this._formTemplate = document.createElement('template'); this._formTemplate.innerHTML = ` -

Gift Options

+

Gift Message

diff --git a/scripts/__dropins__/storefront-cart/fragments.js b/scripts/__dropins__/storefront-cart/fragments.js index c4ebf68332..410b671350 100644 --- a/scripts/__dropins__/storefront-cart/fragments.js +++ b/scripts/__dropins__/storefront-cart/fragments.js @@ -1,4 +1,4 @@ -const e=` +const e = ` fragment PRICE_RANGE_FRAGMENT on PriceRange { minimum_price { regular_price { @@ -29,7 +29,7 @@ const e=` } } } -`,t=` +`, t = ` fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption { type customizable_option_uid @@ -45,7 +45,7 @@ const e=` } } } -`,a=` +`, a = ` fragment CART_ITEM_FRAGMENT on CartItemInterface { __typename uid @@ -196,8 +196,7 @@ fragment CART_ITEM_FRAGMENT on CartItemInterface { ${e} ${t} -`,r=` -fragment CART_FRAGMENT on Cart { +`, r = (`fragment CART_FRAGMENT on Cart { id total_quantity is_virtual @@ -244,11 +243,7 @@ fragment CART_FRAGMENT on Cart { applied_coupons { code } - itemsV2 ( - pageSize:$pageSize, - currentPage:$currentPage, - sort: $itemsSortInput - ) { + itemsV2(pageSize: $pageSize, currentPage: $currentPage, sort: $itemsSortInput) { items { ...CART_ITEM_FRAGMENT } @@ -262,7 +257,18 @@ fragment CART_FRAGMENT on Cart { } postcode } + gift_message { + from + to + message + } + amorder_attributes { + attribute_code + value + } } - -${a} -`;export{r as CART_FRAGMENT,a as CART_ITEM_FRAGMENT}; +${a}`); +export { +r as CART_FRAGMENT, +a as CART_ITEM_FRAGMENT +}; \ No newline at end of file