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

CountryProvinceSelector is not a constructor #183

@meandillar

Description

@meandillar

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions