将变体属性值显示为Woocommerce购物车/结帐中的单独行 [英] Display variations attributes values as separate rows in Woocommerce cart / checkout

查看:37
本文介绍了将变体属性值显示为Woocommerce购物车/结帐中的单独行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 https://alcocovers.com/shop/上有几种变量产品,我面临的问题是:添加到购物车后,我以为我在网站上使用的购物车数据模板中存在一些问题,但我检查并没有损坏(供参考,以下是模板代码 https://pastebin.com/fswKRZ8a ).我禁用了所有自定义模板,结果是相同的.我还仔细检查了两种产品的设置方式是否完全相同,所以我很茫然,其背后的原因是什么.有谁知道这是什么原因造成的?

I have several variable products on our https://alcocovers.com/shop/ The issue I am facing is: upon adding to the cart, Dumpster Tarps has item data listed on cart page, but product Lugger Cover doesn't. Here's a screenshot: I thought there was some issue in the cart item data template I am using on the website, but I checked and nothing is broken (for reference here's the template code https://pastebin.com/fswKRZ8a). I disabled all custom templates and the results were the same. I also double checked that both products are setup in exactly the same way so I am at a loss what's the reason(s) behind this. Anyone who has an idea what would be causing this?

更新#1:一位朋友建议,也许是因为Lugger Cover页面只有一个属性,这就是为什么它不在购物车上列出商品数据的原因.但是我创建了一个测试页,并且该页也没有在购物车...

Update #1: A friend suggested maybe because Lugger Cover page has only one attribute that's why it doesn't list the item data on cart. But I created a test page and this page also doesn't have item data listed on the cart...

更新#2:我向测试页添加了第三个属性,现在项目数据将显示在购物车页面上.不知道为什么对于在产品页面上使用具有一/两个属性的产品,商品数据没有显示在购物车上.我重新检查了模板文件,没有问题.

Update #2: I added a third attribute to the test page and now the item data shows up on the cart page. No clue why for products that have one/two attributes used on the product page, the item data doesn't show up on the cart. I rechecked the template files and there's no issue.

推荐答案

尝试以下操作,该操作将在购物车商品标题下方将您的商品变体属性显示为单独的行:

Try the following, that will display your product variations attributes as separated rows, below the cart item title:

add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );
add_filter( 'woocommerce_is_attribute_in_product_name', '__return_false' );

代码进入您的活动子主题(或活动主题)的function.php文件中.我希望它能起作用.

Code goes in function.php file of your active child theme (or active theme). I hope it will work.

相关:

  • Remove attribute values from product variation title and show them on separate rows
  • Hide variation info from cart item title in WooCommerce 3+

这篇关于将变体属性值显示为Woocommerce购物车/结帐中的单独行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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