• ДОБРО ПОЖАЛОВАТЬ В КЛУБ ПО WORDPRESS

    Мы активно растущий клуб по WordPress и нам нужна помощь каждого человека, в том числе и Ваша! Не стесняйтесь и станьте частью большого сообщества.
    Мы делимся новостями, отытом и полезными советами! Пройдите простую регистрацию, чтобы пользоваться всеми возможностями нашего клуба.

    Присоединяйтесь к нам, вам обязательно понравится - Присоединится

Вопрос Проблема с regular_price was called incorrectly

Dremychi

НОВИЧОК

Dremychi

НОВИЧОК
Сообщения
2
В Логах сайта масса ошибок, как мне кажется какие-то выражения в коде устарели. Может кто-то подскажет где копать. Буду очень признателен! Знаний не хватает.

id was called incorrectly Backtrace: do_action(‘wp_ajax_wcpt_load_products’), WP_Hook->do_action, WP_Hook->apply_filters, WC_Product_Table_Ajax_Handler::load_products, WC_Product_Table->get_data, WC_Product_Table->fetch_data, WC_Product_Table->add_products_to_table, array_walk, WC_Product_Table->add_product_data, Product_Table_Data_Image->get_data, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong. This message was added in version 3.0.

regular_price was called incorrectly Backtrace: do_action(‘wp_ajax_wcpt_load_products’), WP_Hook->do_action, WP_Hook->apply_filters, WC_Product_Table_Ajax_Handler::load_products, WC_Product_Table->get_data, WC_Product_Table->fetch_data, WC_Product_Table->add_products_to_table, array_walk, WC_Product_Table->add_product_data, Product_Table_Data_Price->get_data, WC_Product->get_price_html, apply_filters(‘woocommerce_get_price_html’), WP_Hook->apply_filters, my_simple_product_price_html, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong. This message was added in version 3.0.

sale_price was called incorrectly Backtrace: do_action(‘wp_ajax_wcpt_load_products’), WP_Hook->do_action, WP_Hook->apply_filters, WC_Product_Table_Ajax_Handler::load_products, WC_Product_Table->get_data, WC_Product_Table->fetch_data, WC_Product_Table->add_products_to_table, array_walk, WC_Product_Table->add_product_data, Product_Table_Data_Price->get_data, WC_Product->get_price_html, apply_filters(‘woocommerce_get_price_html’), WP_Hook->apply_filters, my_simple_product_price_html, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong. This message was added in version 3.0.

price was called incorrectly. Backtrace: do_action(‘wp_ajax_wcpt_load_products’), WP_Hook->do_action, WP_Hook->apply_filters, WC_Product_Table_Ajax_Handler::load_products, WC_Product_Table->get_data, WC_Product_Table->fetch_data, WC_Product_Table->add_products_to_table, array_walk, WC_Product_Table->add_product_data, Product_Table_Data_Price->get_data, WC_Product->get_price_html, apply_filters(‘woocommerce_get_price_html’), WP_Hook->apply_filters, my_simple_product_price_html, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong. This message was added in version 3.0.
 

Dremychi

НОВИЧОК

Dremychi

НОВИЧОК
Сообщения
2
Подозреваю что в файле finctions.php выражения которые выводят цену устарели после выхода WC3.0

Кто-то может подскажет что исправить?
if (!function_exists('my_commonPriceHtml')) {

function my_commonPriceHtml($price_amt, $regular_price, $sale_price) {
// $html_price = '<p class="price">';
//if product is in sale
if (($price_amt == $sale_price) && ($sale_price != 0)) {
$html_price .= '<p class="cash1">' . wc_price($sale_price) . '</p>';
$html_price .= '<p class="cash2">' . wc_price($regular_price) . '</p>';
}
//in sale but free
else if (($price_amt == $sale_price) && ($sale_price == 0)) {
$html_price .= '<ins>Free!</ins>';
$html_price .= '<del>' . wc_price($regular_price) . '</del>';
}
//not is sale
else if (($price_amt == $regular_price) && ($regular_price != 0)) {
$html_price .= '<ins>' . wc_price($regular_price) . '</ins>';
}
//for free product
else if (($price_amt == $regular_price) && ($regular_price == 0)) {
$html_price .= '<ins>Free!</ins>';
}
// $html_price .= '</p>';
return $html_price;
}

}

add_filter('woocommerce_get_price_html', 'my_simple_product_price_html', 100, 2);

function my_simple_product_price_html($price, $product) {
if ( 'simple' === $product->get_type() ) {
$regular_price = $product->regular_price;
$sale_price = $product->sale_price;
$price_amt = $product->price;
return my_commonPriceHtml($price_amt, $regular_price, $sale_price);
} else {
return $price;
}
}

add_filter('woocommerce_variation_sale_price_html', 'my_variable_product_price_html', 10, 2);
add_filter('woocommerce_variation_price_html', 'my_variable_product_price_html', 10, 2);

function my_variable_product_price_html($price, $variation) {
$variation_id = $variation->variation_id;
//creating the product object
$variable_product = new WC_Product($variation_id);

$regular_price = $variable_product->regular_price;
$sale_price = $variable_product->sale_price;
$price_amt = $variable_product->price;

return my_commonPriceHtml($price_amt, $regular_price, $sale_price);
}

add_filter('woocommerce_variable_sale_price_html', 'my_variable_product_minmax_price_html', 10, 2);
add_filter('woocommerce_variable_price_html', 'my_variable_product_minmax_price_html', 10, 2);

function my_variable_product_minmax_price_html($price, $product) {
$variation_min_price = $product->get_variation_price('min', true);
$variation_max_price = $product->get_variation_price('max', true);
$variation_min_regular_price = $product->get_variation_regular_price('min', true);
$variation_max_regular_price = $product->get_variation_regular_price('max', true);

if (($variation_min_price == $variation_min_regular_price) && ($variation_max_price == $variation_max_regular_price)) {
$html_min_max_price = $price;
} else {
$html_price = '<p class="price">';
$html_price .= '<ins>' . wc_price($variation_min_price) . '-' . wc_price($variation_max_price) . '</ins>';
$html_price .= '<del>' . wc_price($variation_min_regular_price) . '-' . wc_price($variation_max_regular_price) . '</del>';
$html_min_max_price = $html_price;
}

return $html_min_max_price;
}
 
Сверху