From 5ab6d3b27d698719c9326663aa46fdd40fa3ba58 Mon Sep 17 00:00:00 2001 From: Alex P Date: Tue, 12 Dec 2023 10:57:31 +0200 Subject: [PATCH] Do not fail script loading if no script_attributes or data_client_id --- .../resources/js/modules/Helper/ScriptLoading.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-button/resources/js/modules/Helper/ScriptLoading.js b/modules/ppcp-button/resources/js/modules/Helper/ScriptLoading.js index 6c7dc1a37..96070b5fb 100644 --- a/modules/ppcp-button/resources/js/modules/Helper/ScriptLoading.js +++ b/modules/ppcp-button/resources/js/modules/Helper/ScriptLoading.js @@ -56,10 +56,12 @@ export const loadPaypalScript = (config, onLoaded, onError = null) => { // Build the PayPal script options. let scriptOptions = keysToCamelCase(config.url_params); - scriptOptions = merge(scriptOptions, config.script_attributes); + if (config.script_attributes) { + scriptOptions = merge(scriptOptions, config.script_attributes); + } // Load PayPal script for special case with data-client-token - if (config.data_client_id.set_attribute) { + if (config.data_client_id?.set_attribute) { dataClientIdAttributeHandler(scriptOptions, config.data_client_id, callback, errorCallback); return; }