I am trying to get product attribute slug. I have used below code but it display name.
echo $_product->get_attribute( 'pa_color' );
I am working on woocommerce/cart/cart.php file in theme folder.
Also I checked this is coming in anchor url of product image in cart page but not getting it
anchor url: https://example.com/productos/sweatshirt/?attribute_pa_color=aa2757&attribute_pa_talla=m
I am working on this from today morning but I have not get success. Please guide.
3 Answers
I got this….
To get slug use:
$attributes = $_product->get_attributes();
$pa_color = $attributes["pa_color"];
Thanks to all for helping me.