Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

get variable product price woocommerce

if ($product->is_type( 'simple' )) {
        $sale_price     =  $product->get_sale_price();
        $regular_price  =  $product->get_regular_price();
    }
    elseif($product->is_type('variable')){
        $sale_price     =  $product->get_variation_sale_price( 'min', true );
        $regular_price  =  $product->get_variation_regular_price( 'max', true );
    }


    $discount = round (($sale_price / $regular_price -1 ) * 100);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #variable #product #price #woocommerce
ADD COMMENT
Topic
Name
5+8 =