Answer the question
In order to leave comments, you need to log in
How to cancel the work of a php function in one category?
Actually, here is the function of changing the price at the woocommerce rate:
add_action ('admin_menu', 'dynamic_price_button');
add_action ('woocommerce_get_price', 'change_price');
remove_action ('woocommerce_get_price', 'change_price2');
add_action( 'admin_init', 'register_mysettings' );
function register_mysettings () {
register_setting( 'baw-settings-group', 'kurs' );
register_setting( 'baw-settings-group', 'valuta' );
}
function change_price ($this) {
$int = $this;
$kurs=get_option('kurs');
if ($kurs!='') {
return $int*$kurs;}
else return $int;
}
function dynamic_price_button () {
add_submenu_page ('woocommerce', 'Курс сегодня', 'Курс сегодня', 'manage_options', 'dynamic_price', 'setting_page');
}
...
if( has_term( '1489', 'product_cat' ,$product->ID) )
function change_price ($this) {
$int = $this;
$kurs=get_option('kurs');
if ($kurs!='') {
return $int*$kurs;}
else return $int;
}
function change_price ($this) {
if( has_term( '1489', 'product_cat' ,$product->ID) ) /*категория */
$int = $this;
$kurs=get_option('kurs');
if ($kurs!='') {
return $int*$kurs;}
else return $int;
}
Answer the question
In order to leave comments, you need to log in
function change_price ($this) {
if( !has_term( '1489', 'product_cat' ,$product->ID) ) /*категория --вот тут в начале добавил !*/
$int = $this;
$kurs=get_option('kurs');
if ($kurs!='') {
return $int*$kurs;}
else return $int;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question