* Change option value path

* Try wcSettings.preloadSettings.general first

* Add changelog
This commit is contained in:
Moon 2021-08-30 20:31:03 -07:00 committed by GitHub
parent e6833b19eb
commit ccdd32282d
3 changed files with 15 additions and 4 deletions

View File

@ -1,3 +1,7 @@
# Unreleased
- Fix an error when getting woocommerce_default_country value. #7600
- Attempts to get the woocommerce_default_country value in wcSettings.preloadSettings.general first for the backward compatibility #7600
# 1.1.3
- Retry fix for missing build-module folder

View File

@ -22,8 +22,10 @@ export const fetchExperimentAssignment = async ( {
experiment_name: experimentName,
anon_id: anonId ?? undefined,
woo_country_code:
window.wcSettings.preloadSettings.general
.woocommerce_default_country,
window.wcSettings?.preloadSettings?.general
?.woocommerce_default_country ||
window.wcSettings?.admin?.preloadSettings?.general
?.woocommerce_default_country,
} );
const response = await window.fetch(

View File

@ -10,10 +10,15 @@ interface generalSettings {
interface preloadSettings {
general: generalSettings;
}
interface wcSettings {
interface admin {
preloadSettings: preloadSettings;
}
interface wcSettings {
admin: admin;
preloadSettings: preloadSettings;
}
declare global {
interface Window {
wcSettings: wcSettings;