Skip to content

Instantly share code, notes, and snippets.

@thiagotmendes
Created July 31, 2017 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagotmendes/cbe734d2832c21c4ad104c38b5814a8b to your computer and use it in GitHub Desktop.
Save thiagotmendes/cbe734d2832c21c4ad104c38b5814a8b to your computer and use it in GitHub Desktop.
// Get product attributes
$attributes = $product->get_attributes();
if ( ! $attributes ) {
echo "";
}
foreach ( $attributes as $attribute ) {
$taxonomia = $attribute['name'];
$nomeAtributo = explode('pa_',$attribute['name']);
$product_attributes = array();
$product_attributes = get_the_terms(get_the_ID(), $taxonomia);
//var_dump($product_attributes);
$attributes_dropdown = '<div class="form-group">';
echo "<strong class='total left titl'>" .ucfirst($nomeAtributo[1]) ."</strong>";
foreach ( $product_attributes as $pa ) {
$attributes_dropdown .= '
<li>
<input id="id_'. $pa->slug .'" type="radio" name="attribute_'. $taxonomia. '" value="' . $pa->slug . '">
<label for="id_'. $pa->slug .'">' . $pa->name . '</label>
</li>';
}
$attributes_dropdown .= "</div>";
echo $attributes_dropdown;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment