|

How to set up woocommerce product retail map discount?

How to set up woocommerce product retail map discount? Copy and paste the codes below to your functions.php

Note: to get the $retail_map, make sure you have retail_map key in each products. You can add custom fields with the name retail_map and put a value.

function woocommerce_get_custom_price($price, $product){ 
	$reg_price = get_post_meta( $product->id, '_regular_price', true );
	$retail_map = get_post_meta( $product->id, 'retail_map', true );
	$value = $retail_map * .05; 
	
	if( $retail_map != 0 ){ 
		$price = $value;
	}else{
		$price = $reg_price;
	} 
	return $price; 
}
add_filter( 'woocommerce_get_price', 'woocommerce_get_custom_price', 10, 3 );

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *