Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client was experiencing an error message indicating an undefined property related to WooCommerce and PayPal payment gateways.

Solution:
1. We acknowledged the issue and confirmed that our development team was able to reproduce it. The problem was specifically occurring when using the "WooCommerce Checkout Add-Ons" plugin alongside the PayPal plugin.
2. We informed the client that an Errata had been published for this issue, which can be found here: https://wpml.org/errata/woocommerce-checkout-add-ons-and-woocommerce-paypal-payments-fees-not-added-to-paypal-in-multicurrency-setup/
3. We released an update for WooCommerce Multilingual (version 5.3.5) that should resolve the issue. We advised the client to update the plugin to the latest version. If the update was not visible in the Plugin dashboard, we provided instructions to download the latest version from the WPML account downloads page: https://wpml.org/account/downloads/

Please note that the solution provided might be irrelevant if it's outdated or not applicable to your case. If the issue persists after trying the recommended steps, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you need further assistance, please open a new support ticket at our support forum.

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.

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Prosenjit Barman 1 year, 4 months ago.

Assisted by: Prosenjit Barman.

Author Posts
February 21, 2024 at 1:55 pm #15328469

thorbenK

Hello,

i get the following error message: Warning: Undefined property: WooCommerce::$payment_gateways in ...
/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/src/Checkout/DisableGateways.php on line 118

I tried the known workaround but couldn't find the code snippet to change: https://wpml.org/errata/woocommerce-payment-details-are-displayed-twice-on-the-order-confirmation-page-e-mail/

Code:

<?php

use WCML\Multicurrency\Transient\Hooks as TransientHooks;

/**
* Class WCML_Currencies_Payment_Gateways
*/
class WCML_Currencies_Payment_Gateways {

const OPTION_KEY = 'wcml_custom_payment_gateways_for_currencies';

/** @var WCML_Payment_Gateway[] */
private $payment_gateways;

/** @var array */
private $available_gateways;

/** @var array */
private $supported_gateways;

/** @var woocommerce_wpml */
private $woocommerce_wpml;

/** @var WPML_WP_API */
private $wp_api;

/**
* @param woocommerce_wpml $woocommerce_wpml
* @param WPML_WP_API $wp_api
*/
public function __construct( woocommerce_wpml $woocommerce_wpml, WPML_WP_API $wp_api ) {
$this->woocommerce_wpml = $woocommerce_wpml;
$this->wp_api = $wp_api;
}

public function add_hooks() {
/**
* Since WC 8.5 we have `wc_payment_gateways_initialized` to load our code only when
* needed. Before that, we have to use `wp_loaded` and get the instance ourselves,
* which causes gateways to be loaded on every request.
*/
$hook = version_compare( WC_VERSION, '8.5', '>=' )
? 'wc_payment_gateways_initialized'
: 'wp_loaded';
add_action( $hook, [ $this, 'init_gateways' ] );

add_filter( 'woocommerce_gateway_description', [ $this, 'filter_gateway_description' ], 10, 2 );
add_filter( 'option_woocommerce_stripe_settings', [ 'WCML_Payment_Gateway_Stripe', 'filter_stripe_settings' ] );
add_filter( 'option_woocommerce-ppcp-settings', [ 'WCML_Payment_Gateway_PayPal_V2', 'filter_ppcp_args' ] );

TransientHooks::addHooks( WCML_Payment_Gateway_PayPal_V2::BEARER_TOKEN_TRANSIENT );

if ( ! is_admin() && wcml_is_multi_currency_on() ) {
add_filter(
'woocommerce_paypal_supported_currencies',
[ 'WCML_Payment_Gateway_PayPal', 'filter_supported_currencies' ]
);
}
}

/**
* @param string $currency
*
* @return bool
*/
public function is_enabled( $currency ) {
$gateway_enabled_settings = $this->get_settings();

if ( isset( $gateway_enabled_settings[ $currency ] ) ) {
return $gateway_enabled_settings[ $currency ];
}

return false;
}

/**
* @param string $currency
* @param bool $value
*/
public function set_enabled( $currency, $value ) {
$gateway_enabled_settings = $this->get_settings();
$gateway_enabled_settings[ $currency ] = $value;

update_option( self::OPTION_KEY, $gateway_enabled_settings );
}

/**
* @return array
*/
private function get_settings() {
return get_option( self::OPTION_KEY, [] );
}

/**
* @param WC_Payment_Gateways|null $wc_payment_gateways
*/
public function init_gateways( $wc_payment_gateways = null ) {
if ( null !== $this->payment_gateways ) {
return;
}

if ( ! $wc_payment_gateways ) {
$wc_payment_gateways = WC()->payment_gateways();
}

$this->payment_gateways = [];
$this->available_gateways = [];
$this->supported_gateways = [];

do_action( 'wcml_before_init_currency_payment_gateways' );

$this->available_gateways = $wc_payment_gateways->get_available_payment_gateways();

$this->supported_gateways = [
'bacs' => 'WCML_Payment_Gateway_Bacs',
'paypal' => 'WCML_Payment_Gateway_PayPal',
'ppcp-gateway' => 'WCML_Payment_Gateway_PayPal_V2',
'stripe' => 'WCML_Payment_Gateway_Stripe',
];
$this->supported_gateways = apply_filters( 'wcml_supported_currency_payment_gateways', $this->supported_gateways );

$this->store_supported_gateways();
$this->store_non_supported_gateways();
}

/**
* @return array
*/
public function get_gateways() {
$this->init_gateways();

return $this->payment_gateways;
}

/**
* @return array
*/
public function get_supported_gateways() {
$this->init_gateways();

February 22, 2024 at 11:29 am #15333152

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thanks for contacting WPML Support.

I understand the issue you're having and would like to inform you that our development team has also been able to reproduce the issue. It's a complicated issue that affects the PayPal plugin but only occurs when using the "WooCommerce Checkout Add-Ons" plugin.

We also have published an Errata for this issue: https://wpml.org/errata/woocommerce-checkout-add-ons-and-woocommerce-paypal-payments-fees-not-added-to-paypal-in-multicurrency-setup/

Unfortunately, we currently don't have a viable solution for this problem. However, I want to assure you that our development team is actively working on this matter. I will promptly inform you as soon as there is any update. Additionally, I will also add this ticket to the development ticket created to address the issue to increase the priority.

I appreciate your patience and understanding in this matter.

Best regards,
Prosenjit

February 23, 2024 at 2:37 am #15335976

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
I hope you're doing well.

We've released an update for WooCommerce Multilingual (version 5.3.5) that addresses the problem you're experiencing. Could you please update the plugin to the newest version and see if it resolves the issue?

If you're not seeing any update notice in the Plugin dashboard, you can download the latest version of the plugin from the Download section of your WPML.ORG account(https://wpml.org/account/downloads/) and install that version on your site.

Let me know how it goes. I will be happy to help if you need further assistance in this matter.

Best regards,
Prosenjit