Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get product price woocommerce of specific id

$product = wc_get_product( $post_id );

$product->get_regular_price();
$product->get_sale_price();
$product->get_price();
Comment

how to get woocommerce product price

$_product->get_regular_price();
$_product->get_sale_price();
$_product->get_price();
Comment

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);
}
Comment

how to get woocommerce product price

function so_30165014_price_shortcode_callback( $atts ) {
    $atts = shortcode_atts( array(
        'id' => null,
    ), $atts, 'bartag' );

    $html = '';

    if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){
         $_product = wc_get_product( $atts['id'] );
         $html = "price = " . $_product->get_price();
    }
    return $html;
}
add_shortcode( 'woocommerce_price', 'so_30165014_price_shortcode_callback' );
Comment

PREVIOUS NEXT
Code Example
Php :: jdate get one day before php 
Php :: wp+get feature image 
Php :: create new laravel project with specific version 
Php :: encryption key has not encrypted laravel 
Php :: force https redirection laravel 
Php :: Get the number of days between two dates in PHP 
Php :: carbon parse subday 
Php :: get last inserted id in php 
Php :: laravel validation unique email 
Php :: php round all values in array 
Php :: substr() php 
Php :: redirect back in codeigniter 
Php :: convert string to decimal php 
Php :: laravel get env variable 
Php :: change laravel mix to run on different port 
Php :: Composer install : Your requirements could not be resolved to an installable set of packages 
Php :: php print top n of array 
Php :: Check duplicate email in laravel using jQuery 
Php :: php alert 
Php :: php check if string email 
Php :: get domain from url cakephp 
Php :: how to debug php 
Php :: for loop php increment by 2 
Php :: laravel singular 
Php :: js var to php 
Php :: php var dump die 
Php :: how convert big text to array that text have br in laravel 
Php :: php artisan optimize command 
Php :: insert into wp table 
Php :: Command "make:controller" is not defined. 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =