Site logo

Archived topic

Woocommerce Variation Showing Slug Value in Cart

8 replies · Started by Taylor on January 31, 2020

Viewing posts 1–9 of 9

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.

Thanks

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 slug

Hi there,

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: $item_data['display']

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?

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.

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?

I am actually only using the generate press theme and premium plugin.

I have submitted this to woocommerce support.

Let me know what they say - it might be something simple I can help with :)

This archived topic is closed to new replies.