gpay на каждом шаге чекаут

wp-content/plugins/checkout-for-woocommerce/templates/ortorex/functions.php
изменяем строки

//add_action( 'cfw_checkout_customer_info_tab2', 'cfw_payment_request_buttons', 10 );
remove_action( 'cfw_checkout_customer_info_tab', 'cfw_payment_request_buttons', 10 );
add_action( 'cfw_checkout_customer_info_tab2', 'cfw_customer_info_address', 50 );
add_action( 'cfw_checkout_customer_info_tab2', 'checkout_ab_test_cfw_customer_info_tab_nav2', 60 );
add_action( 'cfw_after_breadcrumb_navigation', 'cfw_payment_request_buttons' ); //add gpay applepay to all tabs

Exclude product from custom feed

function lw_gpf_exclude_product($excluded, $product_id, $feed_format) {
    // Return TRUE to exclude a product, FALSE to include it, $excluded to use the default behaviour.
    if (strpos($_SERVER['REQUEST_URI'], '/woocommerce_gpf/83e2cc41de7757ea/') !== false){
        if (COUNTRY_NAME == 'Australia' && $product_id != 260415 ) {
            return TRUE;
        }
    }
    // If not in the above categories use the default behaviour.
    return $excluded;
	}
	add_filter( 'woocommerce_gpf_exclude_product', 'lw_gpf_exclude_product', 11, 3);

Нет методов оплаты woocommerce

Если на странице checkout нет методов оплаты, то проблема может быть в неправильной настройке плагина Plugin Organizer, который блокирует способы оплаты на страницах типа page.

How correctly remove wpml plugin

This artickles will help with it:
wpml.org/documentation/getting-started-guide/language-setup/deleting-languages-and-plugin-data-by-doing-a-wpml-reset-on-your-site/
If you have time out after attempt to delete language, read this:
wpml.org/forums/topic/how-to-delete-language-content-from-database/
sql queries works quickly.

Временные метки wp

Если страницы сайта долго загружаются, то причина может быть в теме оформления wp.
Для анализа скорости работы темы оформления можно добавлять код, который будет логировать временные метки.
И на основе анализа этих меток можно будет оценить время выполнения php с момента вызова functions.php до момента вызова последней строки в footer.php

<?php if (function_exists('wc_get_logger') && is_user_logged_in() && str_contains($_SERVER['REQUEST_URI'], 'your uri here') ) {
           $logger = wc_get_logger();
           $context = array( 'source' => 'slow log'  );
           $err_msg = 'start  header.php '.microtime(true);
           $logger->info( $err_msg, $context );
}?> 

Файл лога будет доступен в админке в табе логов woocommerce.
В коде добавлен адрес конкретной страницы и условие авторизации пользователя, чтобы другие посетители не попадали в лог.

Обновление мини корзины после ajax добавления в корзину

Скрипт ajax_add_to_cart.js  имеет объект response(можно вывести в console.log() для понимания что приходит в ответ), который возвращается после запроса.

При успешном добавлении в нем будет html из шаблона mini-cart.php обернутый в класс widget_shopping_cart_content. Если в шаблоне такой обертки нет, то html миникарт не будет обновляться и будет хранить данные, полученные при загрузке страницы.

При этом в настройках woocommerce должна стоять галочка «Enable ajax on archive, shop pages»

Show regular price in minicart

This code for showing regular price for each product in minicart and subtotal sum. Work with simple and variable products. For bundle products — need corrections.

function display_regular_price_in_mini_cart( $item_data, $cart_item ) {
    
    $product = wc_get_product( $cart_item['product_id'] );
    $quantity = $cart_item['quantity'];
    if ( $product->is_type( 'variable' ) ) {
        $variation_id = $cart_item['variation_id'];
        $variation = wc_get_product( $variation_id );
        $regular_price = $variation->get_regular_price();
    } else {
        $regular_price = $product->get_regular_price();
    }
    
    if ( $regular_price ) {
        $item_data[] = array(
            'key'     => 'regular_price',
            'value'   => '<span class="test_quantity">'.$quantity.' × '.'</span><del>'.wc_price( $regular_price ).'</del><br/>',
            'display' => '',
        );
    }
    
    return $item_data;
}
add_filter( 'woocommerce_get_item_data', 'display_regular_price_in_mini_cart', 10, 2 );

function show_subtotal_with_regular_prices( $subtotal ) {
   
    $cart = WC()->cart->get_cart();
    $subtotal_sale = $subtotal;
    $subtotal = 0;

    foreach ( $cart as $cart_item_key => $cart_item ) {
        $product_id = $cart_item['product_id'];
        $product = wc_get_product( $cart_item['product_id'] );
        $quantity = $cart_item['quantity'];
        if ( $product->is_type( 'variable' ) ) {
        $variation_id = $cart_item['variation_id'];
        $variation = wc_get_product( $variation_id );
        $regular_price = $variation->get_regular_price();
        } else {
            $regular_price = $product->get_regular_price();
        }
            $subtotal += $regular_price * $quantity;
    }
    return  $subtotal_sale.'<del>'.wc_price($subtotal).'</del>';
}

add_filter( 'woocommerce_cart_subtotal', 'show_subtotal_with_regular_prices' );

Add your custom log to woocommerce

You may use this code to save custom information in wp loop

if (function_exists('wc_get_logger')) {
           $logger = wc_get_logger();
           $context = array( 'source' => 'Log name here'  );
           $logger->info( $err_msg, $context );
}

It will be available in woocommerce Status-> Logs tab

104: Connection reset by peer

Если при попытке открыть страницу аналитики woocommerce возникает ошибка 502 Bad Gateway, а в логе сервера при этом сообщение

104: Connection reset by peer

То одной из возможных причин может быть конфликт плагинов. Конкретно у меня была проблема с WooCommerce Google Product Feed. После его деактивации страница начинала работать как надо.

Если дело не в этом плагине, то нужно попробовать поочередно отключать их все. Также необходимо в логе смотреть ошибки по php — сама ошибка говорит о том, что nginx не смог получить корректный ответ от php-fpm

Добавить класс к карточке товара

// Фильтр для добавления класса к карточке товара
function add_custom_class_to_product_card($classes) {
    global $product;

    $product_class_settings = get_option('product_class_settings');
    $product_ids = isset($product_class_settings['product_ids']) ? $product_class_settings['product_ids'] : '';

    if ($product_ids) {
        $product_ids = explode(',', $product_ids);
        $product_ids = array_map('trim', $product_ids);

        if (in_array($product->get_id(), $product_ids)) {
            $classes[] = 'hide-regular-price'; // Можно заменить 'hide-regular-price' на имя класса, которое вы хотите добавить к карточке товара
        }
    }

    return $classes;
}
add_filter('woocommerce_post_class', 'add_custom_class_to_product_card');