Merged in feature/280-dev-dev01 (pull request #21)
auto-patch 280-dev-dev01-2024-01-19T16_41_58 * auto-patch 280-dev-dev01-2024-01-19T16_41_58
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
// Check init order attribution on consent change.
|
||||
const CONSENT_CATEGORY_MARKING = 'marketing';
|
||||
document.addEventListener( 'wp_listen_for_consent_change', ( e ) => {
|
||||
const changedConsentCategory = e.detail;
|
||||
for ( const key in changedConsentCategory ) {
|
||||
if ( changedConsentCategory.hasOwnProperty( key ) ) {
|
||||
if ( key === CONSENT_CATEGORY_MARKING && changedConsentCategory[ key ] === 'allow' ) {
|
||||
window.wc_order_attribution.setAllowTrackingConsent( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Init order attribution as soon as consent type is defined.
|
||||
$( document ).on( 'wp_consent_type_defined', () => {
|
||||
if ( wp_has_consent( CONSENT_CATEGORY_MARKING ) ) {
|
||||
window.wc_order_attribution.setAllowTrackingConsent( true );
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
||||
|
||||
Reference in New Issue
Block a user