Answers for "WooCommerce Add Text after Price to Specific Product or Products"

PHP
0

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; 
	}
		  
}
Posted by: Guest on June-21-2021

Code answers related to "WooCommerce Add Text after Price to Specific Product or Products"

Browse Popular Code Answers by Language