- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我一直在使用以下内容来决定结帐字段是否需要填写...
if ($posted['shipping_method'] == "local_pickup_plus") {
}
自从更新到 WooCommerce 2.1 后,我的代码不再有效。
我尝试回显存储在 $posted['shipping_method'] 中的值,看看我是否在根据正确的值检查它,但似乎此变量中不再存储任何内容。
我一直在寻找其他方法来检查所选的送货方式,但我没有取得太大进展。
如有任何帮助,我们将不胜感激。
最佳答案
找了几个小时,然后决定深入研究 WooCommerce 文件...
这似乎对我有用:
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping = $chosen_methods[0];
我通过在我的 functions.php 中像这样使用它来设置本地交付的最小总数
add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping = $chosen_methods[0];
$min_spend = 25;
$cart_total = $woocommerce->cart->cart_contents_total;
if (($cart_total < 25) AND ($chosen_shipping == 'local_delivery')) {
$surcharge = $min_spend-$cart_total;
$woocommerce->cart->add_fee( 'Delivery Surchage', $surcharge, true, 'standard' );
}
}
希望这对某人有所帮助。
关于php - WooCommerce 2.1 检测选择的运输方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22383621/
我有一个Rails应用程序,它的搜索系统取决于elasticsearch,我已经使用盆景插件将其推到heroku上,但是每当我尝试在我的应用程序上搜索内容时,都会在日志中给我这个错误。 2017-07
有什么方法可以禁用 Magento 中的购物卡/结账/送货选项吗? 我正在开发一个产品比较网站,其价格是从联属网站列出的。 我实际上并没有在我的网站上销售任何东西。 最佳答案 aDVo,如果禁用以下m
这是关于 iOS 设备蓝牙配件开发的指导请求。 公开可用的文档/讨论似乎有限;我认为这是由于 MFI NDA。 如果配件开发像一般的 iOS 开发一样易于访问,我没有找到我期望的 iOS 蓝牙配件的数
我有下一个问题: 我在名为的汽车的榻榻米中有一个水桶。 我在Elasticsearch中具有索引-名为测试 我映射了我的文档。 在 elasticsearch 配置中,我设置了: couchbase.
我遇到了 woocommerce 运输问题,这是我在购物车页面上遇到的错误。 Fatal error: Call to a member function get_label() on null in
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 9年前关闭。 Improve this que
您好,我正在使用 WooCommerce 为客户创建一个 wordpress 网站。该站点已完成,但客户希望能够从 shop_order 页面创建发货。我已经弄明白了大部分,问题是我对 UPS API
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 2 年前。 Improve this qu
用户从桶中选择 1 到 {N} 个产品 对于每个产品,供应商提供 {N} 个报价 我想给用户机会告诉他 我想要的输出: 如果您从供应商 (A) 处购买 5 件产品的总成本为 87 美元 如果您从供应商
FedEx 运输 API 是否具有 SOAP 端点?我找不到 WSDL 端点。 最佳答案 自从这里的其他 2 个答案以来,他们的网站已经更改。 最直接的答案是他们没有经典的 WSDL 端点,您只需在其
我正在将 Nodejs UPS 运输 API 与我的网站集成。我正在使用this模块。我使用了取货API。但它抛出错误 Missing or invalid AccountNumber UPS 。添加
我是一名优秀的程序员,十分优秀!