Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

Tagged: 

This topic contains 13 replies, has 2 voices.

Last updated by Bruno Kos 10 months, 3 weeks ago.

Assisted by: Bruno Kos.

Author Posts
December 18, 2023 at 9:53 am #15082025

andrijaG-2

WC_Payment_Gateways->__construct() is called twice if WPML is active. As a result payment gatways are registered twice and hook's are triggered twice.

Just added trigger_error() in WC_Payment_Gateways->__construct()
```
public function __construct() {
trigger_error("testr", E_USER_WARNING);
$this->init();
}
```

Result is:
```
[18-Dec-2023 09:37:37 UTC] PHP Warning: test in /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php on line 70
[18-Dec-2023 09:37:37 UTC] PHP Stack trace:
[18-Dec-2023 09:37:37 UTC] PHP 1. {main}() /var/www/production/shop/wp-admin/plugins.php:0
[18-Dec-2023 09:37:37 UTC] PHP 2. require_once() /var/www/production/shop/wp-admin/plugins.php:10
[18-Dec-2023 09:37:37 UTC] PHP 3. require() /var/www/production/shop/wp-admin/admin.php:158
[18-Dec-2023 09:37:37 UTC] PHP 4. require_once() /var/www/production/shop/wp-admin/menu.php:417
[18-Dec-2023 09:37:37 UTC] PHP 5. do_action($hook_name = 'admin_menu', ...$arg = variadic('')) /var/www/production/shop/wp-admin/includes/menu.php:161
[18-Dec-2023 09:37:37 UTC] PHP 6. WP_Hook->do_action($args = [0 => '']) /var/www/production/shop/wp-includes/plugin.php:517
[18-Dec-2023 09:37:37 UTC] PHP 7. WP_Hook->apply_filters($value = '', $args = [0 => '']) /var/www/production/shop/wp-includes/class-wp-hook.php:348
[18-Dec-2023 09:37:37 UTC] PHP 8. Automattic\WooCommerce\Internal\Admin\WcPayWelcomePage->register_payments_welcome_page('') /var/www/production/shop/wp-includes/class-wp-hook.php:324
[18-Dec-2023 09:37:37 UTC] PHP 9. Automattic\WooCommerce\Internal\Admin\WcPayWelcomePage->must_be_visible() /var/www/production/shop/wp-content/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php:98
[18-Dec-2023 09:37:37 UTC] PHP 10. Automattic\WooCommerce\Internal\Admin\WcPayWelcomePage->get_incentive() /var/www/production/shop/wp-content/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php:80
[18-Dec-2023 09:37:37 UTC] PHP 11. WooCommerce->payment_gateways() /var/www/production/shop/wp-content/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php:391
[18-Dec-2023 09:37:37 UTC] PHP 12. WC_Payment_Gateways::instance() /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-woocommerce.php:970
[18-Dec-2023 09:37:37 UTC] PHP 13. WC_Payment_Gateways->__construct() /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php:43
[18-Dec-2023 09:37:37 UTC] PHP 14. trigger_error($message = 'testr', $error_level = 512) /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php:70
[18-Dec-2023 09:37:37 UTC] PHP Warning: testr in /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php on line 70
[18-Dec-2023 09:37:37 UTC] PHP Stack trace:
[18-Dec-2023 09:37:37 UTC] PHP 1. {main}() /var/www/production/shop/wp-admin/plugins.php:0
[18-Dec-2023 09:37:37 UTC] PHP 2. require_once() /var/www/production/shop/wp-admin/plugins.php:10
[18-Dec-2023 09:37:37 UTC] PHP 3. require() /var/www/production/shop/wp-admin/admin.php:158
[18-Dec-2023 09:37:37 UTC] PHP 4. require_once() /var/www/production/shop/wp-admin/menu.php:417
[18-Dec-2023 09:37:37 UTC] PHP 5. do_action($hook_name = 'admin_menu', ...$arg = variadic('')) /var/www/production/shop/wp-admin/includes/menu.php:161
[18-Dec-2023 09:37:37 UTC] PHP 6. WP_Hook->do_action($args = [0 => '']) /var/www/production/shop/wp-includes/plugin.php:517
[18-Dec-2023 09:37:37 UTC] PHP 7. WP_Hook->apply_filters($value = '', $args = [0 => '']) /var/www/production/shop/wp-includes/class-wp-hook.php:348
[18-Dec-2023 09:37:37 UTC] PHP 8. Automattic\WooCommerce\Internal\Admin\WcPayWelcomePage->register_payments_welcome_page('') /var/www/production/shop/wp-includes/class-wp-hook.php:324
[18-Dec-2023 09:37:37 UTC] PHP 9. Automattic\WooCommerce\Internal\Admin\WcPayWelcomePage->must_be_visible() /var/www/production/shop/wp-content/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php:98
[18-Dec-2023 09:37:37 UTC] PHP 10. Automattic\WooCommerce\Internal\Admin\WcPayWelcomePage->get_incentive() /var/www/production/shop/wp-content/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php:80
[18-Dec-2023 09:37:37 UTC] PHP 11. WooCommerce->payment_gateways() /var/www/production/shop/wp-content/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php:391
[18-Dec-2023 09:37:37 UTC] PHP 12. WC_Payment_Gateways::instance() /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-woocommerce.php:970
[18-Dec-2023 09:37:37 UTC] PHP 13. WC_Payment_Gateways->__construct() /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php:43
[18-Dec-2023 09:37:37 UTC] PHP 14. WC_Payment_Gateways->init() /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php:71
[18-Dec-2023 09:37:37 UTC] PHP 15. apply_filters($hook_name = 'woocommerce_payment_gateways', $value = [0 => 'WC_Gateway_BACS', 1 => 'WC_Gateway_Cheque', 2 => 'WC_Gateway_COD']) /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php:89
[18-Dec-2023 09:37:37 UTC] PHP 16. WP_Hook->apply_filters($value = [0 => 'WC_Gateway_BACS', 1 => 'WC_Gateway_Cheque', 2 => 'WC_Gateway_COD'], $args = [0 => [0 => 'WC_Gateway_BACS', 1 => 'WC_Gateway_Cheque', 2 => 'WC_Gateway_COD']]) /var/www/production/shop/wp-includes/plugin.php:205
[18-Dec-2023 09:37:37 UTC] PHP 17. WPML\FP\{closure:/var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/functions.php:137-158}([0 => class WC_Gateway_BACS { public $plugin_id = 'woocommerce_'; public $id = 'bacs'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'yes'; public $title = 'Direct bank transfer'; public $description = 'Make your payment directly into our bank account. Please use your Order ID as the payment reference. Your order will not be shipped until the funds have cleared in our account.'; public $chosen = NULL; public $method_title = 'Direct bank transfer'; public $method_description = 'Take payments in person via BACS. More commonly known as direct bank/wire transfer.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $locale = NULL; public $instructions = ''; public $account_details = [...] }, 1 => class WC_Gateway_Cheque { public $plugin_id = 'woocommerce_'; public $id = 'cheque'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'no'; public $title = 'Check payments'; public $description = 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.'; public $chosen = NULL; public $method_title = 'Check payments'; public $method_description = 'Take payments in person via checks. This offline gateway can also be useful to test purchases.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $instructions = '' }, 2 => class WC_Gateway_COD { public $plugin_id = 'woocommerce_'; public $id = 'cod'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'no'; public $title = 'Cash on delivery'; public $description = 'Pay with cash upon delivery.'; public $chosen = NULL; public $method_title = 'Cash on delivery'; public $method_description = 'Have your customers pay with cash (or by other means) upon delivery.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $instructions = 'Pay with cash upon delivery.'; public $enable_for_methods = [...]; public $enable_for_virtual = TRUE }]) /var/www/production/shop/wp-includes/class-wp-hook.php:324
[18-Dec-2023 09:37:37 UTC] PHP 18. call_user_func_array:{/var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/functions.php:154}($callback = class Closure { public $parameter = ['$fn' => '<required>', '$value' => '<required>'] }, $args = [0 => class Closure { public $static = [...] }, 1 => [0 => class WC_Gateway_BACS { ... }, 1 => class WC_Gateway_Cheque { ... }, 2 => class WC_Gateway_COD { ... }]]) /var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/functions.php:154
[18-Dec-2023 09:37:37 UTC] PHP 19. WPML\FP\Fns::WPML\FP\{closure:/var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php:174-178}($fn = class Closure { public $static = ['returnFn' => class Closure { ... }, 'fn' => [...], 'inProgress' => TRUE] }, $value = [0 => class WC_Gateway_BACS { public $plugin_id = 'woocommerce_'; public $id = 'bacs'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'yes'; public $title = 'Direct bank transfer'; public $description = 'Make your payment directly into our bank account. Please use your Order ID as the payment reference. Your order will not be shipped until the funds have cleared in our account.'; public $chosen = NULL; public $method_title = 'Direct bank transfer'; public $method_description = 'Take payments in person via BACS. More commonly known as direct bank/wire transfer.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $locale = NULL; public $instructions = ''; public $account_details = [...] }, 1 => class WC_Gateway_Cheque { public $plugin_id = 'woocommerce_'; public $id = 'cheque'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'no'; public $title = 'Check payments'; public $description = 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.'; public $chosen = NULL; public $method_title = 'Check payments'; public $method_description = 'Take payments in person via checks. This offline gateway can also be useful to test purchases.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $instructions = '' }, 2 => class WC_Gateway_COD { public $plugin_id = 'woocommerce_'; public $id = 'cod'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'no'; public $title = 'Cash on delivery'; public $description = 'Pay with cash upon delivery.'; public $chosen = NULL; public $method_title = 'Cash on delivery'; public $method_description = 'Have your customers pay with cash (or by other means) upon delivery.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $instructions = 'Pay with cash upon delivery.'; public $enable_for_methods = [...]; public $enable_for_virtual = TRUE }]) /var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/functions.php:154
[18-Dec-2023 09:37:37 UTC] PHP 20. WPML\FP\Fns::WPML\FP\{closure:/var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php:363-375}([0 => class WC_Gateway_BACS { public $plugin_id = 'woocommerce_'; public $id = 'bacs'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'yes'; public $title = 'Direct bank transfer'; public $description = 'Make your payment directly into our bank account. Please use your Order ID as the payment reference. Your order will not be shipped until the funds have cleared in our account.'; public $chosen = NULL; public $method_title = 'Direct bank transfer'; public $method_description = 'Take payments in person via BACS. More commonly known as direct bank/wire transfer.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $locale = NULL; public $instructions = ''; public $account_details = [...] }, 1 => class WC_Gateway_Cheque { public $plugin_id = 'woocommerce_'; public $id = 'cheque'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'no'; public $title = 'Check payments'; public $description = 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.'; public $chosen = NULL; public $method_title = 'Check payments'; public $method_description = 'Take payments in person via checks. This offline gateway can also be useful to test purchases.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $instructions = '' }, 2 => class WC_Gateway_COD { public $plugin_id = 'woocommerce_'; public $id = 'cod'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'no'; public $title = 'Cash on delivery'; public $description = 'Pay with cash upon delivery.'; public $chosen = NULL; public $method_title = 'Cash on delivery'; public $method_description = 'Have your customers pay with cash (or by other means) upon delivery.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $instructions = 'Pay with cash upon delivery.'; public $enable_for_methods = [...]; public $enable_for_virtual = TRUE }]) /var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php:175
[18-Dec-2023 09:37:37 UTC] PHP 21. call_user_func_array:{/var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php:371}($callback = [0 => class WCML_Currencies_Payment_Gateways { private $payment_gateways = [...]; private $available_gateways = [...]; private $supported_gateways = [...]; private $woocommerce_wpml = class woocommerce_wpml { ... }; private $wp_api = class WPML_WP_API { ... } }, 1 => 'init_gateways'], $args = [0 => [0 => class WC_Gateway_BACS { ... }, 1 => class WC_Gateway_Cheque { ... }, 2 => class WC_Gateway_COD { ... }]]) /var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php:371
[18-Dec-2023 09:37:37 UTC] PHP 22. WCML_Currencies_Payment_Gateways->init_gateways([0 => class WC_Gateway_BACS { public $plugin_id = 'woocommerce_'; public $id = 'bacs'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'yes'; public $title = 'Direct bank transfer'; public $description = 'Make your payment directly into our bank account. Please use your Order ID as the payment reference. Your order will not be shipped until the funds have cleared in our account.'; public $chosen = NULL; public $method_title = 'Direct bank transfer'; public $method_description = 'Take payments in person via BACS. More commonly known as direct bank/wire transfer.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $locale = NULL; public $instructions = ''; public $account_details = [...] }, 1 => class WC_Gateway_Cheque { public $plugin_id = 'woocommerce_'; public $id = 'cheque'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'no'; public $title = 'Check payments'; public $description = 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.'; public $chosen = NULL; public $method_title = 'Check payments'; public $method_description = 'Take payments in person via checks. This offline gateway can also be useful to test purchases.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $instructions = '' }, 2 => class WC_Gateway_COD { public $plugin_id = 'woocommerce_'; public $id = 'cod'; public $errors = [...]; public $settings = [...]; public $form_fields = [...]; protected $data = [...]; public $order_button_text = NULL; public $enabled = 'no'; public $title = 'Cash on delivery'; public $description = 'Pay with cash upon delivery.'; public $chosen = NULL; public $method_title = 'Cash on delivery'; public $method_description = 'Have your customers pay with cash (or by other means) upon delivery.'; public $has_fields = FALSE; public $countries = NULL; public $availability = NULL; public $icon = ''; public $supports = [...]; public $max_amount = 0; public $view_transaction_url = ''; public $new_method_label = ''; public $pay_button_id = ''; protected $tokens = [...]; public $instructions = 'Pay with cash upon delivery.'; public $enable_for_methods = [...]; public $enable_for_virtual = TRUE }]) /var/www/production/shop/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Fns.php:371
[18-Dec-2023 09:37:37 UTC] PHP 23. WCML_Currencies_Payment_Gateways->get_available_payment_gateways() /var/www/production/shop/wp-content/plugins/woocommerce-multilingual/classes/multi-currency/payment-gateways/class-wcml-currencies-payment-gateways.php:101
[18-Dec-2023 09:37:37 UTC] PHP 24. WooCommerce->payment_gateways() /var/www/production/shop/wp-content/plugins/woocommerce-multilingual/classes/multi-currency/payment-gateways/class-wcml-currencies-payment-gateways.php:216
[18-Dec-2023 09:37:37 UTC] PHP 25. WC_Payment_Gateways::instance() /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-woocommerce.php:970
[18-Dec-2023 09:37:37 UTC] PHP 26. WC_Payment_Gateways->__construct() /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php:43
[18-Dec-2023 09:37:37 UTC] PHP 27. trigger_error($message = 'test', $error_level = 512) /var/www/production/shop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php:70

```

December 20, 2023 at 8:29 am #15098827

andrijaG-2

No response?!

December 21, 2023 at 9:23 am #15107983

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Hi,

Thank you for contacting WPML support!

Can you show us this here perhaps using your own way of triggering this error?
hidden link

Any particular URL I need to visit after you added the code?

Have you done your tests using custom plugin with a code such as:

add_action('plugins_loaded', 'my_custom_woocommerce_modification');

function my_custom_woocommerce_modification() {
    if (class_exists('WC_Payment_Gateways')) {
        trigger_error("WC_Payment_Gateways class is loaded", E_USER_WARNING);
    }
}

Feel free to make any modifications on the above sandbox.

Regards,
Bruno Kos

December 21, 2023 at 9:50 am #15108291

andrijaG-2

Not sure if I'am following. Here is output of snippet you provided:
```
[21-Dec-2023 09:28:52 UTC] PHP Warning: WC_Payment_Gateways class is loaded in /my_wp_root/wp-content/plugins/some-test-plugin/some-test-plugin.php on line 138
[21-Dec-2023 09:28:52 UTC] PHP Stack trace:
[21-Dec-2023 09:28:52 UTC] PHP 1. {main}() /my_wp_root/wp-admin/admin-ajax.php:0
[21-Dec-2023 09:28:52 UTC] PHP 2. require_once() /my_wp_root/wp-admin/admin-ajax.php:22
[21-Dec-2023 09:28:52 UTC] PHP 3. require_once() /my_wp_root/wp-load.php:50
[21-Dec-2023 09:28:52 UTC] PHP 4. require_once() /my_wp_root/wp-config.php:109
[21-Dec-2023 09:28:52 UTC] PHP 5. do_action($hook_name = 'plugins_loaded') /my_wp_root/wp-settings.php:506
[21-Dec-2023 09:28:52 UTC] PHP 6. WP_Hook->do_action($args = [0 => '']) /my_wp_root/wp-includes/plugin.php:517
[21-Dec-2023 09:28:52 UTC] PHP 7. WP_Hook->apply_filters($value = '', $args = [0 => '']) /my_wp_root/wp-includes/class-wp-hook.php:348
[21-Dec-2023 09:28:52 UTC] PHP 8. my_custom_woocommerce_modification('') /my_wp_root/wp-includes/class-wp-hook.php:324
[21-Dec-2023 09:28:52 UTC] PHP 9. trigger_error($message = 'WC_Payment_Gateways class is loaded', $error_level = 512) /my_wp_root/wp-content/plugins/some-test-plugin/some-test-plugin.php:138
```

WPML is calling "WC()->payment_gateways()->get_available_payment_gateways()" at class-wcml-currencies-payment-gateways.php:216 which is called form "woocommerce_payment_gateways".

"woocommerce_payment_gateways" hook which is called from WC_Payment_Gateways::init "class-wc-payment-gateways.php:89" which is called from "WC_Payment_Gateways::__constructor()" during instantiating "WC_Payment_Gateways" in "WC_Payment_Gateways::instance()".

Eg. WPML is calling "WC_Payment_Gateways::instance()" from itself.

There are three possible solutions:
1. Change Woo to first construct WC_Payment_Gateways in instance() and then call init()
2. Change WPML to use different hook
3. Change WPML to not instantiate WC_Payment_Gateways during "woocommerce_payment_gateways"

BTW. Double initialization of WC_Payment_Gateways is double registration of hooks which is problem for any payment gatway hook that return HTML. As a result there are duplicated HTML content on page eg. for wire transfer there are two "Paying instructions".

December 21, 2023 at 1:10 pm #15110461

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

I asked our 2nd tier to check this out, we will get back to you as soon as I have some information.

December 21, 2023 at 4:02 pm #15111979

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Can you please provide us with the debug information, so that we can get a better idea of your setup?

https://wpml.org/faq/provide-debug-information-faster-support/

Because according to our development log, it should have been resolved in Version 5.3.0:
https://wpml.org/download/woocommerce-multilingual-multicurrency/?section=changelog

Specifically:
Improved performance by loading shipping and payment gateways only when needed.

December 28, 2023 at 9:38 pm #15135738

andrijaG-2

After futher investigation I found two similar problems with user-provider workarounds

https://wpml.org/forums/topic/duplicated-bank-information-in-order-confirmation-email/
https://wpml.org/errata/all-bacs-accounts-are-shown-on-order-confirmation-page-and-emails/

I recreated problem on your sandbox hidden link

Backend:
1. Activate multi currency
2. Add second currency
3. Activate Payments->BACS
4. Add product

Frontend:
1. Orders some product
2. On "Checkout" page "Our bank details" are listed twice

January 2, 2024 at 7:59 am #15140330

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

I am not seeing this on hidden link, can you send a screenshot?

Also, have you made any changes on the site code in Sandbox (theme, plugins, etc)?

January 2, 2024 at 9:01 am #15142377

andrijaG-2

It's on "Order received" after checkout. Screen shot attached.

Pasted image.png
January 2, 2024 at 1:31 pm #15143595

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

I see - can you only confirm whether you made any changes (function call checks, etc) in the sandbox or the sandbox plugins are as they were installed?

January 3, 2024 at 10:51 am #15146053

andrijaG-2

No changes, plugins are there as installed.

January 3, 2024 at 3:40 pm #15147618

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Ok - for that order issue, would this not work?
https://wpml.org/errata/woocommerce-payment-details-are-displayed-twice-on-the-order-confirmation-page-e-mail/

Can you try? Let me know if this is a different issue than the one you reported in the first message.

January 8, 2024 at 9:51 am #15159313

andrijaG-2

Errata you send should be manually applied on every WPML update? Why is this not part of plugin?

If this could be applied as some snippet that would be fine, but editing Your plugin on every update is something You should change in Your plugin.

January 8, 2024 at 11:41 am #15160066

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

As far as I see within our development cycle, it seems like the permanent fix is scheduled for 5.3.3 which would be the next release.

The topic ‘[Closed] WC_Payment_Gateways->__construct() is called twice’ is closed to new replies.