Last active
June 20, 2019 15:12
-
-
Save blivic/0be09145a44e029bb8f107b78a78fe2e to your computer and use it in GitHub Desktop.
Display available sizes on shop page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* DO NOT copy the opening php tag | |
* check if you're using the correct attribute slug | |
*/ | |
add_action('woocommerce_after_shop_loop_item','display_size_attribute_in_shop'); | |
function display_size_attribute_in_shop() { | |
global $product; | |
if( $product->is_type('variable') ){ | |
$color_val = $product->get_attribute('pa_size'); | |
if( ! empty($color_val) ){ | |
echo "<div class='size_att'>"; | |
echo "<span>In sizes: </span>"; | |
echo $color_val; | |
echo "</div"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment