Hey,
I built a Checkout extension to add a Delivery instructions textfield to the Checkout page. This field renders for all stores except for two. The two stores that the TextField does not render on are owned by the same client with the same name in their MyShopify URL. The client has two other stores that render OK. This has been tested for another client as well as two other dev stores and is OK. There is zero errors. I’ve spent days trying to figure out why this textfield won’t render for two specific stores and I’m completely stumped without some kind of error.
I am a Reaction/Remix n00b so excuse my mess. Any help would be greatly appreciated! Thank you for your time!
Checkout.jsx
import {
reactExtension,
TextField,
BlockStack,
useShop,
useCustomer,
useCartLines,
useShippingAddress,
useMetafield,
useApplyMetafieldsChange,
useAppMetafields,
} from "@shopify/ui-extensions-react/checkout";
import React from "react";
// Set the entry points for the extension
const delivery_address_before = reactExtension('purchase.checkout.delivery-address.render-before', () => <App />);
export { delivery_address_before };
const delivery_address_after = reactExtension('purchase.checkout.delivery-address.render-after', () => <App />);
export { delivery_address_after };
const shipping_option_list_before = reactExtension('purchase.checkout.shipping-option-list.render-before', () => <App />);
export { shipping_option_list_before };
const shipping_option_list_after = reactExtension('purchase.checkout.shipping-option-list.render-after', () => <App />);
export { shipping_option_list_after };
function App() {
// Get Customer ID
const customer = useCustomer();
const customer_id = customer?.id?.replace('gid://shopify/Customer/', '');
// Line-items
const line_items = useCartLines();
let delivery_line_item_exists = false;
// If items in cart are BOPIS, so far
if(delivery_line_item_exists === false) {
// Loop line-items
line_items.forEach(line_item => {
if(line_item.attributes[0]?.value === 'Ship to Home' || line_item.attributes[0]?.value === 'Same Day Delivery' || line_item.attributes[0]?.value === 'Local Delivery') {
// Set delivery_line_item_exists to true
delivery_line_item_exists = true;
}
});
}
// Define the Order metafield namespace and key
const metafield_namespace = "frd";
const metafield_key = "delivery_instructions";
// Get a reference to the Order metafield
const delivery_instructions = useMetafield({
namespace: metafield_namespace,
key: metafield_key,
});
let delivery_instructions_input_value = delivery_instructions?.value;
// Set a function to handle updating the Order metafield
const applyMetafieldsChange = useApplyMetafieldsChange();
// If at least one item in the cart is not BOPIS
if(delivery_line_item_exists === true) {
// Show Delivery Instructions
return (
<BlockStack>
<TextField
label="Delivery instructions (optional)"
multiline={3}
onChange={(value) => {
// Apply the change to the Order metafield
applyMetafieldsChange({
type: "updateMetafield",
namespace: metafield_namespace,
key: metafield_key,
valueType: "string",
value,
});
// If Customer
if(customer_id) {
// Apply the change to the Customer metafield
// function...
}
}}
value={delivery_instructions_input_value}
/>
</BlockStack>
);
}
}