Im using Woocommerce 3.3.3. and Visual Products Configurator 4.0
In My web site you can add some product to cart and proceed to checkout
- I have edited
cart/cart.php
template to show my product category name in cart (from line 75 to 79).
The code
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$terms = get_the_terms( $product_id, 'product_cat' );
foreach ($terms as $term) {
$product_cat = $term->name;
}
echo $product_cat ;
Is that placement fine ?
I have edited
checkout/review-order.php
to show my category name in checkout (from line 36 to 41):foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); $terms = get_the_terms( $product_id, 'product_cat' ); foreach ($terms as $term) { $product_cat = $term->name; } echo $product_cat ;
my category name is showed twice. How can i fix that ?
After that i can see my category name under checkout but it is displayed twice.
How can avoid this displaying repetition?
Is the placement fine?