Closed RadoslavGeorgiev closed 6 months ago
In 7380387-zen, the user used the fix provided in this Slack thread by @RadoslavGeorgiev and resolved the incompatibility issue with the plugin Vertical Accordion and Product Detail tabs. TLDR: ApplePay&GooglePay buttons were not working in Single Product pages.
WooCommerce and other Extensions also rely on wc
, so I couldn't simulate any scenario where the store is broken because of wc
being overwritten and this check fixes it. I created a PR anyway so that we're doing our part in checking if an unpredictable variable that should never be overwritten holds the expected value. However, errors like this can only be solved by the extensions causing them or worked around using the suggested fix.
Ticket: 7380387-zd-a8c
The
getConfig
function in checkout utils assumes that as long as awc
global is available, it's Woo configuration:https://github.com/Automattic/woocommerce-payments/blob/4a667b85caa3f97572d055ca07107a51afd8201c/client/utils/checkout.js#L16-L18
However, it might not be. An extension I just stumbled upon does this in the global namespace:
In the given scenario,
wc
was not defined anyway, but because it's now an element, our code triggers a fatal error, and prevents payment request buttons from working, even though they show up.To avoid this, we should first check whether
wc.wcSettings
exists, and that it has agetSetting()
method.