diff --git a/plugins/woocommerce/changelog/add-order-attribution-base64-encoding-cookies b/plugins/woocommerce/changelog/add-order-attribution-base64-encoding-cookies new file mode 100644 index 00000000000..f38060060fa --- /dev/null +++ b/plugins/woocommerce/changelog/add-order-attribution-base64-encoding-cookies @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Filter to apply Base64 encoding to order attribution cookies diff --git a/plugins/woocommerce/client/legacy/js/frontend/order-attribution.js b/plugins/woocommerce/client/legacy/js/frontend/order-attribution.js index 9dad4dc842c..08dee73bd9b 100644 --- a/plugins/woocommerce/client/legacy/js/frontend/order-attribution.js +++ b/plugins/woocommerce/client/legacy/js/frontend/order-attribution.js @@ -82,6 +82,7 @@ sbjs.init( { lifetime: Number( params.lifetime ), session_length: Number( params.session ), + base64: Boolean( params.base64 ), timezone_offset: '0', // utc } ); } @@ -184,7 +185,10 @@ if( input ) { input.value = stringifyFalsyInputValue( this.values[ fieldName ] ); } else { - console.warn( `Field "${fieldName}" not found. Most likely, the '' element was manipulated.`); + console.warn( + `Field "${fieldName}" not found. ` + + `Most likely, the '' element was manipulated.` + ); } } } diff --git a/plugins/woocommerce/client/legacy/package.json b/plugins/woocommerce/client/legacy/package.json index b7b31847afc..a8b96931165 100644 --- a/plugins/woocommerce/client/legacy/package.json +++ b/plugins/woocommerce/client/legacy/package.json @@ -42,7 +42,7 @@ "wireit": "0.14.3" }, "dependencies": { - "sourcebuster": "github:woocommerce/sourcebuster-js#v1.1.2" + "sourcebuster": "github:woocommerce/sourcebuster-js#v1.2.0" }, "wireit": { "build:project:assets": { diff --git a/plugins/woocommerce/src/Internal/Orders/OrderAttributionController.php b/plugins/woocommerce/src/Internal/Orders/OrderAttributionController.php index 9aa0f137e7a..7ad08759562 100644 --- a/plugins/woocommerce/src/Internal/Orders/OrderAttributionController.php +++ b/plugins/woocommerce/src/Internal/Orders/OrderAttributionController.php @@ -288,6 +288,15 @@ class OrderAttributionController implements RegisterHooksInterface { */ $session_length = (int) apply_filters( 'wc_order_attribution_session_length_minutes', 30 ); + /** + * Filter to enable base64 encoding for cookie values. + * + * @since 9.0.0 + * + * @param bool $use_base64_cookies True to enable base64 encoding, default is false. + */ + $use_base64_cookies = apply_filters( 'wc_order_attribution_use_base64_cookies', false ); + /** * Filter to allow tracking. * @@ -302,6 +311,7 @@ class OrderAttributionController implements RegisterHooksInterface { 'params' => array( 'lifetime' => $lifetime, 'session' => $session_length, + 'base64' => $use_base64_cookies, 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'prefix' => $this->field_prefix, 'allowTracking' => 'yes' === $allow_tracking, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1390c775e0e..99efb52ac86 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4495,8 +4495,8 @@ importers: plugins/woocommerce/client/legacy: dependencies: sourcebuster: - specifier: github:woocommerce/sourcebuster-js#v1.1.2 - version: https://codeload.github.com/woocommerce/sourcebuster-js/tar.gz/411d8dffaa37d7602d678c2ec02baacee93c12d5 + specifier: github:woocommerce/sourcebuster-js#v1.2.0 + version: https://codeload.github.com/woocommerce/sourcebuster-js/tar.gz/d7f4616d5a17e17db925ca1842457f309379d861 devDependencies: '@types/node': specifier: ^16.18.68 @@ -22426,8 +22426,8 @@ packages: resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} engines: {node: '>= 8'} - sourcebuster@https://codeload.github.com/woocommerce/sourcebuster-js/tar.gz/411d8dffaa37d7602d678c2ec02baacee93c12d5: - resolution: {tarball: https://codeload.github.com/woocommerce/sourcebuster-js/tar.gz/411d8dffaa37d7602d678c2ec02baacee93c12d5} + sourcebuster@https://codeload.github.com/woocommerce/sourcebuster-js/tar.gz/d7f4616d5a17e17db925ca1842457f309379d861: + resolution: {tarball: https://codeload.github.com/woocommerce/sourcebuster-js/tar.gz/d7f4616d5a17e17db925ca1842457f309379d861} version: 1.1.2 space-separated-tokens@1.1.5: @@ -58636,7 +58636,7 @@ snapshots: source-map@0.7.4: {} - sourcebuster@https://codeload.github.com/woocommerce/sourcebuster-js/tar.gz/411d8dffaa37d7602d678c2ec02baacee93c12d5: {} + sourcebuster@https://codeload.github.com/woocommerce/sourcebuster-js/tar.gz/d7f4616d5a17e17db925ca1842457f309379d861: {} space-separated-tokens@1.1.5: {}