我需要在我的woocommerce购物车页面上隐藏运费 label ,但要在结帐页面上显示 .
我已经读过,我可以使用is_cart()来专门定位购物车但它没有使用我在functions.php中编写的任何代码 .
有谁知道怎么做到这一点?
-编辑-
我发现以下代码放在functions.php中:
add_filter('woocommerce_cart_shipping_method_full_label', 'remove_shipping_label', 10, 2);
function remove_shipping_label($label, $method) {
$new_label = preg_replace('/^.+:/', '', $label);
return $new_label;
}
现在我需要将代码与“if(is_cart())”结合起来专门定位购物车页面,但我还没弄清楚如何 .
3 回答
这就是我的工作,即编辑woocommerce运输细节模板 . 老问题我知道,我的回答与这个问题没有100%的关系,但是搜索并没有帮助我解决这个问题,所以我想我会帮助任何人继续寻找......
在
$pos=strpos($wherefrom,"checkout");
行checkout
必须是结帐页面的名称(slug) . 该部分让's you choose payment methods is loaded by ajax, so all the ' is_page ', ' is_checkout ', etc, return blanks, so I resorted to useing the http_referrer. This is the result of way too many hours on one '小' problem. This code goes in the cart-shipping.php file as described in Yavour'的答案,并且必须替换现有的<ul></ul>
之间的现有代码 .购物车页面由插件文件夹中的模板加载:
要覆盖此模板,您需要在主题中复制该文件:
现在你可以用它做任何事情(甚至把它留空)它只会影响购物车页面 . 结帐页面使用不同的模板文件来生成送货字段 .
资料来源:经验template overriding