【问题标题】:How to change "State/Province" field from text to dropdown list in checkout page in magento 2如何在magento 2的结帐页面中将“州/省”字段从文本更改为下拉列表
【发布时间】:2018-10-06 10:03:36
【问题描述】:

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

我已在商店 > 配置 > 常规的 州选项 中的 State is required 中设置了国家“澳大利亚”。 但即使清除缓存后也不会出现任何变化。我在这个问题上挣扎了好几个小时。任何修复它的帮助都会很棒。

【问题讨论】:

    标签: magento magento2


    【解决方案1】:

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

    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 中添加澳大利亚州下拉菜单。

    【讨论】:

    • 已经有一些客户在状态为文本框时注册了,如果我将状态/省更改为下拉菜单。是否已经根据文本框值更改了注册客户的状态/省值?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-07
    • 2016-09-25
    • 2021-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    相关资源
    最近更新 更多