how to get woocommerce product price
$_product->get_regular_price();
$_product->get_sale_price();
$_product->get_price();
how to get woocommerce product price
$_product->get_regular_price();
$_product->get_sale_price();
$_product->get_price();
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' );
WooCommerce Add Text after Price to Specific Product or Products
add_filter( 'woocommerce_get_price_html', 'njengah_text_after_price' );
function njengah_text_after_price($price){
global $post;
$product_id = $post->ID;
$product_array = array( 1,2,3 );//add in the product IDs to add text after price
if ( in_array( $product_id, $product_array )) {
$text_to_add_after_price = ' text to add after price for the specific products '; //change text in bracket to your preferred text
return $price . $text_to_add_after_price;
}else{
return $price;
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us