@automattic/newspack-blocks 4.9.1 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/modalCheckout.asset.php +1 -1
- package/dist/modalCheckout.js +1 -1
- package/newspack-blocks.php +2 -2
- package/package.json +1 -1
- package/src/modal-checkout/index.js +6 -7
- package/vendor/autoload.php +1 -1
- package/vendor/composer/autoload_real.php +4 -4
- package/vendor/composer/autoload_static.php +2 -2
- package/vendor/composer/installed.php +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.9.2](https://github.com/Automattic/newspack-blocks/compare/v4.9.1...v4.9.2) (2025-04-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* tweak button update functionality for Braintree ([#2104](https://github.com/Automattic/newspack-blocks/issues/2104)) ([0248e82](https://github.com/Automattic/newspack-blocks/commit/0248e82a6a5be4b9dbf9c37fdca706a9cc86cbd0))
|
|
7
|
+
|
|
1
8
|
## [4.9.1](https://github.com/Automattic/newspack-blocks/compare/v4.9.0...v4.9.1) (2025-04-02)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<?php return array('dependencies' => array(), 'version' => '
|
|
1
|
+
<?php return array('dependencies' => array(), 'version' => '6955854535c693191ce0');
|
package/dist/modalCheckout.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const e=(e,t={})=>({...t,action:e}),t=(e,t="np_modal_checkout_interaction")=>{"function"==typeof window.gtag&&e&&window.gtag("event",t,e)},o=e=>{const t=document.getElementById(e),o=!!t&&t.getAttribute("data-order-details");return!!o&&JSON.parse(o)||{}};function c(e){"undefined"!=typeof document&&"function"==typeof e&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}const n=(c="continue")=>{if("function"!=typeof window.gtag)return;const{action_type:n,amount:i,currency:r,product_id:a,product_type:s,recurrence:d,referrer:l,variation_id:u=""}=o("modal-checkout-product-details"),p={action_type:n,amount:i,currency:r,product_id:a,product_type:s,recurrence:d,referrer:l};u&&(p.variation_id=u);const _=e(c,p);t(_)};var i;i=jQuery,c((()=>{if(!i)return void console.warn("jQuery is not available.");const r=newspackBlocksModalCheckout.newspack_class_prefix,a=new CustomEvent("checkout-ready");function s(){i(`.woocommerce-NoticeGroup-checkout, .${r}__inline-error, .woocommerce-error, .woocommerce-message, .wc-block-components-notice-banner, .woocommerce-notices-wrapper`).remove()}function d(n=!0){const i=document.querySelector("#newspack_modal_checkout_container");i.checkoutReady=!0,i.dispatchEvent(a),n&&c((function(){if("function"!=typeof window.gtag)return;const{action_type:c,amount:n,currency:i,product_id:r,product_type:a,recurrence:s,referrer:d,variation_id:l=""}=o("modal-checkout-product-details"),u={action_type:c,amount:n,currency:i,product_id:r,product_type:a,recurrence:s,referrer:d};l&&(u.variation_id=l);const p=e("loaded",u);t(p)}))}if(newspackBlocksModalCheckout.is_checkout_complete){const l=document.querySelector("#newspack_modal_checkout_container");l&&(l.checkoutComplete=!0)}else{function u(){i("#wcpay-express-checkout-button-separator, #wc-stripe-payment-request-button-separator").after('<div class="newspack-ui__word-divider">'+newspackBlocksModalCheckout.divider_text+"</div>");let c=[];const a=i("form.checkout");if(!a.length)return void console.warn("Form is not available");const l=i("form.modal_checkout_coupon"),u=i("form.modal_checkout_nyp"),p=i("#checkout_continue"),_=i("#customer_details"),m=i("#after_customer_details"),h=i(".newspack-wcsg--wrapper");function f(){const e=i('input[name="payment_method"]:checked').val();i(".wc_payment_method").removeClass("selected"),i(".wc_payment_method.payment_method_"+e).addClass("selected")}function g(){let e;if(i.ajax({url:newspackBlocksModalCheckout.ajax_url,method:"POST",async:!1,data:{action:"get_cart_total"},success:t=>{e=t}}),e)return e}if(i('input[name="payment_method"]').change(f),i(document).on("payment_method_selected",f),i(document).on("updated_checkout",f),f(),i(document).on("updated_checkout",(function(){i("#payment .wc_payment_methods").length?i("#after_customer_details > h3").show():i("#after_customer_details > h3").hide()})),i(document).on("updated_checkout",(function(){const e=i("#after_customer_details > .order-review-wrapper");if(!e.length)return;const t=e.clone();i("#after_customer_details").hasClass("transaction-details-expanded")&&i('[id="order_review_heading"]',t).attr("aria-expanded","true"),i("#payment .order-review-wrapper").remove();const o=t.find("table");o.is(".empty")?t.addClass("hidden"):(o.unblock(),t.removeClass("hidden")),i(".payment_methods").after(t)})),i(document).on("click","#order_review_heading",(function(){i(this).attr("aria-expanded",(function(e,t){return"false"===t?"true":"false"})),i("#after_customer_details").toggleClass("transaction-details-expanded")})),i(document).on("updated_checkout",(function(){let e=newspackBlocksModalCheckout.labels.complete_button;if(e)if(i("#place_order").hasClass("button-label-updated")){const t=i("<div>"+e+"</div>");t.find(".cart-price").html(g,(function(){return this.childNodes})),e=t.html(),i("#place_order").html(e),i("#place_order_clone").html(e)}else i("#place_order").addClass("button-label-updated").html(e),i("#place_order_clone").addClass("button-label-updated").html(e)})),h.length){const e=h.find(".newspack-wcsg--gift-toggle input"),t=h.find(".newspack-wcsg--gift-email");e.on("change",(function(){e.is(":checked")?t.addClass("visible"):t.removeClass("visible")}))}function k(e){a.find(".input-text, select, input:checkbox").trigger("validate").trigger("blur");let t=!1;const o=[],c=e=>{const c=i("#"+e.data("id")+"_field");if(c?.length){t||(t=c);const o=c.find(".woocommerce-error");o.length&&o.remove(),c.addClass("woocommerce-invalid").removeClass("woocommerce-valid"),c.append(`<span class="${r}__inline-error">`+e.text()+"</span>"),e.remove()}else e.is("li")||(e=i("<li />").append(e)),o.push(e)};if(s(),0!==e.trimStart().indexOf("<")?c(i("<li />").append(e)):e.includes("<li")?i(e).find("li").each((function(){c(i(this))})):c(i(e)),o.length){t=!1;const e=i('<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout"/>').append(i('<ul class="woocommerce-error" role="alert" />').append(o));a.prepend(e),e.get(0).scrollIntoView({behavior:"smooth"})}t?.length&&(window.scroll({top:t.offset().top-100,left:0,behavior:"smooth"}),t.find("input.input-text, select, input:checkbox").trigger("focus")),C(a),i(document.body).trigger("update_checkout"),i(document.body).trigger("checkout_error",[e])}function w(e){e.preventDefault(),e.stopImmediatePropagation(),v(),n("continue")}function y(e){const t=window.newspack_grecaptcha||{};if(s(),i("#checkout_details").remove(),e)a.attr("data-skip-recaptcha","1"),a.append('<input name="is_validation_only" type="hidden" value="1" />'),"v3"===t?.version&&t.destroy(a.get()),l.length&&l.hide(),u.length&&u.hide(),_.show(),m.hide(),_.find("input").first().focus(),c=function(e,t){const o=i._data(e,"events");return o?t?i._data(e,"events")[t]:o:[]}(a[0],"submit").slice(0),c.forEach((e=>{a.off("submit",e.handler)})),a.on("submit",w);else{a.removeAttr("data-skip-recaptcha");const e=a.find('[name="is_validation_only"]');if(e.length&&e.remove(),t?.render){a.data("newspack-recaptcha","newspack_modal_checkout");const e=()=>{s(),a.get(0).scrollIntoView({behavior:"smooth"})},o=e=>k(e);t.render(a.get(),e,o),i(document).on("updated_checkout",(()=>t.render(a.get(),e,o))),i(document.body).on("checkout_error",(()=>t.render(a.get(),e,o)))}l.length&&l.show(),u.length&&u.show(),_.hide(),m.show(),function(){i("#checkout_details").remove();const e={};a.serializeArray().forEach((t=>{e[t.name]=t.value}));const t=`${newspackBlocksModalCheckout.newspack_class_prefix}__font--xs`,o=[];o.push('<div class="billing-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.billing_details+"</h3>"),(e.billing_first_name||e.billing_last_name)&&o.push(`<p class="${t}">`+e.billing_first_name+" "+e.billing_last_name+"</p>"),e.billing_company&&o.push(`<p class="${t}">`+e.billing_company+"</p>");let c="";if((e.billing_address_1||e.billing_address_2)&&(c=`<p class="${t}">`,e.billing_address_1&&(c+=e.billing_address_1),e.billing_address_2&&(c+=" "+e.billing_address_2),c+="<br>",e.billing_city&&(c+=e.billing_city),e.billing_state&&(c+=", "+e.billing_state),e.billing_postcode&&(c+=" "+e.billing_postcode),c+="<br>",e.billing_country&&(c+=e.billing_country)),o.push(c),e.billing_email&&o.push(`<p class="${t}">`+e.billing_email+"</p>"),o.push("</div>"),e.hasOwnProperty("shipping_address_1")){o.push('<div class="shipping-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.shipping_details+"</h3>");let n="";e.ship_to_different_address?(n=`<p class="${t}">`,e.shipping_address_1&&(n+=e.shipping_address_1),e.shipping_address_2&&(n+=" "+e.shipping_address_2),n+="<br>",e.shipping_city&&(n+=e.shipping_city),e.shipping_state&&(n+=", "+e.shipping_state),e.shipping_postcode&&(n+=" "+e.shipping_postcode),n+="<br>",e.shipping_country&&(n+=e.shipping_country)):n=c,o.push(n),o.push("</div>")}e.hasOwnProperty("newspack_wcsg_is_gift")&&e.hasOwnProperty("wcsg_gift_recipients_email")&&e.newspack_wcsg_is_gift&&e.wcsg_gift_recipients_email&&(o.push('<div class="gift-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.gift_recipient+"</h3>"),o.push(`<p class="${t}">`+e.wcsg_gift_recipients_email+"</p>")),i(".order-details-summary").after('<div id="checkout_details">'+o.join("")+"</div>")}(),a.off("submit",w),c.forEach((e=>{a.on("submit",e.handler)}))}a.triggerHandler("editing_details",[e]),window.scroll({top:0,left:0,behavior:"smooth"})}function v(e=!1,t=(()=>{})){if(!b(a))return console.warn("Unable to block the form"),t(),!1;s();const o=a.find(".woocommerce-NoticeGroup.woocommerce-NoticeGroup-checkout");o.length&&o.remove();const c=["save_user_in_woopay"],d=a.serializeArray().filter((e=>!c.includes(e.name)));d.push({name:"woocommerce_checkout_update_totals",value:"1"}),i.ajax({type:"POST",url:wc_checkout_params.checkout_url,data:d,dataType:"html",success:o=>{let c;try{c=JSON.parse(o)}catch(e){c={messages:'<div class="woocommerce-error">'+wc_checkout_params.i18n_checkout_error+"</div>"}}e||!0!==c.reload?(C(a),c.messages?e||(c.messages?k(c.messages):k(`<div class="${r}__inline-error">`+wc_checkout_params.i18n_checkout_error+"</div>")):(y(!1),i._data(a[0],"events")?.click?.some((e=>"#checkout_back"===e.selector))||a.on("click","#checkout_back",(function(e){e.preventDefault(),y(!0),n("back")}))),t(c)):window.location.reload()},error:(o,c,n)=>{let i="";e||(i='<div class="woocommerce-error">'+(n||wc_checkout_params.i18n_checkout_error)+"</div>",k(i)),t({messages:i})}})}function b(e){return!e.is(".modal-processing")&&(e.find("button[type=submit]").each(((e,t)=>{i(t).attr("disabled",!0)})),e.addClass("modal-processing"),!0)}function C(e){return!!e.is(".modal-processing")&&(e.find("button[type=submit]").each(((e,t)=>{i(t).attr("disabled",!1)})),e.removeClass("modal-processing"),!0)}p.length?(y(!0),h.length?d():v(!0,d)):d(),l.length&&(l.on("submit",(function(e){if(e.preventDefault(),!b(l))return!1;const t={security:wc_checkout_params.apply_coupon_nonce,coupon_code:l.find('input[name="coupon_code"]').val()};i.ajax({type:"POST",url:wc_checkout_params.wc_ajax_url.toString().replace("%%endpoint%%","apply_coupon"),data:t,dataType:"html",success:e=>{if(s(),l.find(".result").remove(),e){const o=e.includes("error");l.append(`<p class="result ${r}__helper-text ${o?r+"__inline-error":""}">`+i(e).text()+"</p>"),o?(l.find('input[name="coupon_code"]').focus(),l.find('h3, input[name="coupon_code"]').addClass("newspack-ui__field-error")):(l.find('input[name="coupon_code"]').focus(),l.find('h3, input[name="coupon_code"]').removeClass("newspack-ui__field-error")),i(document.body).trigger("applied_coupon_in_checkout",[t.coupon_code]),i(document.body).trigger("update_checkout",{update_shipping_method:!1})}},complete:()=>{C(l)}})})),i(document.body).on("removed_coupon_in_checkout",(()=>{s(),l.find(".result").remove(),l.find('input[name="coupon_code"]').val("").focus()}))),u.length&&u.on("submit",(function(e){if(e.preventDefault(),!b(u))return!1;const t=u.find('input[name="price"]');t.attr("disabled",!0);const o={_ajax_nonce:newspackBlocksModalCheckout.nyp_nonce,action:"process_name_your_price_request",price:u.find('input[name="price"]').val(),product_id:u.find('input[name="product_id"]').val(),newspack_checkout_name_your_price:u.find('input[name="newspack_checkout_name_your_price"]').val()};i.ajax({type:"POST",url:newspackBlocksModalCheckout.ajax_url,data:o,success:({success:e,data:t})=>{s(),u.find(".result").remove(),u.append(`<p class="result ${r}__helper-text ${e?"":r+"__inline-error"}">`+t.message+"</p>"),e?u.find('h3, input[name="price"]').removeClass("newspack-ui__field-error"):(u.find('input[name="price"]').focus(),u.find('h3, input[name="price"]').addClass("newspack-ui__field-error")),i(document.body).trigger("update_checkout",{update_shipping_method:!1})},complete:()=>{C(u),t.attr("disabled",!1),t.focus()}})})),a.on("click","#place_order",(function(){(()=>{if("function"!=typeof window.gtag)return;const{action_type:c,amount:n,currency:i,product_id:r,product_type:a,recurrence:s,referrer:d,variation_id:l=""}=o("modal-checkout-product-details"),u={action_type:c,amount:n,currency:i,product_id:r,product_type:a,recurrence:s,referrer:d};l&&(u.variation_id=l);const p=e("form_submission",u);t(p)})()}))}u()}i(document.body).on("checkout_error",(function(){const e=i(".woocommerce-NoticeGroup-checkout, .woocommerce-notices-wrapper");e.length&&e.each(((e,t)=>i(t).addClass(`${r}__notice ${r}__notice--error`)));const t=i("#checkout_error_back");t.length&&t.on("click",(e=>{e.preventDefault(),parent.newspackCloseModalCheckout()})),d(!1)})),document.addEventListener("keydown",(function(e){"Escape"===e.key&&parent.newspackCloseModalCheckout()})),newspackBlocksModalCheckout.is_error&&i(document.body).trigger("checkout_error")}))})();
|
|
1
|
+
(()=>{"use strict";const e=(e,t={})=>({...t,action:e}),t=(e,t="np_modal_checkout_interaction")=>{"function"==typeof window.gtag&&e&&window.gtag("event",t,e)},o=e=>{const t=document.getElementById(e),o=!!t&&t.getAttribute("data-order-details");return!!o&&JSON.parse(o)||{}};function c(e){"undefined"!=typeof document&&"function"==typeof e&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}const n=(c="continue")=>{if("function"!=typeof window.gtag)return;const{action_type:n,amount:i,currency:r,product_id:a,product_type:s,recurrence:d,referrer:l,variation_id:u=""}=o("modal-checkout-product-details"),p={action_type:n,amount:i,currency:r,product_id:a,product_type:s,recurrence:d,referrer:l};u&&(p.variation_id=u);const _=e(c,p);t(_)};var i;i=jQuery,c((()=>{if(!i)return void console.warn("jQuery is not available.");const r=newspackBlocksModalCheckout.newspack_class_prefix,a=new CustomEvent("checkout-ready");function s(){i(`.woocommerce-NoticeGroup-checkout, .${r}__inline-error, .woocommerce-error, .woocommerce-message, .wc-block-components-notice-banner, .woocommerce-notices-wrapper`).remove()}function d(n=!0){const i=document.querySelector("#newspack_modal_checkout_container");i.checkoutReady=!0,i.dispatchEvent(a),n&&c((function(){if("function"!=typeof window.gtag)return;const{action_type:c,amount:n,currency:i,product_id:r,product_type:a,recurrence:s,referrer:d,variation_id:l=""}=o("modal-checkout-product-details"),u={action_type:c,amount:n,currency:i,product_id:r,product_type:a,recurrence:s,referrer:d};l&&(u.variation_id=l);const p=e("loaded",u);t(p)}))}if(newspackBlocksModalCheckout.is_checkout_complete){const l=document.querySelector("#newspack_modal_checkout_container");l&&(l.checkoutComplete=!0)}else{function u(){i("#wcpay-express-checkout-button-separator, #wc-stripe-payment-request-button-separator").after('<div class="newspack-ui__word-divider">'+newspackBlocksModalCheckout.divider_text+"</div>");let c=[];const a=i("form.checkout");if(!a.length)return void console.warn("Form is not available");const l=i("form.modal_checkout_coupon"),u=i("form.modal_checkout_nyp"),p=i("#checkout_continue"),_=i("#customer_details"),m=i("#after_customer_details"),h=i(".newspack-wcsg--wrapper");function f(){const e=i('input[name="payment_method"]:checked').val();i(".wc_payment_method").removeClass("selected"),i(".wc_payment_method.payment_method_"+e).addClass("selected")}function g(){let e;if(i.ajax({url:newspackBlocksModalCheckout.ajax_url,method:"POST",async:!1,data:{action:"get_cart_total"},success:t=>{e=t}}),e)return e}if(i('input[name="payment_method"]').change(f),i(document).on("payment_method_selected",f),i(document).on("updated_checkout",f),f(),i(document).on("updated_checkout",(function(){i("#payment .wc_payment_methods").length?i("#after_customer_details > h3").show():i("#after_customer_details > h3").hide()})),i(document).on("updated_checkout",(function(){const e=i("#after_customer_details > .order-review-wrapper");if(!e.length)return;const t=e.clone();i("#after_customer_details").hasClass("transaction-details-expanded")&&i('[id="order_review_heading"]',t).attr("aria-expanded","true"),i("#payment .order-review-wrapper").remove();const o=t.find("table");o.is(".empty")?t.addClass("hidden"):(o.unblock(),t.removeClass("hidden")),i(".payment_methods").after(t)})),i(document).on("click","#order_review_heading",(function(){i(this).attr("aria-expanded",(function(e,t){return"false"===t?"true":"false"})),i("#after_customer_details").toggleClass("transaction-details-expanded")})),i(document).on("updated_checkout",(function(){let e=newspackBlocksModalCheckout.labels.complete_button;if(e){if(i("#place_order").has(i("span.cart-price"))){const t=i("<div>"+e+"</div>");t.find(".cart-price").html(g,(function(){return this.childNodes})),e=t.html()}i("#place_order").html(e),i("#place_order_clone").html(e)}})),h.length){const e=h.find(".newspack-wcsg--gift-toggle input"),t=h.find(".newspack-wcsg--gift-email");e.on("change",(function(){e.is(":checked")?t.addClass("visible"):t.removeClass("visible")}))}function k(e){a.find(".input-text, select, input:checkbox").trigger("validate").trigger("blur");let t=!1;const o=[],c=e=>{const c=i("#"+e.data("id")+"_field");if(c?.length){t||(t=c);const o=c.find(".woocommerce-error");o.length&&o.remove(),c.addClass("woocommerce-invalid").removeClass("woocommerce-valid"),c.append(`<span class="${r}__inline-error">`+e.text()+"</span>"),e.remove()}else e.is("li")||(e=i("<li />").append(e)),o.push(e)};if(s(),0!==e.trimStart().indexOf("<")?c(i("<li />").append(e)):e.includes("<li")?i(e).find("li").each((function(){c(i(this))})):c(i(e)),o.length){t=!1;const e=i('<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout"/>').append(i('<ul class="woocommerce-error" role="alert" />').append(o));a.prepend(e),e.get(0).scrollIntoView({behavior:"smooth"})}t?.length&&(window.scroll({top:t.offset().top-100,left:0,behavior:"smooth"}),t.find("input.input-text, select, input:checkbox").trigger("focus")),C(a),i(document.body).trigger("update_checkout"),i(document.body).trigger("checkout_error",[e])}function w(e){e.preventDefault(),e.stopImmediatePropagation(),v(),n("continue")}function y(e){const t=window.newspack_grecaptcha||{};if(s(),i("#checkout_details").remove(),e)a.attr("data-skip-recaptcha","1"),a.append('<input name="is_validation_only" type="hidden" value="1" />'),"v3"===t?.version&&t.destroy(a.get()),l.length&&l.hide(),u.length&&u.hide(),_.show(),m.hide(),_.find("input").first().focus(),c=function(e,t){const o=i._data(e,"events");return o?t?i._data(e,"events")[t]:o:[]}(a[0],"submit").slice(0),c.forEach((e=>{a.off("submit",e.handler)})),a.on("submit",w);else{a.removeAttr("data-skip-recaptcha");const e=a.find('[name="is_validation_only"]');if(e.length&&e.remove(),t?.render){a.data("newspack-recaptcha","newspack_modal_checkout");const e=()=>{s(),a.get(0).scrollIntoView({behavior:"smooth"})},o=e=>k(e);t.render(a.get(),e,o),i(document).on("updated_checkout",(()=>t.render(a.get(),e,o))),i(document.body).on("checkout_error",(()=>t.render(a.get(),e,o)))}l.length&&l.show(),u.length&&u.show(),_.hide(),m.show(),function(){i("#checkout_details").remove();const e={};a.serializeArray().forEach((t=>{e[t.name]=t.value}));const t=`${newspackBlocksModalCheckout.newspack_class_prefix}__font--xs`,o=[];o.push('<div class="billing-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.billing_details+"</h3>"),(e.billing_first_name||e.billing_last_name)&&o.push(`<p class="${t}">`+e.billing_first_name+" "+e.billing_last_name+"</p>"),e.billing_company&&o.push(`<p class="${t}">`+e.billing_company+"</p>");let c="";if((e.billing_address_1||e.billing_address_2)&&(c=`<p class="${t}">`,e.billing_address_1&&(c+=e.billing_address_1),e.billing_address_2&&(c+=" "+e.billing_address_2),c+="<br>",e.billing_city&&(c+=e.billing_city),e.billing_state&&(c+=", "+e.billing_state),e.billing_postcode&&(c+=" "+e.billing_postcode),c+="<br>",e.billing_country&&(c+=e.billing_country)),o.push(c),e.billing_email&&o.push(`<p class="${t}">`+e.billing_email+"</p>"),o.push("</div>"),e.hasOwnProperty("shipping_address_1")){o.push('<div class="shipping-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.shipping_details+"</h3>");let n="";e.ship_to_different_address?(n=`<p class="${t}">`,e.shipping_address_1&&(n+=e.shipping_address_1),e.shipping_address_2&&(n+=" "+e.shipping_address_2),n+="<br>",e.shipping_city&&(n+=e.shipping_city),e.shipping_state&&(n+=", "+e.shipping_state),e.shipping_postcode&&(n+=" "+e.shipping_postcode),n+="<br>",e.shipping_country&&(n+=e.shipping_country)):n=c,o.push(n),o.push("</div>")}e.hasOwnProperty("newspack_wcsg_is_gift")&&e.hasOwnProperty("wcsg_gift_recipients_email")&&e.newspack_wcsg_is_gift&&e.wcsg_gift_recipients_email&&(o.push('<div class="gift-details">'),o.push("<h3>"+newspackBlocksModalCheckout.labels.gift_recipient+"</h3>"),o.push(`<p class="${t}">`+e.wcsg_gift_recipients_email+"</p>")),i(".order-details-summary").after('<div id="checkout_details">'+o.join("")+"</div>")}(),a.off("submit",w),c.forEach((e=>{a.on("submit",e.handler)}))}a.triggerHandler("editing_details",[e]),window.scroll({top:0,left:0,behavior:"smooth"})}function v(e=!1,t=(()=>{})){if(!b(a))return console.warn("Unable to block the form"),t(),!1;s();const o=a.find(".woocommerce-NoticeGroup.woocommerce-NoticeGroup-checkout");o.length&&o.remove();const c=["save_user_in_woopay"],d=a.serializeArray().filter((e=>!c.includes(e.name)));d.push({name:"woocommerce_checkout_update_totals",value:"1"}),i.ajax({type:"POST",url:wc_checkout_params.checkout_url,data:d,dataType:"html",success:o=>{let c;try{c=JSON.parse(o)}catch(e){c={messages:'<div class="woocommerce-error">'+wc_checkout_params.i18n_checkout_error+"</div>"}}e||!0!==c.reload?(C(a),c.messages?e||(c.messages?k(c.messages):k(`<div class="${r}__inline-error">`+wc_checkout_params.i18n_checkout_error+"</div>")):(y(!1),i._data(a[0],"events")?.click?.some((e=>"#checkout_back"===e.selector))||a.on("click","#checkout_back",(function(e){e.preventDefault(),y(!0),n("back")}))),t(c)):window.location.reload()},error:(o,c,n)=>{let i="";e||(i='<div class="woocommerce-error">'+(n||wc_checkout_params.i18n_checkout_error)+"</div>",k(i)),t({messages:i})}})}function b(e){return!e.is(".modal-processing")&&(e.find("button[type=submit]").each(((e,t)=>{i(t).attr("disabled",!0)})),e.addClass("modal-processing"),!0)}function C(e){return!!e.is(".modal-processing")&&(e.find("button[type=submit]").each(((e,t)=>{i(t).attr("disabled",!1)})),e.removeClass("modal-processing"),!0)}p.length?(y(!0),h.length?d():v(!0,d)):d(),l.length&&(l.on("submit",(function(e){if(e.preventDefault(),!b(l))return!1;const t={security:wc_checkout_params.apply_coupon_nonce,coupon_code:l.find('input[name="coupon_code"]').val()};i.ajax({type:"POST",url:wc_checkout_params.wc_ajax_url.toString().replace("%%endpoint%%","apply_coupon"),data:t,dataType:"html",success:e=>{if(s(),l.find(".result").remove(),e){const o=e.includes("error");l.append(`<p class="result ${r}__helper-text ${o?r+"__inline-error":""}">`+i(e).text()+"</p>"),o?(l.find('input[name="coupon_code"]').focus(),l.find('h3, input[name="coupon_code"]').addClass("newspack-ui__field-error")):(l.find('input[name="coupon_code"]').focus(),l.find('h3, input[name="coupon_code"]').removeClass("newspack-ui__field-error")),i(document.body).trigger("applied_coupon_in_checkout",[t.coupon_code]),i(document.body).trigger("update_checkout",{update_shipping_method:!1})}},complete:()=>{C(l)}})})),i(document.body).on("removed_coupon_in_checkout",(()=>{s(),l.find(".result").remove(),l.find('input[name="coupon_code"]').val("").focus()}))),u.length&&u.on("submit",(function(e){if(e.preventDefault(),!b(u))return!1;const t=u.find('input[name="price"]');t.attr("disabled",!0);const o={_ajax_nonce:newspackBlocksModalCheckout.nyp_nonce,action:"process_name_your_price_request",price:u.find('input[name="price"]').val(),product_id:u.find('input[name="product_id"]').val(),newspack_checkout_name_your_price:u.find('input[name="newspack_checkout_name_your_price"]').val()};i.ajax({type:"POST",url:newspackBlocksModalCheckout.ajax_url,data:o,success:({success:e,data:t})=>{s(),u.find(".result").remove(),u.append(`<p class="result ${r}__helper-text ${e?"":r+"__inline-error"}">`+t.message+"</p>"),e?u.find('h3, input[name="price"]').removeClass("newspack-ui__field-error"):(u.find('input[name="price"]').focus(),u.find('h3, input[name="price"]').addClass("newspack-ui__field-error")),i(document.body).trigger("update_checkout",{update_shipping_method:!1})},complete:()=>{C(u),t.attr("disabled",!1),t.focus()}})})),a.on("click","#place_order",(function(){(()=>{if("function"!=typeof window.gtag)return;const{action_type:c,amount:n,currency:i,product_id:r,product_type:a,recurrence:s,referrer:d,variation_id:l=""}=o("modal-checkout-product-details"),u={action_type:c,amount:n,currency:i,product_id:r,product_type:a,recurrence:s,referrer:d};l&&(u.variation_id=l);const p=e("form_submission",u);t(p)})()}))}u()}i(document.body).on("checkout_error",(function(){const e=i(".woocommerce-NoticeGroup-checkout, .woocommerce-notices-wrapper");e.length&&e.each(((e,t)=>i(t).addClass(`${r}__notice ${r}__notice--error`)));const t=i("#checkout_error_back");t.length&&t.on("click",(e=>{e.preventDefault(),parent.newspackCloseModalCheckout()})),d(!1)})),document.addEventListener("keydown",(function(e){"Escape"===e.key&&parent.newspackCloseModalCheckout()})),newspackBlocksModalCheckout.is_error&&i(document.body).trigger("checkout_error")}))})();
|
package/newspack-blocks.php
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Author URI: https://newspack.com/
|
|
8
8
|
* Text Domain: newspack-blocks
|
|
9
9
|
* Domain Path: /languages
|
|
10
|
-
* Version: 4.9.
|
|
10
|
+
* Version: 4.9.2
|
|
11
11
|
*
|
|
12
12
|
* @package Newspack_Blocks
|
|
13
13
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
|
|
16
16
|
define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
|
|
17
17
|
define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
|
|
18
|
-
define( 'NEWSPACK_BLOCKS__VERSION', '4.9.
|
|
18
|
+
define( 'NEWSPACK_BLOCKS__VERSION', '4.9.2' );
|
|
19
19
|
|
|
20
20
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
|
|
21
21
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
|
package/package.json
CHANGED
|
@@ -170,13 +170,16 @@ import { domReady } from './utils';
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Update Place Order button text.
|
|
175
|
+
*/
|
|
173
176
|
$( document ).on( 'updated_checkout', function() {
|
|
174
177
|
// Update "Place Order" button to include current price.
|
|
175
178
|
let processOrderText = newspackBlocksModalCheckout.labels.complete_button;
|
|
176
179
|
if ( ! processOrderText ) {
|
|
177
180
|
return;
|
|
178
181
|
}
|
|
179
|
-
if ( $( '#place_order' ).
|
|
182
|
+
if ( $( '#place_order' ).has( $( 'span.cart-price' ) ) ) {
|
|
180
183
|
// Modify button text to include updated price.
|
|
181
184
|
const tree = $( '<div>' + processOrderText + '</div>' );
|
|
182
185
|
// Update the HTML in the .cart-price span with the new price, and return.
|
|
@@ -184,13 +187,9 @@ import { domReady } from './utils';
|
|
|
184
187
|
return this.childNodes;
|
|
185
188
|
} );
|
|
186
189
|
processOrderText = tree.html();
|
|
187
|
-
$( '#place_order' ).html( processOrderText );
|
|
188
|
-
$( '#place_order_clone' ).html( processOrderText );
|
|
189
|
-
} else {
|
|
190
|
-
// Set default button label passed from PHP.
|
|
191
|
-
$( '#place_order' ).addClass( 'button-label-updated' ).html( processOrderText );
|
|
192
|
-
$( '#place_order_clone' ).addClass( 'button-label-updated' ).html( processOrderText );
|
|
193
190
|
}
|
|
191
|
+
$( '#place_order' ).html( processOrderText );
|
|
192
|
+
$( '#place_order_clone' ).html( processOrderText );
|
|
194
193
|
} );
|
|
195
194
|
|
|
196
195
|
/**
|
package/vendor/autoload.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// autoload_real.php @generated by Composer
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class ComposerAutoloaderInit24dbb65351facec32b640555ffad9986
|
|
6
6
|
{
|
|
7
7
|
private static $loader;
|
|
8
8
|
|
|
@@ -22,12 +22,12 @@ class ComposerAutoloaderInitb0d9edd8849fedd7b5cd47883fc7dd6b
|
|
|
22
22
|
return self::$loader;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
spl_autoload_register(array('
|
|
25
|
+
spl_autoload_register(array('ComposerAutoloaderInit24dbb65351facec32b640555ffad9986', 'loadClassLoader'), true, true);
|
|
26
26
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
|
27
|
-
spl_autoload_unregister(array('
|
|
27
|
+
spl_autoload_unregister(array('ComposerAutoloaderInit24dbb65351facec32b640555ffad9986', 'loadClassLoader'));
|
|
28
28
|
|
|
29
29
|
require __DIR__ . '/autoload_static.php';
|
|
30
|
-
call_user_func(\Composer\Autoload\
|
|
30
|
+
call_user_func(\Composer\Autoload\ComposerStaticInit24dbb65351facec32b640555ffad9986::getInitializer($loader));
|
|
31
31
|
|
|
32
32
|
$loader->register(true);
|
|
33
33
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
namespace Composer\Autoload;
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class ComposerStaticInit24dbb65351facec32b640555ffad9986
|
|
8
8
|
{
|
|
9
9
|
public static $classMap = array (
|
|
10
10
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
|
@@ -13,7 +13,7 @@ class ComposerStaticInitb0d9edd8849fedd7b5cd47883fc7dd6b
|
|
|
13
13
|
public static function getInitializer(ClassLoader $loader)
|
|
14
14
|
{
|
|
15
15
|
return \Closure::bind(function () use ($loader) {
|
|
16
|
-
$loader->classMap =
|
|
16
|
+
$loader->classMap = ComposerStaticInit24dbb65351facec32b640555ffad9986::$classMap;
|
|
17
17
|
|
|
18
18
|
}, null, ClassLoader::class);
|
|
19
19
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'name' => 'automattic/newspack-blocks',
|
|
4
4
|
'pretty_version' => 'dev-trunk',
|
|
5
5
|
'version' => 'dev-trunk',
|
|
6
|
-
'reference' => '
|
|
6
|
+
'reference' => '0248e82a6a5be4b9dbf9c37fdca706a9cc86cbd0',
|
|
7
7
|
'type' => 'wordpress-plugin',
|
|
8
8
|
'install_path' => __DIR__ . '/../../',
|
|
9
9
|
'aliases' => array(),
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
'automattic/newspack-blocks' => array(
|
|
14
14
|
'pretty_version' => 'dev-trunk',
|
|
15
15
|
'version' => 'dev-trunk',
|
|
16
|
-
'reference' => '
|
|
16
|
+
'reference' => '0248e82a6a5be4b9dbf9c37fdca706a9cc86cbd0',
|
|
17
17
|
'type' => 'wordpress-plugin',
|
|
18
18
|
'install_path' => __DIR__ . '/../../',
|
|
19
19
|
'aliases' => array(),
|