我正在尝试将要添加的每种产品的产品类别显示在购物车和结帐页面上。
我的PHP知识非常有限,所以最愚蠢的解释将是很棒的:)
我看过woocommerce文档,并用Google搜索了创世连接文档,但没有找到我想要的东西。
使用Genesis Woocommerce Connect以及最新的woocommerce和wordpress。
不知道从这里去哪里..:/
woocommerce>模板>购物车> cart.php是购物车页面。在此,foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item )
循环显示您添加到购物车的产品。循环变量$product_id
具有添加到购物车的每个产品的ID。将此代码放入循环中
$terms = get_the_terms( $product_id, 'product_cat' );
foreach ($terms as $term) {
$product_cat = $term->name;
}
echo $product_cat ;
它将显示类别。锻炼一下,让我知道:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句