脚本宝典收集整理的这篇文章主要介绍了php – WooCommerce 2.1检测选择的送货方式,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
if ($posted['shipping_method'] == "local_pickup_plus") { }
自从更新到WooCommerce 2.1后,我的代码不再有效.
我试图回应$posted [‘shipping_method’]中存储的值,看看我是否正在检查它是否正确值,但似乎没有任何东西存储在这个变量中了.
任何帮助将不胜感激.
这似乎对我有用:
$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检测选择的送货方式全部内容,希望文章能够帮你解决php – WooCommerce 2.1检测选择的送货方式所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。