Answer the question
In order to leave comments, you need to log in
How to display woocommerce variations in price tag?
Good afternoon, is it possible to display variations in the price tag?
Answer the question
In order to leave comments, you need to log in
if ( $product->is_type('variable') ) {
foreach ( $product->get_available_variations() as $variation ) {
foreach ( wc_get_product($variation['variation_id'])->get_variation_attributes() as $attr ) {
echo wc_attribute_label( $attr );
}
$active_price = floatval($variation['display_price']);
$regular_price = floatval($variation['display_regular_price']);
if ( $active_price != $regular_price ){
$sale_price = $active_price;
}
echo '<span class="variation-prices"><strong>Price</strong>: '.$variation['price_html'].'</span><br>';
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question