What is wrong in this code? I have some issue with this code.
function my_woocommerce_get_price($price, $_product) {
$kurs = 1.67;
$new_price = $price / $kurs;
$product_categories = array('laminat');
if( has_term( $product_categories, 'product_cat', $product->get_id() ) ) {
return $new_price; // новая цена
} else {
return $price;
}
}
add_filter('woocommerce_get_price', 'my_woocommerce_get_price', 100, 2);
I had this Error when I try to save code.
Uncaught Error: Call to a member function get_id() on null in wp-content/themes/mrDoor/functions.php:128
Stack trace:
#0 wp-includes/class-wp-hook.php(287): my_woocommerce_get_price('919', Object(WC_Product_Simple))
#1 wp-includes/plugin.php(255): WP_Hook->apply_filters('919', Array)
#2 wp-content/plugins/woocommerce/includes/class-wc-deprecated-filter-hooks.php(142): apply_filters_ref_array('woocommerce_get...', Array)
#3 wp-content/plugins/woocommerce/includes/class-wc-deprecated-filter-hooks.php(129): WC_Deprecated_Filter_Hooks->trigger_hook('woocommerce_get...', Array)
#4 wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-deprecated-hooks.php(75): WC_Deprecated_Filter_Hooks->handle_deprecated_hook('woocommerce_pro...', 'woocommerce_get...', Array, '919')
#5 wp-include