PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.83
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.83
51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Woo_Checkout_Place_Order / script.js

script.js in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.83, at includes/widgets/Woo_Checkout_Place_Order/script.js

48 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Woo Checkout Place Order widget behaviour.
3 *
4 * The button carries form="checkout", but WooCommerce's checkout form has no
5 * id - only name="checkout" and class="checkout". An unresolvable form
6 * attribute makes a submit button inert, so a button placed outside the form
7 * did nothing at all. Give the form an id and point the buttons at it.
8 */
9 (function () {
10 'use strict';
11
12 const FORM_ID = 'ka-woo-checkout-form';
13
14 const attach = () => {
15 const buttons = document.querySelectorAll('.ka-woo-checkout-place-order__btn');
16 if (!buttons.length) {
17 return;
18 }
19
20 const form = document.querySelector('form.woocommerce-checkout, form.checkout[name="checkout"]');
21 if (!form) {
22 return;
23 }
24
25 if (!form.id) {
26 form.id = FORM_ID;
27 }
28
29 buttons.forEach((button) => {
30 if (button.form === form) {
31 return;
32 }
33 button.setAttribute('form', form.id);
34 });
35 };
36
37 document.addEventListener('DOMContentLoaded', attach);
38
39 // The checkout markup is re-rendered on every update_order_review call.
40 if (window.jQuery) {
41 window.jQuery(document.body).on('updated_checkout', attach);
42 }
43
44 if (window.elementorFrontend && window.elementorFrontend.hooks) {
45 window.elementorFrontend.hooks.addAction('frontend/element_ready/woo_checkout_place_order.default', attach);
46 }
47 })();
48