【问题标题】:Get shipping country during cart view - WooCommerce在购物车视图中获取发货国家 - WooCommerce
【发布时间】:2016-10-17 02:16:48
【问题描述】:

我想在购物车/结帐时(所以在下订单之前)获得所选的送货国家。 这是为了确定是否必须添加额外费用(高于正常运费)。

我怎样才能得到这个功能选择的国家? 我在 if 函数中使用它(在此示例中为国家“比利时”):

 ` elseif ($total >= $min_order and $chosen_shippingcountry = 'BE') {$fees = 10;}`

谁能帮忙?

谢谢!

问候, 塞德里克

【问题讨论】:

    标签: php wordpress woocommerce cart


    【解决方案1】:

    如果我没记错的话,您正在寻找在 WooCommerce 购物车/结帐页面上设置送货国家/地区的代码。下面的代码测试到 WooCommerce 2.4。

    方法#1:

    global $woocommerce;
    $woocommerce->customer->get_shipping_country()
    

    方法#2

    WC()->customer->get_shipping_country()
    

    请注意,WooCommerce 2.6 的发货方有 major changes。但是来自 GitHub reference,它应该可以工作。

    【讨论】:

    • 确认这两种方法仍在使用 Woocommerce 版本 3.4.5
    猜你喜欢
    • 1970-01-01
    • 2021-01-14
    • 1970-01-01
    • 2017-04-27
    • 2014-04-10
    • 1970-01-01
    • 2021-07-20
    • 2015-02-03
    相关资源
    最近更新 更多