- This topic has 8 replies, 2 voices, and was last updated 1 year, 1 month ago by Tom.
January 31, 2020 at 8:47 am #1150571Taylor
On my site when a variation is added to the cart the variations are shown by the slug value not the name which makes it difficult to identify which product was added to the cart. Can this value be changed from the slug to the value.
ThanksJanuary 31, 2020 at 4:47 pm #1150911TomLead DeveloperLead Developer
I did some looking around and found this: https://stackoverflow.com/questions/39045038/woocommerce-display-product-variation-description-on-cart-page
Let me know if it helps or not 🙂January 31, 2020 at 5:09 pm #1150926Taylor
Yeah that isn’t really the issue. The issue is this the product shows the title field and then below you get a variation label and slug i.e Diameter: 1-1-2. This should look like Diameter: 1-1/2. The issue is simply the cart is displaying attribute_pa field instead of the name field. So somewhere in the theme whatever field it is displaying needs to be changed to name instead of slugFebruary 1, 2020 at 9:31 am #1151436TomLead DeveloperLead Developer
WooCommerce itself handles this in their templates.
Here’s the line that outputs it: https://github.com/woocommerce/woocommerce/blob/master/templates/cart/cart-item-data.php#L24
It looks like it’s looking for this value:
If we go look for $item_data, we find this: https://github.com/woocommerce/woocommerce/blob/master/includes/wc-template-functions.php#L3578
So it looks like it’s looking for a “Display” field, if that doesn’t exist, it will output the “value” field (which is likely what’s happening for you).
Do the variation have a name/display field set?February 1, 2020 at 9:48 am #1151465Taylor
Yea I do have a name field in each one. What’s confusing is that when you look at the attributes displayed in the table in additional information it is displaying the name field their but in the cart it pulls the slug.February 1, 2020 at 4:32 pm #1151714TomLead DeveloperLead Developer
Hmm, it might be a question for WooCommerce support.
Are you using a custom template for your product page to display the data like that? If so, can you share the template using something like pastebin or a github gist?February 1, 2020 at 4:34 pm #1151719Taylor
I am actually only using the generate press theme and premium plugin.February 1, 2020 at 4:34 pm #1151720Taylor
I have submitted this to woocommerce support.February 1, 2020 at 4:47 pm #1151737
- You must be logged in to reply to this topic.