Archived topic
Add variable size on product page
3 replies · Started by Selina on September 7, 2020
Hello, I would like to add the sizes to the shoes (the smallest and the largest) so that the smallest and largest size of each product can be displayed without having to click inside it, outside the product sheet. I don't know if I have explained myself correctly.
Some examples:
- https://www.pisamonas.es/calzado-nino/zapatito-ingles
- webnenes.com/etiqueta-productos/nino/
Thanks!
Hi there,
I'm not sure I 100% understand - can you explain a bit further maybe? Screenshots of the specific areas we should be looking at would be great.
Thanks!
Hi, I attach this screenshot: https://ibb.co/8M3rwYx.
For example, in the shoe on the left, it is available in stock from size 26 to 41: https://ibb.co/C7tDRkZ.
So what I want is that without having to go into the product, I can see the smallest and largest size in each product. On my website, for example, like this: https://ibb.co/R9zhzRk.
I hope I have explained it better now. :)
Thanks!
Hi Selina,
You can try this PHP code.
add_action( 'woocommerce_after_shop_loop_item_title', 'display_size_attribute', 5 );
function display_size_attribute() {
global $product;
if ( $product->is_type('variable') ) {
$taxonomy = 'size';
echo '<span>' . $product->get_attribute($taxonomy) . '</span>';
}
}
Just change the $taxonomy = 'size'; value to the slug of your size attribute.
ex: $taxonomy = 'avail_size';
Here's How to add PHP.
Let us know if it works for you.