Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

CountryProvinceSelector is not a constructor #183

Open
meandillar opened this issue Nov 11, 2020 · 0 comments
Open

CountryProvinceSelector is not a constructor #183

meandillar opened this issue Nov 11, 2020 · 0 comments

Comments

@meandillar
Copy link

I'm receiving a CountryProvinceSelector is not a constructor error when using the @shopify/theme-addresses package as shown in the tutorial docs here: https://shopify.dev/docs/themes/theme-templates/customers-addresses-liquid

This is the same error as issue #74 (closed) but problem still exists. According to that issue CountryProvinceSelector is available in previous versions of the theme-addresses package

The error occurs when attempting to create select dropdowns for Country and Province in an address form like so:

import { CountryProvinceSelector } from '@shopify/theme-addresses'

const countryProvinceSelector = new CountryProvinceSelector(window.theme.allCountryOptionTags)
const countrySelector = document.querySelector('#address_country_new')
const provinceSelector = document.querySelector('#address_province_new')
const provinceWrapper = document.querySelector('#address_province_wrapper_new')

countryProvinceSelector.build(countrySelector, provinceSelector, {
   onCountryChange: provinces => provinceWrapper.classList.toggle(hideClass, !provinces.length)
})

Will this functionality be implemented in future versions? And if not, what is the recommended way to access a list of Provinces with Javascript?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant