Choosing a selection results in a full page refresh.
Opens in a new window.
document.addEventListener('DOMContentLoaded', function() {
// Select the "Free Pick Up in Walpole, MA" element
const pickupText = document.querySelector('p:contains("Free Pick Up in Walpole, MA"), p._1tx8jg70');
if (!pickupText) return; // stop if the element isn't on this page
// Function to check state and hide/show pickup option
function handlePickupVisibility() {
const stateField = document.querySelector('[name="checkout[shipping_address][province]"]');
if (!stateField) return;
const state = stateField.value?.trim();
const allowedStates = [
'MA', 'Massachusetts',
'RI', 'Rhode Island',
'NH', 'New Hampshire',
'VT', 'Vermont',
'CT', 'Connecticut'
];
if (allowedStates.includes(state)) {
pickupText.style.display = 'block'; // show for NE states
} else {
pickupText.style.display = 'none'; // hide for all others
}
}
// Watch for changes in the checkout form (customer entering address)
const observer = new MutationObserver(handlePickupVisibility);
observer.observe(document.body, { childList: true, subtree: true });
// Run once on page load
handlePickupVisibility();
});