如果Woocommerce商店和档案馆中缺货,请删除产品按钮 [英] Remove product button if out of stock from Woocommerce shop and archives

查看:48
本文介绍了如果Woocommerce商店和档案馆中缺货,请删除产品按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用答案代码从我的产品页面中删除添加到购物车"按钮,但是现在每当有文章缺货时,我都会得到一个那里的不可用"标签弄乱了我页面的布局.

I am using Add font awesome icon to custom add to cart button in Woocommerce 3 answer code to remove the "add to cart" button from my products pages, but now whenever there is an article out of stock I get a "Not Available" label there which messes with the layout of my page.

我尝试禁用它,但是运气不好,有人知道如何隐藏标签吗?

I've tried disabling it, but with no luck, anyone knows how to hide the label?

推荐答案

使用官方woocommerce中的此摘录

Use this snippet from the official woocommerce documentation website.

if (!function_exists('woocommerce_template_loop_add_to_cart')) {
    function woocommerce_template_loop_add_to_cart() {
        global $product;
        if ( ! $product->is_in_stock() || ! $product->is_purchasable() ) return;
        wc_get_template('loop/add-to-cart.php');
    }
}

将此代码从活动主题或子主题放入您的 functions.php 文件中.

Place this code into your functions.php file from your active theme or child-theme.

这篇关于如果Woocommerce商店和档案馆中缺货,请删除产品按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆