I would like to display the short description of my product rather than its name in my cart and the checkout I went to the cart.php file and I found a code I think I must change it
someone would have a solution for me ?
<td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>">
<?php
if ( ! $product_permalink ) {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(),
$cart_item, $cart_item_key ) . ' ' );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>',
esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key ) );
}
2
Answers
A better solution is to use a hook. for example:
Code goes in
functions.php
file of your active theme/child theme. Tested and works.If you want to display the short description in the cart and in the checkout you can do it using the
woocommerce_cart_item_name
hook.If you want to show the short description of all product types you can use this code:
If, in the case of product variations, you want to show the short description of the parent product (variable product) you can use the following code:
It works both on the cart page and in the checkout.
The code must be added in your theme’s functions.php file.