Solution:
In WooCommerce 2.x, the variation attributes were displayed in the cart as meta data, however in WooCommerce 3.x they are included in the product name. But this requires a change to any cart customization in a plugin or theme to use the new WC_Product
method get_name()
instead of get_title()
.
If this is a third party plugin or theme, ideally you should find out if a new version is available that is fully compatible with WooCommerce 3.x and addresses the issue. But as a workaround, assuming the plugin/theme uses the filter hook woocommerce_cart_item_name
, you can add the following to your theme’s functions.php
(if you are using a third party theme, you should create a child theme so that you don’t lose your changes on updating it):
add_filter(
'woocommerce_cart_item_name',
function($name, $cart_item, $cart_item_key) {
$product = apply_filters(
'woocommerce_cart_item_product',
$cart_item['data'],
$cart_item,
$cart_item_key
);
if (method_exists($product, 'get_name')) {
// WooCommerce 3.x
$is_link = substr($name, 0, 3) === '<a ';
$name = $product->get_name();
if ($is_link) {
$name = sprintf(
'<a href="%s">%s</a>',
esc_url($product->get_permalink($cart_item)),
$name
);
}
}
return $name;
},
50, 3
);