我正在尝试让产品类别显示在购物车和结帐页面为每个添加的产品。
我的php知识非常有限,所以最愚蠢的解释将是很棒的:)
我看了一下woocommerce文档,并在谷歌上搜索了genesis connect文档,但我没有找到我想要的东西。
使用Genesis Woocommerce Connect和最新的woocommerce和wordpress。
不知道下一步该怎么走..:/
发布于 2015-01-19 17:10:32
woocommerce>templates>cart>cart.php is the cart page.In this,foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item )循环显示您添加到循环的cart.Variable $product_id中的产品具有您添加到购物车的每个产品的id。将此代码放入循环中
$terms = get_the_terms( $product_id, 'product_cat' );
foreach ($terms as $term) {
$product_cat = $term->name;
}
echo $product_cat ;它将显示类别。解决问题,并让我知道:)
发布于 2019-05-01 13:59:43
您可以简单地将其添加到购物车foreach循环中
echo wc_get_product_category_list( $cart_item['product_id'] );在WooCommerce Cart Github snipet中查看购物车循环。
https://stackoverflow.com/questions/28020610
复制相似问题