PayPal Express Button

Problem statement at our web agency: If the current PayPal plugin ("SwagPaymentPayPalUnified", see https://store.shopware.com/swag828732772311f/paypal.html, which replaces the old "PayPal Express" plugin) is used to enable PayPal Express Checkout in a Shopware online shop, but the PayPal Express Checkout is not displayed, this may be due to the localization of the Shopware shop. In our case, the console reported the JavaScript error "Error: Expected props.locale to be valid", meaning that the localization was invalid. In our case, it was Kazakh (language code "kk_KZ"), because we use the "Deutsch Du - Shopware 5+ ready" language pack from "Shop Uebersetzungen". However, the code "kk-KZ" is not supported by the PayPal plugin. So what can be done?

 

Of course, the first step is to contact the language pack extension developer and ask for assistance, since all users who want to use PayPal Express are affected by this problem — and to contact Shopware itself, which developed the PayPal plugin. Ideally, the PayPal plugin would provide "en_US", or English from another region, as a fallback for all languages it does not support. Unfortunately, this is not the case, so we hope that this will be addressed in the next update and work around the issue with an additional IF statement that passes the German localization (e.g. "de_DE") when the code "kk_KZ" is configured in the shop. To do this, we open the file

 

/custom/plugins/SwagPaymentPayPalUnified/Subscriber/ExpressCheckout

 

and modify the function

 

getExpressCheckoutButtonLanguage()

 

as follows:

 

private function getExpressCheckoutButtonLanguage()

{

                $express_checkout_button_language = $this->dependencyProvider->getShop()->getLocale()->getLocale();

                if ($express_checkout_button_language == 'kk_KZ') {

                               return 'de_DE';

                } else {

                               return $express_checkout_button_language;

                }

                // return $this->dependencyProvider->getShop()->getLocale()->getLocale();

}

 

So: Do everything as usual, but if the language is Kazakh, use German instead. This also makes the PayPal Express button appear in our Shopware online shop (the online shop version in a current project at our web agency: Shopware Professional 5.5.6). Hopefully, the next update will make this possible without any manual modifications!