T
T
tracey4adams2019-11-26 00:56:26
Taxonomy
tracey4adams, 2019-11-26 00:56:26

WooCommerce | The second price in a certain category of goods?

It is necessary that the second price is displayed only in a certain category of goods.
I use this code to display the second price:
$price_us_int = intval(preg_replace('/[^0-9]+/', '', $price), 10);
function convert_idr_to_usd_cart( $price ){
$convertion_rate = 0.67; // Here we set the currency conversion rate
$new_price = $price * $convertion_rate; // Dividing the price by the rate, to multiply, replace / with *
return number_format($new_price, 0, '.', ''); //Number of price symbols after the comma
}
add_filter( 'wc_price', 'my_custom_price_format', 10, 3 );
function my_custom_price_format( $formatted_price, $price, $args ) {
$price_usd = convert_idr_to_usd_cart($price);
$currency = 'USD'; //Currency
$currency_symbol = get_woocommerce_currency_symbol( $currency );
$price_usd = $price_usd .$currency_symbol; // adding currency symbol
$formatted_price_usd = " | Wholesale price $price_usd"; //How to display the price
return $formatted_price . $formatted_price_usd;
}
www.***/product-category/men/cat***/
How to apply it only to cat*** ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pychev Anatoly, 2019-11-26
@pton

check the current product for belonging to the desired category,
for example, through has_term

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question