Slow down – 2 calls to WC_Payment_Gateways->get_available_payment_gateway
-
Hi,
I noticed that checkout-wc is calling the WC_Payment_Gateways->get_available_payment_gateways() twice during the Ajax call ‘update_order_review’. This is slowing down the server as sometimes the gateways do some Ajax calls themselves on this filter and it takes time to complete. So when we call this twice it is twice slower. Please refactor this somehow such that this is only called once. I think this also called during checkout page generation.
Here is the logs I checked this:
[23-Aug-2024 10:49:30 UTC] Checking payment gateways
[23-Aug-2024 10:49:30 UTC] #0 /var/www/html/wp-includes/class-wp-hook.php(324): debug_payment_gateways()
#1 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#2 /var/www/html/wp-content/addons/woocommerce/includes/class-wc-payment-gateways.php(333): apply_filters()
#3 /var/www/html/wp-content/addons/checkout-for-woocommerce/sources/php/functions.php(397): WC_Payment_Gateways->get_available_payment_gateways()
#4 /var/www/html/wp-content/addons/checkout-for-woocommerce/sources/php/functions.php(945): cfw_get_payment_methods_html()
#5 /var/www/html/wp-content/addons/checkout-for-woocommerce/includes/Action/UpdateCheckoutAction.php(213): cfw_get_payment_methods()
#6 /var/www/html/wp-content/addons/checkout-for-woocommerce/includes/Action/CFWAction.php(76): Objectiv\Plugins\Checkout\Action\UpdateCheckoutAction->action()
#7 /var/www/html/wp-includes/class-wp-hook.php(324): Objectiv\Plugins\Checkout\Action\CFWAction->execute()
#8 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#9 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action()
#10 /var/www/html/wp-content/addons/woocommerce/includes/class-wc-ajax.php(96): do_action()
#11 /var/www/html/wp-includes/class-wp-hook.php(324): WC_AJAX::do_wc_ajax()
#12 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#13 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action()
#14 /var/www/html/wp-includes/template-loader.php(13): do_action()
#15 /var/www/html/wp-blog-header.php(19): require_once('/var/www/html/w...')
#16 /var/www/html/index.php(17): require('/var/www/html/w...')
[23-Aug-2024 10:49:31 UTC] Checking shipping address
[23-Aug-2024 10:49:31 UTC] Checking payment gateways
[23-Aug-2024 10:49:31 UTC] #0 /var/www/html/wp-includes/class-wp-hook.php(324): debug_payment_gateways()
#1 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#2 /var/www/html/wp-content/addons/woocommerce/includes/class-wc-payment-gateways.php(333): apply_filters()
#3 /var/www/html/wp-content/addons/checkout-for-woocommerce/sources/php/template-functions.php(910): WC_Payment_Gateways->get_available_payment_gateways()
#4 /var/www/html/wp-content/addons/checkout-for-woocommerce/sources/php/functions.php(3383): cfw_get_review_pane_payment_method()
#5 /var/www/html/wp-content/addons/checkout-for-woocommerce/includes/Managers/AssetManager.php(917): cfw_get_review_data()
#6 /var/www/html/wp-content/addons/checkout-for-woocommerce/includes/Action/UpdateCheckoutAction.php(233): Objectiv\Plugins\Checkout\Managers\AssetManager::get_data()
#7 /var/www/html/wp-content/addons/checkout-for-woocommerce/includes/Action/CFWAction.php(76): Objectiv\Plugins\Checkout\Action\UpdateCheckoutAction->action()
#8 /var/www/html/wp-includes/class-wp-hook.php(324): Objectiv\Plugins\Checkout\Action\CFWAction->execute()
#9 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#10 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action()
#11 /var/www/html/wp-content/addons/woocommerce/includes/class-wc-ajax.php(96): do_action()
#12 /var/www/html/wp-includes/class-wp-hook.php(324): WC_AJAX::do_wc_ajax()
#13 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#14 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action()
#15 /var/www/html/wp-includes/template-loader.php(13): do_action()
#16 /var/www/html/wp-blog-header.php(19): require_once('/var/www/html/w...')
#17 /var/www/html/index.php(17): require('/var/www/html/w...')
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Slow down – 2 calls to WC_Payment_Gateways->get_available_payment_gateway’ is closed to new replies.