WooCommerce $_product->is_visible() 错误 - 购物车.php



通常,如果将目录可见性设置为隐藏,则产品的永久链接/链接不可用。(不是产品页面上的woocommerce插件(

现在这适用于某些产品,但有些产品仍然在购物车视图中显示链接。

我打开购物车.php var_dump这个:

$_product->is_visible()

以上:

$product_permalink = apply_filters('woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink($cart_item) : '', $cart_item, $cart_item_key);

现在还有目录可见性设置为隐藏的产品返回 true 并具有永久链接,所以我认为过滤器有问题?

有什么建议吗?

编辑 1:如果我这样做,它会按预期工作并且没有插入任何链接:

$isVisibleInCatalog = get_post_meta($product_id, '_visibility', true);
                    if ($isVisibleInCatalog != 'hidden') {
                        $product_permalink = apply_filters('woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink($cart_item) : '', $cart_item, $cart_item_key);
                    } else {
                        $product_permalink = "";
                    }

编辑 2:

WordPress 4.7.3

伍商务 2.6.14

我不确定您使用的是哪个Woocommerce版本。您需要使用

WC_Product::is_visible();

相关内容

最新更新