如何在magento 2的结帐页面中将“州/省”字段从文本更改为下拉列表

时间:2018-10-06 10:03:37

标签: magento magento2

我正在寻找一种解决方案,可以更改“州/省”字段以在我的网站的结帐页面的“运输”部分中显示为下拉列表。商店的默认国家/地区设置为AU(澳大利亚)。尽管我在“ directory_country_region”表中添加了目标国家(AU)的州。

我已在商店>配置>常规的州选项中的州要求的国家中设置了“澳大利亚”国家/地区。 但是即使清除了缓存也没有任何变化。我在这个问题上挣扎了很多小时。修复它的任何帮助都很好。

1 个答案:

答案 0 :(得分:1)

在SQL查询下面运行以在Magento 2中添加澳大利亚州下拉列表:

INSERT INTO `directory_country_region` (`country_id`, `code`, `default_name`) VALUES ('AU', 'ACT', 'Australian Capital Territory');
INSERT INTO `directory_country_region` (`country_id`, `code`, `default_name`) VALUES ('AU', 'NSW', 'New South Wales');
INSERT INTO `directory_country_region` (`country_id`, `code`, `default_name`) VALUES ('AU', 'VIC', 'Victoria');
INSERT INTO `directory_country_region` (`country_id`, `code`, `default_name`) VALUES ('AU', 'QLD', 'Queensland');
INSERT INTO `directory_country_region` (`country_id`, `code`, `default_name`) VALUES ('AU', 'SA', 'South Australia');
INSERT INTO `directory_country_region` (`country_id`, `code`, `default_name`) VALUES ('AU', 'WA', 'Western Australia');
INSERT INTO `directory_country_region` (`country_id`, `code`, `default_name`) VALUES ('AU', 'TAS', 'Tasmania');
INSERT INTO `directory_country_region` (`country_id`, `code`, `default_name`) VALUES ('AU', 'NT', 'Northern Territory');

然后在“查询下方运行”:

INSERT INTO directory_country_region_name( locale, region_id, name )
SELECT 'en_US' AS "language", region_id, default_name
FROM `directory_country_region`
WHERE country_id = 'AU';

一旦上述SQL脚本正确运行,则在选择“澳大利亚”为国家/地区时,将显示“澳大利亚州”下拉列表。您可以在任何地方使用此SQL脚本在Magento 2中添加澳大利亚州下拉列表。