Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
491 B
2
Indexable
Never
add_filter('b2bking_filter_wholesale_price_final', function($price, $retail_text, $retail_price, $wholesale_text, $wholesale_price, $product_id){
	// calculate percentage
	$value = b2bking()->reverse_wc_price($retail_price) - b2bking()->reverse_wc_price($wholesale_price);
	$percent = $value / b2bking()->reverse_wc_price($retail_price) * 100;


	$price .= '<br><span style="font-weight:500;font-size:18px">You save '.wc_price($value).' ('.$percent.'%)'.'</span>';
	return $price;
}, 10, 6);