plugin updates
This commit is contained in:
@@ -501,13 +501,13 @@ jQuery( function( $ ) {
|
||||
var maybe_valid_json = raw_response.match( /{"result.*}/ );
|
||||
|
||||
if ( null === maybe_valid_json ) {
|
||||
console.log( 'Unable to fix malformed JSON' );
|
||||
console.log( 'Unable to fix malformed JSON #1' );
|
||||
} else if ( wc_checkout_form.is_valid_json( maybe_valid_json[0] ) ) {
|
||||
console.log( 'Fixed malformed JSON. Original:' );
|
||||
console.log( raw_response );
|
||||
raw_response = maybe_valid_json[0];
|
||||
} else {
|
||||
console.log( 'Unable to fix malformed JSON' );
|
||||
console.log( 'Unable to fix malformed JSON #2' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,10 +560,21 @@ jQuery( function( $ ) {
|
||||
// Detach the unload handler that prevents a reload / redirect
|
||||
wc_checkout_form.detachUnloadEventsOnSubmit();
|
||||
|
||||
// This is just a technical error fallback. i18_checkout_error is expected to be always defined and localized.
|
||||
var errorMessage = errorThrown;
|
||||
|
||||
if (
|
||||
typeof wc_checkout_params === 'object' &&
|
||||
wc_checkout_params !== null &&
|
||||
wc_checkout_params.hasOwnProperty( 'i18n_checkout_error' ) &&
|
||||
typeof wc_checkout_params.i18n_checkout_error === 'string' &&
|
||||
wc_checkout_params.i18n_checkout_error.trim() !== ''
|
||||
) {
|
||||
errorMessage = wc_checkout_params.i18n_checkout_error;
|
||||
}
|
||||
|
||||
wc_checkout_form.submit_error(
|
||||
'<div class="woocommerce-error">' +
|
||||
( errorThrown || wc_checkout_params.i18n_checkout_error ) +
|
||||
'</div>'
|
||||
'<div class="woocommerce-error">' + errorMessage + '</div>'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -65,6 +65,8 @@
|
||||
if ( ! allow ) {
|
||||
// Reset cookies, and clear form data.
|
||||
removeTrackingCookies();
|
||||
} else if ( typeof sbjs === 'undefined' ) {
|
||||
return; // Do nothing, as sourcebuster.js is not loaded.
|
||||
} else {
|
||||
// If not done yet, initialize sourcebuster.js which populates `sbjs.get` object.
|
||||
sbjs.init( {
|
||||
@@ -153,12 +155,16 @@
|
||||
* but it's not yet supported in Safari.
|
||||
*/
|
||||
connectedCallback() {
|
||||
let inputs = '';
|
||||
this.innerHTML = '';
|
||||
const inputs = new DocumentFragment();
|
||||
for( const fieldName of this._fieldNames ) {
|
||||
const value = stringifyFalsyInputValue( this.values[ fieldName ] );
|
||||
inputs += `<input type="hidden" name="${params.prefix}${fieldName}" value="${value}"/>`;
|
||||
const input = document.createElement( 'input' );
|
||||
input.type = 'hidden';
|
||||
input.name = `${params.prefix}${fieldName}`;
|
||||
input.value = stringifyFalsyInputValue( ( this.values && this.values[ fieldName ] ) || '' );
|
||||
inputs.appendChild( input );
|
||||
}
|
||||
this.innerHTML = inputs;
|
||||
this.appendChild( inputs );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1 +1 @@
|
||||
!function(t){"use strict";const e=t.params,n=(document.querySelector.bind(document),(t,e)=>e.split(".").reduce((t,e)=>t&&t[e],t)),s=()=>null,i=t=>null===t||t===undefined?"":t,o="wc/store/checkout";function a(){const i=e.allowTracking?n:s,o=Object.entries(t.fields).map(([t,e])=>[t,i(sbjs.get,e)]);return Object.fromEntries(o)}function c(t){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",t,!0)}function r(){if(window.wp&&window.wp.data&&"function"==typeof window.wp.data.subscribe){const t=window.wp.data.subscribe(function(){t(),c(a())},o)}}t.setOrderTracking=function(t){e.allowTracking=t,t?sbjs.init({lifetime:Number(e.lifetime),session_length:Number(e.session),timezone_offset:"0"}):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};`})}();const n=a();!function(t){for(const e of document.querySelectorAll("wc-order-attribution-inputs"))e.values=t}(n),c(n)},t.setOrderTracking(e.allowTracking),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",r):r(),window.customElements.define("wc-order-attribution-inputs",class extends HTMLElement{constructor(){if(super(),this._fieldNames=Object.keys(t.fields),this.hasOwnProperty("_values")){let t=this.values;delete this.values,this.values=t||{}}}connectedCallback(){let t="";for(const n of this._fieldNames){const s=i(this.values[n]);t+=`<input type="hidden" name="${e.prefix}${n}" value="${s}"/>`}this.innerHTML=t}set values(t){if(this._values=t,this.isConnected)for(const t of this._fieldNames){const n=this.querySelector(`input[name="${e.prefix}${t}"]`);n?n.value=i(this.values[t]):console.warn(`Field "${t}" not found. Most likely, the '<wc-order-attribution-inputs>' element was manipulated.`)}}get values(){return this._values}})}(window.wc_order_attribution);
|
||||
!function(e){"use strict";const t=e.params,n=(document.querySelector.bind(document),(e,t)=>t.split(".").reduce((e,t)=>e&&e[t],e)),s=()=>null,i=e=>null===e||e===undefined?"":e,o="wc/store/checkout";function a(){const i=t.allowTracking?n:s,o=Object.entries(e.fields).map(([e,t])=>[e,i(sbjs.get,t)]);return Object.fromEntries(o)}function c(e){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",e,!0)}function r(){if(window.wp&&window.wp.data&&"function"==typeof window.wp.data.subscribe){const e=window.wp.data.subscribe(function(){e(),c(a())},o)}}e.setOrderTracking=function(e){if(t.allowTracking=e,e){if("undefined"==typeof sbjs)return;sbjs.init({lifetime:Number(t.lifetime),session_length:Number(t.session),timezone_offset:"0"})}else!function(){const e=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=.${e};`})}();const n=a();!function(e){for(const t of document.querySelectorAll("wc-order-attribution-inputs"))t.values=e}(n),c(n)},e.setOrderTracking(t.allowTracking),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",r):r(),window.customElements.define("wc-order-attribution-inputs",class extends HTMLElement{constructor(){if(super(),this._fieldNames=Object.keys(e.fields),this.hasOwnProperty("_values")){let e=this.values;delete this.values,this.values=e||{}}}connectedCallback(){this.innerHTML="";const e=new DocumentFragment;for(const n of this._fieldNames){const s=document.createElement("input");s.type="hidden",s.name=`${t.prefix}${n}`,s.value=i(this.values&&this.values[n]||""),e.appendChild(s)}this.appendChild(e)}set values(e){if(this._values=e,this.isConnected)for(const e of this._fieldNames){const n=this.querySelector(`input[name="${t.prefix}${e}"]`);n?n.value=i(this.values[e]):console.warn(`Field "${e}" not found. Most likely, the '<wc-order-attribution-inputs>' element was manipulated.`)}}get values(){return this._values}})}(window.wc_order_attribution);
|
||||
@@ -99,4 +99,24 @@ jQuery( function( $ ) {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$( 'a.coming-soon-footer-banner-dismiss' ).on( 'click', function( e ) {
|
||||
var target = $( e.target );
|
||||
$.ajax( {
|
||||
type: 'post',
|
||||
url: target.data( 'rest-url' ),
|
||||
data: {
|
||||
meta: {
|
||||
'woocommerce_coming_soon_banner_dismissed': 'yes'
|
||||
}
|
||||
},
|
||||
beforeSend: function ( xhr ) {
|
||||
xhr.setRequestHeader( 'X-WP-Nonce', target.data( 'rest-nonce' ) );
|
||||
},
|
||||
complete: function () {
|
||||
$('#coming-soon-footer-banner').hide();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
jQuery(function(o){o(".woocommerce-ordering").on("change","select.orderby",function(){o(this).closest("form").trigger("submit")}),o("input.qty:not(.product-quantity input.qty)").each(function(){var e=parseFloat(o(this).attr("min"));e>=0&&parseFloat(o(this).val())<e&&o(this).val(e)});var e="store_notice"+(o(".woocommerce-store-notice").data("noticeId")||"");"hidden"===Cookies.get(e)?o(".woocommerce-store-notice").hide():o(".woocommerce-store-notice").show(),o(".woocommerce-store-notice__dismiss-link").on("click",function(s){Cookies.set(e,"hidden",{path:"/"}),o(".woocommerce-store-notice").hide(),s.preventDefault()}),o(".woocommerce-input-wrapper span.description").length&&o(document.body).on("click",function(){o(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),o(".woocommerce-input-wrapper").on("click",function(o){o.stopPropagation()}),o(".woocommerce-input-wrapper :input").on("keydown",function(e){var s=o(this).parent().find("span.description");if(27===e.which&&s.length&&s.is(":visible"))return s.prop("aria-hidden",!0).slideUp(250),e.preventDefault(),!1}).on("click focus",function(){var e=o(this).parent(),s=e.find("span.description");e.addClass("currentTarget"),o(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),s.length&&s.is(":hidden")&&s.prop("aria-hidden",!1).slideDown(250),e.removeClass("currentTarget")}),o.scroll_to_notices=function(e){e.length&&o("html, body").animate({scrollTop:e.offset().top-100},1e3)},o('.woocommerce form .woocommerce-Input[type="password"]').wrap('<span class="password-input"></span>'),o(".woocommerce form input").filter(":password").parent("span").addClass("password-input"),o(".password-input").append('<span class="show-password-input"></span>'),o(".show-password-input").on("click",function(){o(this).hasClass("display-password")?o(this).removeClass("display-password"):o(this).addClass("display-password"),o(this).hasClass("display-password")?o(this).siblings(['input[type="password"]']).prop("type","text"):o(this).siblings('input[type="text"]').prop("type","password")})});
|
||||
jQuery(function(o){o(".woocommerce-ordering").on("change","select.orderby",function(){o(this).closest("form").trigger("submit")}),o("input.qty:not(.product-quantity input.qty)").each(function(){var e=parseFloat(o(this).attr("min"));e>=0&&parseFloat(o(this).val())<e&&o(this).val(e)});var e="store_notice"+(o(".woocommerce-store-notice").data("noticeId")||"");"hidden"===Cookies.get(e)?o(".woocommerce-store-notice").hide():o(".woocommerce-store-notice").show(),o(".woocommerce-store-notice__dismiss-link").on("click",function(s){Cookies.set(e,"hidden",{path:"/"}),o(".woocommerce-store-notice").hide(),s.preventDefault()}),o(".woocommerce-input-wrapper span.description").length&&o(document.body).on("click",function(){o(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),o(".woocommerce-input-wrapper").on("click",function(o){o.stopPropagation()}),o(".woocommerce-input-wrapper :input").on("keydown",function(e){var s=o(this).parent().find("span.description");if(27===e.which&&s.length&&s.is(":visible"))return s.prop("aria-hidden",!0).slideUp(250),e.preventDefault(),!1}).on("click focus",function(){var e=o(this).parent(),s=e.find("span.description");e.addClass("currentTarget"),o(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),s.length&&s.is(":hidden")&&s.prop("aria-hidden",!1).slideDown(250),e.removeClass("currentTarget")}),o.scroll_to_notices=function(e){e.length&&o("html, body").animate({scrollTop:e.offset().top-100},1e3)},o('.woocommerce form .woocommerce-Input[type="password"]').wrap('<span class="password-input"></span>'),o(".woocommerce form input").filter(":password").parent("span").addClass("password-input"),o(".password-input").append('<span class="show-password-input"></span>'),o(".show-password-input").on("click",function(){o(this).hasClass("display-password")?o(this).removeClass("display-password"):o(this).addClass("display-password"),o(this).hasClass("display-password")?o(this).siblings(['input[type="password"]']).prop("type","text"):o(this).siblings('input[type="text"]').prop("type","password")}),o("a.coming-soon-footer-banner-dismiss").on("click",function(e){var s=o(e.target);o.ajax({type:"post",url:s.data("rest-url"),data:{meta:{woocommerce_coming_soon_banner_dismissed:"yes"}},beforeSend:function(o){o.setRequestHeader("X-WP-Nonce",s.data("rest-nonce"))},complete:function(){o("#coming-soon-footer-banner").hide()}})})});
|
||||
Reference in New Issue
Block a user