Product variations attributes as cart items shows up differently in WooCommerce

。_饼干妹妹 提交于 2019-12-20 03:57:08

问题


I noticed that woocommerce is threating different product attributes differently (see screenshot).

The attributes of the first product are added only with numbers after the dash. The attributes of the second product is listed below the product title.

I can't figure out why this happens.

How to make all product attributes look like the one of the first product?


回答1:


They can be many reasons. Before woocommerce 3 variation attributes where displayed as cart item meta data like "Seirin J + tube" … Now the variable products created under WooCommerce version 3+, display their attribute values in the title, like "Seirin B + tube"…

But hopefully there is some ways to unify this using some dedicated hooks.

1) Display attributes values in cart items title for all cases (this one is for you):

add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_true' );

2) Remove attributes values in cart items titles for all cases and display them as separated attribute / value pairs under the title.

add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and works.



来源:https://stackoverflow.com/questions/47871261/product-variations-attributes-as-cart-items-shows-up-differently-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!