V
V
Vitaly Frolov2017-09-08 21:25:21
WooCommerce
Vitaly Frolov, 2017-09-08 21:25:21

Problem with woocommerce Has_cap function called with an argument deprecated as of version 2.0.0?

Guys, tell me how to redo the code. I make the display of goods in a list, I added
this code to function.php:

add_action('woocommerce_before_shop_loop', 'setTempleteCategory');

/**
 * Устанавливает режим просмотра категорий товаров
 * @global type $VIEW_TEMPLATE
 */
function setTempleteCategory() {
    global $VIEW_TEMPLATE;

    if (isset($_REQUEST['cat_templete'])) {
        if ($_REQUEST['cat_templete'] == 'list') {
            $VIEW_TEMPLATE = 'list';
            setcookie("view_template_product", "", time() - 3600);
            setcookie('view_template_product', 'list', time() + 60 * 60 * 24 * 30);
        } elseif ($_REQUEST['cat_templete'] == 'table') {
            $VIEW_TEMPLATE = 'table';
            setcookie("view_template_product", "", time() - 3600);
            setcookie('view_template_product', 'table', time() + 60 * 60 * 24 * 30);
        } else {
            $VIEW_TEMPLATE = 'table';
        }
    } else {
        if (isset($_COOKIE['view_template_product'])) {
            if ($_COOKIE['view_template_product'] == 'list') {
                $VIEW_TEMPLATE = 'list';
            } elseif ($_COOKIE['view_template_product'] == 'table') {
                $VIEW_TEMPLATE = 'table';
            }
        } else {
            $VIEW_TEMPLATE = 'table';
        }
    }
}

the code works, everything is displayed in a list, but now this error is
thrown - "Notice: The has_cap function was called with an argument that is considered obsolete from version 2.0.0! The use of user levels in plugins and themes is considered obsolete. Use roles and features.. in /home/c/ci46493/wordpress/public_html/wp-includes/functions.php on line 4023
Warning: Cannot modify header information - headers already sent by (output started at /home/c/ci46493/wordpress/public_html/wp- config.php:1) in /home/c/ci46493/wordpress/public_html/wp-includes/pluggable.php on line 1210"
How do I change the code to fix this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question