购物车商品中的商品变化属性在WooCommerce中的显示方式不同 [英] Product variations attributes as cart items shows up differently in WooCommerce

查看:41
本文介绍了购物车商品中的商品变化属性在WooCommerce中的显示方式不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到woocommerce对不同产品属性的威胁以不同的方式(请参见屏幕截图).

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?

推荐答案

它们可能有很多原因.在woocommerce 3变体属性显示为购物车项目元数据之前,例如"Seirin J + tube"…现在,在WooCommerce版本3+下创建的变量产品在标题中显示其属性值,例如"Seirin B + tube"…

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)在所有情况下的购物车商品标题中显示属性值(这是给您的):

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)删除所有情况下购物车商品标题中的属性值,并在标题下分别显示为attribute/value对.

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' );

代码会出现在您活动的子主题(或主题)的function.php文件或任何插件文件中.

经过测试,可以正常工作.

Tested and works.

这篇关于购物车商品中的商品变化属性在WooCommerce中的显示方式不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆