plugin updates
This commit is contained in:
@@ -705,15 +705,13 @@
|
||||
|
||||
} else {
|
||||
var prop = slider.prop;
|
||||
|
||||
slider.container.each(function() {
|
||||
var container = this;
|
||||
var keyframes = {};
|
||||
keyframes[prop] = [
|
||||
window.getComputedStyle(container)[prop],
|
||||
slider.args[prop]
|
||||
];
|
||||
var currentStyle = {};
|
||||
currentStyle[prop] = container.style[prop];
|
||||
|
||||
container.animate(keyframes, { duration: slider.vars.animationSpeed, easing: easing }).onfinish = function() {
|
||||
container.animate([currentStyle, slider.args], { duration: slider.vars.animationSpeed, easing: easing }).onfinish = function() {
|
||||
container.style[prop] = slider.args[prop];
|
||||
slider.wrapup(dimension);
|
||||
};
|
||||
@@ -1134,7 +1132,8 @@
|
||||
$slides = $this.find(selector);
|
||||
|
||||
if ( ( $slides.length === 1 && options.allowOneSlide === false ) || $slides.length === 0 ) {
|
||||
$slides.fadeIn(400);
|
||||
var fadeIn = [{ opacity: 0 }, { opacity: 1 }];
|
||||
if ($slides.length) { $slides[0].animate(fadeIn, 400); }
|
||||
if (options.start) { options.start($this); }
|
||||
} else if ($this.data('flexslider') === undefined) {
|
||||
new $.flexslider(this, options);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -14,7 +14,7 @@ jQuery( function( $ ) {
|
||||
this.run = this.run.bind( this );
|
||||
|
||||
$( document.body )
|
||||
.on( 'click', '.add_to_cart_button', { addToCartHandler: this }, this.onAddToCart )
|
||||
.on( 'click', '.add_to_cart_button:not(.wc-interactive)', { addToCartHandler: this }, this.onAddToCart )
|
||||
.on( 'click', '.remove_from_cart_button', { addToCartHandler: this }, this.onRemoveFromCart )
|
||||
.on( 'added_to_cart', this.updateButton )
|
||||
.on( 'ajax_request_not_sent.adding_to_cart', this.updateButton )
|
||||
@@ -71,7 +71,7 @@ jQuery( function( $ ) {
|
||||
$thisbutton.addClass( 'loading' );
|
||||
|
||||
// Allow 3rd parties to validate and quit early.
|
||||
if ( false === $( document.body ).triggerHandler( 'should_send_ajax_request.adding_to_cart', [ $thisbutton ] ) ) {
|
||||
if ( false === $( document.body ).triggerHandler( 'should_send_ajax_request.adding_to_cart', [ $thisbutton ] ) ) {
|
||||
$( document.body ).trigger( 'ajax_request_not_sent.adding_to_cart', [ false, false, $thisbutton ] );
|
||||
return true;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ jQuery( function( $ ) {
|
||||
|
||||
if ( $button ) {
|
||||
$button.removeClass( 'loading' );
|
||||
|
||||
|
||||
if ( fragments ) {
|
||||
$button.addClass( 'added' );
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
jQuery(function(t){if("undefined"==typeof wc_add_to_cart_params)return!1;var a=function(){this.requests=[],this.addRequest=this.addRequest.bind(this),this.run=this.run.bind(this),t(document.body).on("click",".add_to_cart_button",{addToCartHandler:this},this.onAddToCart).on("click",".remove_from_cart_button",{addToCartHandler:this},this.onRemoveFromCart).on("added_to_cart",this.updateButton).on("ajax_request_not_sent.adding_to_cart",this.updateButton).on("added_to_cart removed_from_cart",{addToCartHandler:this},this.updateFragments)};a.prototype.addRequest=function(t){this.requests.push(t),1===this.requests.length&&this.run()},a.prototype.run=function(){var a=this,e=a.requests[0].complete;a.requests[0].complete=function(){"function"==typeof e&&e(),a.requests.shift(),a.requests.length>0&&a.run()},t.ajax(this.requests[0])},a.prototype.onAddToCart=function(a){var e=t(this);if(e.is(".ajax_add_to_cart")){if(!e.attr("data-product_id"))return!0;if(a.preventDefault(),e.removeClass("added"),e.addClass("loading"),!1===t(document.body).triggerHandler("should_send_ajax_request.adding_to_cart",[e]))return t(document.body).trigger("ajax_request_not_sent.adding_to_cart",[!1,!1,e]),!0;var r={};t.each(e.data(),function(t,a){r[t]=a}),t.each(e[0].dataset,function(t,a){r[t]=a}),t(document.body).trigger("adding_to_cart",[e,r]),a.data.addToCartHandler.addRequest({type:"POST",url:wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart"),data:r,success:function(a){a&&(a.error&&a.product_url?window.location=a.product_url:"yes"!==wc_add_to_cart_params.cart_redirect_after_add?t(document.body).trigger("added_to_cart",[a.fragments,a.cart_hash,e]):window.location=wc_add_to_cart_params.cart_url)},dataType:"json"})}},a.prototype.onRemoveFromCart=function(a){var e=t(this),r=e.closest(".woocommerce-mini-cart-item");a.preventDefault(),r.block({message:null,overlayCSS:{opacity:.6}}),a.data.addToCartHandler.addRequest({type:"POST",url:wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","remove_from_cart"),data:{cart_item_key:e.data("cart_item_key")},success:function(a){a&&a.fragments?t(document.body).trigger("removed_from_cart",[a.fragments,a.cart_hash,e]):window.location=e.attr("href")},error:function(){window.location=e.attr("href")},dataType:"json"})},a.prototype.updateButton=function(a,e,r,d){(d=void 0!==d&&d)&&(d.removeClass("loading"),e&&d.addClass("added"),e&&!wc_add_to_cart_params.is_cart&&0===d.parent().find(".added_to_cart").length&&d.after('<a href="'+wc_add_to_cart_params.cart_url+'" class="added_to_cart wc-forward" title="'+wc_add_to_cart_params.i18n_view_cart+'">'+wc_add_to_cart_params.i18n_view_cart+"</a>"),t(document.body).trigger("wc_cart_button_updated",[d]))},a.prototype.updateFragments=function(a,e){e&&(t.each(e,function(a){t(a).addClass("updating").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}})}),t.each(e,function(a,e){t(a).replaceWith(e),t(a).stop(!0).css("opacity","1").unblock()}),t(document.body).trigger("wc_fragments_loaded"))},new a});
|
||||
jQuery(function(t){if("undefined"==typeof wc_add_to_cart_params)return!1;var a=function(){this.requests=[],this.addRequest=this.addRequest.bind(this),this.run=this.run.bind(this),t(document.body).on("click",".add_to_cart_button:not(.wc-interactive)",{addToCartHandler:this},this.onAddToCart).on("click",".remove_from_cart_button",{addToCartHandler:this},this.onRemoveFromCart).on("added_to_cart",this.updateButton).on("ajax_request_not_sent.adding_to_cart",this.updateButton).on("added_to_cart removed_from_cart",{addToCartHandler:this},this.updateFragments)};a.prototype.addRequest=function(t){this.requests.push(t),1===this.requests.length&&this.run()},a.prototype.run=function(){var a=this,e=a.requests[0].complete;a.requests[0].complete=function(){"function"==typeof e&&e(),a.requests.shift(),a.requests.length>0&&a.run()},t.ajax(this.requests[0])},a.prototype.onAddToCart=function(a){var e=t(this);if(e.is(".ajax_add_to_cart")){if(!e.attr("data-product_id"))return!0;if(a.preventDefault(),e.removeClass("added"),e.addClass("loading"),!1===t(document.body).triggerHandler("should_send_ajax_request.adding_to_cart",[e]))return t(document.body).trigger("ajax_request_not_sent.adding_to_cart",[!1,!1,e]),!0;var r={};t.each(e.data(),function(t,a){r[t]=a}),t.each(e[0].dataset,function(t,a){r[t]=a}),t(document.body).trigger("adding_to_cart",[e,r]),a.data.addToCartHandler.addRequest({type:"POST",url:wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart"),data:r,success:function(a){a&&(a.error&&a.product_url?window.location=a.product_url:"yes"!==wc_add_to_cart_params.cart_redirect_after_add?t(document.body).trigger("added_to_cart",[a.fragments,a.cart_hash,e]):window.location=wc_add_to_cart_params.cart_url)},dataType:"json"})}},a.prototype.onRemoveFromCart=function(a){var e=t(this),r=e.closest(".woocommerce-mini-cart-item");a.preventDefault(),r.block({message:null,overlayCSS:{opacity:.6}}),a.data.addToCartHandler.addRequest({type:"POST",url:wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","remove_from_cart"),data:{cart_item_key:e.data("cart_item_key")},success:function(a){a&&a.fragments?t(document.body).trigger("removed_from_cart",[a.fragments,a.cart_hash,e]):window.location=e.attr("href")},error:function(){window.location=e.attr("href")},dataType:"json"})},a.prototype.updateButton=function(a,e,r,d){(d=void 0!==d&&d)&&(d.removeClass("loading"),e&&d.addClass("added"),e&&!wc_add_to_cart_params.is_cart&&0===d.parent().find(".added_to_cart").length&&d.after('<a href="'+wc_add_to_cart_params.cart_url+'" class="added_to_cart wc-forward" title="'+wc_add_to_cart_params.i18n_view_cart+'">'+wc_add_to_cart_params.i18n_view_cart+"</a>"),t(document.body).trigger("wc_cart_button_updated",[d]))},a.prototype.updateFragments=function(a,e){e&&(t.each(e,function(a){t(a).addClass("updating").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}})}),t.each(e,function(a,e){t(a).replaceWith(e),t(a).stop(!0).css("opacity","1").unblock()}),t(document.body).trigger("wc_fragments_loaded"))},new a});
|
||||
@@ -407,7 +407,7 @@ jQuery( function( $ ) {
|
||||
var $form = $( 'form.checkout' );
|
||||
|
||||
// Remove notices from all sources
|
||||
$( '.woocommerce-error, .woocommerce-message' ).remove();
|
||||
$( '.woocommerce-error, .woocommerce-message, .is-error, .is-success' ).remove();
|
||||
|
||||
// Add new errors returned by this event
|
||||
if ( data.messages ) {
|
||||
@@ -572,7 +572,7 @@ jQuery( function( $ ) {
|
||||
return false;
|
||||
},
|
||||
submit_error: function( error_message ) {
|
||||
$( '.woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message' ).remove();
|
||||
$( '.woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message, .is-error, .is-success' ).remove();
|
||||
wc_checkout_form.$checkout_form.prepend( '<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">' + error_message + '</div>' ); // eslint-disable-line max-len
|
||||
wc_checkout_form.$checkout_form.removeClass( 'processing' ).unblock();
|
||||
wc_checkout_form.$checkout_form.find( '.input-text, select, input:checkbox' ).trigger( 'validate' ).trigger( 'blur' );
|
||||
@@ -626,7 +626,7 @@ jQuery( function( $ ) {
|
||||
url: wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'apply_coupon' ),
|
||||
data: data,
|
||||
success: function( code ) {
|
||||
$( '.woocommerce-error, .woocommerce-message' ).remove();
|
||||
$( '.woocommerce-error, .woocommerce-message, .is-error, .is-success' ).remove();
|
||||
$form.removeClass( 'processing' ).unblock();
|
||||
|
||||
if ( code ) {
|
||||
@@ -666,7 +666,7 @@ jQuery( function( $ ) {
|
||||
url: wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'remove_coupon' ),
|
||||
data: data,
|
||||
success: function( code ) {
|
||||
$( '.woocommerce-error, .woocommerce-message' ).remove();
|
||||
$( '.woocommerce-error, .woocommerce-message, .is-error, .is-success' ).remove();
|
||||
container.removeClass( 'processing' ).unblock();
|
||||
|
||||
if ( code ) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +0,0 @@
|
||||
// Extend checkout block's request data with order attribution data.
|
||||
window.wp.data.dispatch( window.wc.wcBlocksData.CHECKOUT_STORE_KEY ).__internalSetExtensionData(
|
||||
'woocommerce/order-attribution',
|
||||
window.wc_order_attribution.sbjsDataToSchema( window.sbjs.get )
|
||||
);
|
||||
@@ -1 +0,0 @@
|
||||
window.wp.data.dispatch(window.wc.wcBlocksData.CHECKOUT_STORE_KEY).__internalSetExtensionData("woocommerce/order-attribution",window.wc_order_attribution.sbjsDataToSchema(window.sbjs.get));
|
||||
@@ -5,93 +5,78 @@
|
||||
|
||||
// Helper functions.
|
||||
const $ = document.querySelector.bind( document );
|
||||
const propertyAccessor = ( obj, path ) => path.split( '.' ).reduce( ( acc, part ) => acc && acc[ part ], obj );
|
||||
const returnNull = () => null;
|
||||
|
||||
// Hardcode Checkout store key (`wc.wcBlocksData.CHECKOUT_STORE_KEY`), as we no longer have `wc-blocks-checkout` as a dependency.
|
||||
const CHECKOUT_STORE_KEY = 'wc/store/checkout';
|
||||
|
||||
/**
|
||||
* Flattens the sbjs.get object into a schema compatible object.
|
||||
* Get the order attribution data.
|
||||
*
|
||||
* @param {Object} obj Sourcebuster data object, `sbjs.get`.
|
||||
* @returns
|
||||
* Returns object full of `null`s if tracking is disabled.
|
||||
*
|
||||
* @returns {Object} Schema compatible object.
|
||||
*/
|
||||
wc_order_attribution.sbjsDataToSchema = ( obj ) => ( {
|
||||
type: obj.current.typ,
|
||||
url: obj.current_add.rf,
|
||||
|
||||
utm_campaign: obj.current.cmp,
|
||||
utm_source: obj.current.src,
|
||||
utm_medium: obj.current.mdm,
|
||||
utm_content: obj.current.cnt,
|
||||
utm_id: obj.current.id,
|
||||
utm_term: obj.current.trm,
|
||||
|
||||
session_entry: obj.current_add.ep,
|
||||
session_start_time: obj.current_add.fd,
|
||||
session_pages: obj.session.pgs,
|
||||
session_count: obj.udata.vst,
|
||||
|
||||
user_agent: obj.udata.uag,
|
||||
} );
|
||||
function getData() {
|
||||
const accessor = params.allowTracking ? propertyAccessor : returnNull;
|
||||
const entries = Object.entries( wc_order_attribution.fields )
|
||||
.map( ( [ key, property ] ) => [ key, accessor( sbjs.get, property ) ] );
|
||||
return Object.fromEntries( entries );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the module.
|
||||
* Update `wc_order_attribution` input elements' values.
|
||||
*
|
||||
* @param {Object} values Object containing field values.
|
||||
*/
|
||||
function initOrderTracking() {
|
||||
if ( params.allowTracking === 'no' ) {
|
||||
removeTrackingCookies();
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize sourcebuster.js.
|
||||
*/
|
||||
sbjs.init( {
|
||||
lifetime: Number( params.lifetime ),
|
||||
session_length: Number( params.session ),
|
||||
timezone_offset: '0', // utc
|
||||
} );
|
||||
|
||||
/**
|
||||
* Callback to set visitor source values in the checkout
|
||||
* and register forms using sourcebuster object values.
|
||||
* More info at https://sbjs.rocks/#/usage.
|
||||
*/
|
||||
const setFields = () => {
|
||||
|
||||
if ( sbjs.get ) {
|
||||
for( const [ key, value ] of Object.entries( wc_order_attribution.sbjsDataToSchema( sbjs.get ) ) ) {
|
||||
$( `input[name="${params.prefix}${key}"]` ).value = value;
|
||||
}
|
||||
function updateFormValues( values ) {
|
||||
// Update inputs if any exist.
|
||||
if( $( `input[name^="${params.prefix}"]` ) ) {
|
||||
for( const key of Object.keys( wc_order_attribution.fields ) ) {
|
||||
$( `input[name="${params.prefix}${key}"]` ).value = values && values[ key ] || '';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add source values to the classic checkout form.
|
||||
*/
|
||||
if ( $( 'form.woocommerce-checkout' ) !== null ) {
|
||||
const previousInitCheckout = document.body.oninit_checkout;
|
||||
document.body.oninit_checkout = () => {
|
||||
setFields();
|
||||
previousInitCheckout && previousInitCheckout();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Add source values to register form.
|
||||
*/
|
||||
if ( $( '.woocommerce form.register' ) !== null ) {
|
||||
setFields();
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Checkout extension data.
|
||||
*
|
||||
* @param {Object} values Object containing field values.
|
||||
*/
|
||||
function updateCheckoutBlockData( values ) {
|
||||
// Update Checkout block data if available.
|
||||
if ( window.wp && window.wp.data && window.wp.data.dispatch && window.wc && window.wc.wcBlocksData ) {
|
||||
window.wp.data.dispatch( window.wc.wcBlocksData.CHECKOUT_STORE_KEY ).__internalSetExtensionData(
|
||||
'woocommerce/order-attribution',
|
||||
values,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable order tracking analytics and marketing consent init and change.
|
||||
* Initialize sourcebuster & set data, or clear cookies & data.
|
||||
*
|
||||
* @param {boolean} allow Whether to allow tracking or disable it.
|
||||
*/
|
||||
wc_order_attribution.setAllowTrackingConsent = ( allow ) => {
|
||||
wc_order_attribution.setOrderTracking = function( allow ) {
|
||||
params.allowTracking = allow;
|
||||
if ( ! allow ) {
|
||||
return;
|
||||
// Reset cookies, and clear form data.
|
||||
removeTrackingCookies();
|
||||
} else {
|
||||
// If not done yet, initialize sourcebuster.js which populates `sbjs.get` object.
|
||||
sbjs.init( {
|
||||
lifetime: Number( params.lifetime ),
|
||||
session_length: Number( params.session ),
|
||||
timezone_offset: '0', // utc
|
||||
} );
|
||||
}
|
||||
|
||||
params.allowTracking = 'yes';
|
||||
initOrderTracking();
|
||||
const values = getData();
|
||||
updateFormValues( values );
|
||||
updateCheckoutBlockData( values );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,6 +103,37 @@
|
||||
}
|
||||
|
||||
// Run init.
|
||||
initOrderTracking();
|
||||
wc_order_attribution.setOrderTracking( params.allowTracking );
|
||||
|
||||
// Wait for (async) classic checkout initialization and set source values once loaded.
|
||||
if ( $( 'form.woocommerce-checkout' ) !== null ) {
|
||||
const previousInitCheckout = document.body.oninit_checkout;
|
||||
document.body.oninit_checkout = () => {
|
||||
updateFormValues( getData() );
|
||||
previousInitCheckout && previousInitCheckout();
|
||||
};
|
||||
}
|
||||
|
||||
// Work around the lack of explicit script dependency for the checkout block.
|
||||
// Conditionally, wait for and use 'wp-data' & 'wc-blocks-checkout.
|
||||
|
||||
// Wait for (async) block checkout initialization and set source values once loaded.
|
||||
function eventuallyInitializeCheckoutBlock() {
|
||||
if (
|
||||
window.wp && window.wp.data && typeof window.wp.data.subscribe === 'function'
|
||||
) {
|
||||
// Update checkout block data once more if the checkout store was loaded after this script.
|
||||
const unsubscribe = window.wp.data.subscribe( function () {
|
||||
unsubscribe();
|
||||
updateCheckoutBlockData( getData() );
|
||||
}, CHECKOUT_STORE_KEY );
|
||||
}
|
||||
};
|
||||
// Wait for DOMContentLoaded to make sure wp.data is in place, if applicable for the page.
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", eventuallyInitializeCheckoutBlock);
|
||||
} else {
|
||||
eventuallyInitializeCheckoutBlock();
|
||||
}
|
||||
|
||||
}( window.wc_order_attribution ) );
|
||||
|
||||
@@ -1 +1 @@
|
||||
!function(t){"use strict";const e=t.params,s=document.querySelector.bind(document);function n(){if("no"===e.allowTracking)return void function(){const t=window.location.hostname;["sbjs_current","sbjs_current_add","sbjs_first","sbjs_first_add","sbjs_session","sbjs_udata","sbjs_migrations","sbjs_promo"].forEach(e=>{document.cookie=`${e}=; path=/; max-age=-999; domain=.${t};`})}();sbjs.init({lifetime:Number(e.lifetime),session_length:Number(e.session),timezone_offset:"0"});const n=()=>{if(sbjs.get)for(const[n,o]of Object.entries(t.sbjsDataToSchema(sbjs.get)))s(`input[name="${e.prefix}${n}"]`).value=o};if(null!==s("form.woocommerce-checkout")){const t=document.body.oninit_checkout;document.body.oninit_checkout=(()=>{n(),t&&t()})}null!==s(".woocommerce form.register")&&n()}t.sbjsDataToSchema=(t=>({type:t.current.typ,url:t.current_add.rf,utm_campaign:t.current.cmp,utm_source:t.current.src,utm_medium:t.current.mdm,utm_content:t.current.cnt,utm_id:t.current.id,utm_term:t.current.trm,session_entry:t.current_add.ep,session_start_time:t.current_add.fd,session_pages:t.session.pgs,session_count:t.udata.vst,user_agent:t.udata.uag})),t.setAllowTrackingConsent=(t=>{t&&(e.allowTracking="yes",n())}),n()}(window.wc_order_attribution);
|
||||
!function(n){"use strict";const t=n.params,o=document.querySelector.bind(document),e=(n,t)=>t.split(".").reduce((n,t)=>n&&n[t],n),i=()=>null,c="wc/store/checkout";function s(){const o=t.allowTracking?e:i,c=Object.entries(n.fields).map(([n,t])=>[n,o(sbjs.get,t)]);return Object.fromEntries(c)}function a(e){if(o(`input[name^="${t.prefix}"]`))for(const i of Object.keys(n.fields))o(`input[name="${t.prefix}${i}"]`).value=e&&e[i]||""}function d(n){window.wp&&window.wp.data&&window.wp.data.dispatch&&window.wc&&window.wc.wcBlocksData&&window.wp.data.dispatch(window.wc.wcBlocksData.CHECKOUT_STORE_KEY).__internalSetExtensionData("woocommerce/order-attribution",n,!0)}if(n.setOrderTracking=function(n){t.allowTracking=n,n?sbjs.init({lifetime:Number(t.lifetime),session_length:Number(t.session),timezone_offset:"0"}):function(){const n=window.location.hostname;["sbjs_current","sbjs_current_add","sbjs_first","sbjs_first_add","sbjs_session","sbjs_udata","sbjs_migrations","sbjs_promo"].forEach(t=>{document.cookie=`${t}=; path=/; max-age=-999; domain=.${n};`})}();const o=s();a(o),d(o)},n.setOrderTracking(t.allowTracking),null!==o("form.woocommerce-checkout")){const n=document.body.oninit_checkout;document.body.oninit_checkout=(()=>{a(s()),n&&n()})}function r(){if(window.wp&&window.wp.data&&"function"==typeof window.wp.data.subscribe){const n=window.wp.data.subscribe(function(){n(),d(s())},c)}}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",r):r()}(window.wc_order_attribution);
|
||||
@@ -1,24 +1,19 @@
|
||||
( function ( $ ) {
|
||||
( function () {
|
||||
'use strict';
|
||||
|
||||
// Check init order attribution on consent change.
|
||||
const CONSENT_CATEGORY_MARKING = 'marketing';
|
||||
// Set order attribution on consent change.
|
||||
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 );
|
||||
}
|
||||
}
|
||||
if ( changedConsentCategory.hasOwnProperty( key ) && key === window.wc_order_attribution.params.consentCategory ) {
|
||||
window.wc_order_attribution.setOrderTracking( changedConsentCategory[ key ] === 'allow' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// 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 );
|
||||
}
|
||||
// Set order attribution as soon as consent type is defined.
|
||||
document.addEventListener( 'wp_consent_type_defined', () => {
|
||||
window.wc_order_attribution.setOrderTracking( wp_has_consent( window.wc_order_attribution.params.consentCategory ) );
|
||||
} );
|
||||
}( jQuery ) );
|
||||
}() );
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
!function(n){"use strict";document.addEventListener("wp_listen_for_consent_change",n=>{const t=n.detail;for(const n in t)t.hasOwnProperty(n)&&"marketing"===n&&"allow"===t[n]&&window.wc_order_attribution.setAllowTrackingConsent(!0)}),n(document).on("wp_consent_type_defined",()=>{wp_has_consent("marketing")&&window.wc_order_attribution.setAllowTrackingConsent(!0)})}(jQuery);
|
||||
!function(){"use strict";document.addEventListener("wp_listen_for_consent_change",t=>{const n=t.detail;for(const t in n)n.hasOwnProperty(t)&&t===window.wc_order_attribution.params.consentCategory&&window.wc_order_attribution.setOrderTracking("allow"===n[t])}),document.addEventListener("wp_consent_type_defined",()=>{window.wc_order_attribution.setOrderTracking(wp_has_consent(window.wc_order_attribution.params.consentCategory))})}();
|
||||
Reference in New Issue
Block a user