如果产品有变化,请禁用Woocommerce迷你购物车中的数量 [英] If product has variation Disable the Quantity in Woocommerce mini cart

查看:121
本文介绍了如果产品有变化,请禁用Woocommerce迷你购物车中的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的主题中,如果产品有变化,则显示1x $ 18 = $ 18之类的东西,如果产品有变化,则如何删除数量。我需要
pack x $ 18 = $ 18之类的东西,但是如果产品没有任何变化,则按原样显示。是否有如果有条件可以申请变更?

In My theme there If the product has variation Is show some thing like 1x$18=$18 how to remove the Quantity if the product has variations. I need Something Like pack x $18 =$18 but If the Product has no variation it show as it is . Is there any "If condition to apply for variation"? Please help me.

 <?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); ?>

我正在尝试制作

<?php 
if( $product->is_type( 'simple' ) ){
  echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); 
} else{ 
  apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( $product_price ) . '</span>', $cart_item, $cart_item_key ); 
}
$product = new WC_Product( get_the_ID() );
?>

但不起作用

推荐答案

Al最后我解决了问题现在请在我的主题文件中对此进行检查在此处进行检查

Al Last I solve the problem Check this please now this on my theme file Check this here

<?php 
global $woocommerce, $product, $post;
    $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
    if( $_product->is_type( 'simple' ) ){
        echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); 
    }else{ 
        echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( $product_price ) . '</span>', $cart_item, $cart_item_key ); 
    } 
?>

这篇关于如果产品有变化,请禁用Woocommerce迷你购物车中的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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