问题
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?
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...
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.
回答1:
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' );
Code goes in function.php file of your active child theme (or active theme). I hope it will work.
Related:
- Remove attribute values from product variation title and show them on separate rows
- Hide variation info from cart item title in WooCommerce 3+
来源:https://stackoverflow.com/questions/52541435/display-variations-attributes-values-as-separate-rows-in-woocommerce-cart-chec