PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 2.7.0
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v2.7.0
2.7.0 2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 All 43 releases
← All changes | assets/dist/js/elementor-init.js +430 -104 1.6.22.7.0 View file →
@@ -3,18 +3,81 @@
3 3
4 4 Object.defineProperty(exports, "__esModule", {
5 5 value: true
6 6 });
7 +exports["default"] = void 0;
8 +var CheckoutSettings = elementorModules.frontend.handlers.Base.extend({
9 + getDefaultSettings: function getDefaultSettings() {
10 + return {
11 + selectors: {
12 + sticky: '.sellkit-multistep-checkout-sidebar-sticky'
13 + }
14 + };
15 + },
16 + getDefaultElements: function getDefaultElements() {
17 + var selectors = this.getSettings('selectors');
18 + return {
19 + $stickyContainer: this.$element.find(selectors.sticky)
20 + };
21 + },
22 + onInit: function onInit() {
23 + elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments);
24 + this.setOffset();
25 + },
26 + setOffset: function setOffset() {
27 + if (this.getElementSettings('show_sticky_cart_details') !== 'yes') {
28 + return;
29 + }
30 +
31 + var offset = this.getElementSettings('sticky_cart_offset') || 0;
32 +
33 + if (offset === 0) {
34 + return;
35 + }
36 +
37 + var adminbar = document.getElementById('wpadminbar');
38 +
39 + if (!_.isNull(adminbar)) {
40 + offset += adminbar.offsetHeight;
41 + }
42 +
43 + this.elements.$stickyContainer.css('top', "".concat(offset, "px"));
44 + }
45 +});
46 +var _default = CheckoutSettings;
7 47 exports["default"] = _default;
8 48
49 +},{}],2:[function(require,module,exports){
50 +"use strict";
51 +
52 +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
53 +
54 +Object.defineProperty(exports, "__esModule", {
55 + value: true
56 +});
57 +exports["default"] = _default;
58 +
9 59 var _i18n = require("@wordpress/i18n");
10 60
61 +var _checkoutSettings = _interopRequireDefault(require("./checkout-settings"));
62 +
11 63 /* eslint no-undef: 0 */
12 64 // Temporary turned off no undefined variable for localStorage
13 65 var $ = jQuery;
14 66 var wcCountries = JSON.parse(wc_country_select_params.countries);
67 +/**
68 + * When batching "same as shipping" billing sync, skip duplicate sellkit address AJAX
69 + * (avoids racing update_checkout / fragment refresh against hidden country/state fields).
70 + *
71 + * @type {boolean}
72 + */
15 73
16 -function _default() {
74 +window.sellkitSuppressBillingAddressAjax = false;
75 +
76 +function _default($scope) {
77 + new _checkoutSettings["default"]({
78 + $element: $scope
79 + });
17 80 $('body').addClass('contains-sellkit-checkout'); // General class to handle compatibility with other themes.
18 81
19 82 var parent = $('#sellkit-checkout-multistep-inner-wrap');
20 83 var sidebar = $('.sellkit-checkout-right-column');
@@ -41,9 +104,8 @@
41 104 return;
42 105 }
43 106
44 107 secondStepHeader();
45 - var secondTrigger = true;
46 108 first.hide();
47 109
48 110 if ($('.sellkit-one-page-shipping-methods').children().length > 0) {
49 111 second.show();
@@ -48,13 +110,8 @@
48 110 if ($('.sellkit-one-page-shipping-methods').children().length > 0) {
49 111 second.show();
50 112 } else {
51 113 third.show();
52 - secondTrigger = false;
53 - }
54 -
55 - if ($(window).width() > 600 && secondTrigger) {
56 - sidebar.css('background-color', '#effdf5');
57 114 } //Fix Header & wrapper height.
58 115
59 116
60 117 parent.css('height', 'auto');
@@ -63,8 +120,11 @@
63 120 $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
64 121
65 122 breadcrumb.find('.information').removeClass('current').addClass('blue-line');
66 123 breadcrumb.find('.shipping').addClass('current').removeClass('inactive');
124 + $('html, body').animate({
125 + scrollTop: $('.sellkit-checkout-left-column').offset().top
126 + }, 500);
67 127 });
68 128 $('.go-to-first').on('click', function () {
69 129 first.show();
70 130 third.hide();
@@ -74,8 +134,11 @@
74 134 sidebar.css('background-color', 'transparent'); // Manage Breadcrumb.
75 135
76 136 breadcrumb.find('.information').removeClass('blue-line').addClass('current');
77 137 breadcrumb.find('.shipping, .payment').removeClass('current').removeClass('blue-line').addClass('inactive');
138 + $('html, body').animate({
139 + scrollTop: $('.sellkit-checkout-left-column').offset().top
140 + }, 500);
78 141 });
79 142 $('.go-to-payment').on('click', function () {
80 143 // Checks if required fields are filled.
81 144 var requiredFieldsError = checkRequiredFields();
@@ -96,8 +159,11 @@
96 159 $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
97 160
98 161 breadcrumb.find('.shipping').addClass('blue-line').removeClass('current');
99 162 breadcrumb.find('.payment').addClass('current').removeClass('inactive');
163 + $('html, body').animate({
164 + scrollTop: $('.sellkit-checkout-left-column').offset().top
165 + }, 500);
100 166 });
101 167 $('.go-to-second , .go-to-second-header').on('click', function () {
102 168 // Checks if required fields are filled.
103 169 var requiredFieldsError = checkRequiredFields();
@@ -105,10 +171,8 @@
105 171 if (true === requiredFieldsError) {
106 172 return;
107 173 }
108 174
109 - var secondTrigger = true;
110 -
111 175 if ($('.sellkit-one-page-shipping-methods').children().length > 0) {
112 176 second.show();
113 177 first.hide();
114 178 } else {
@@ -113,9 +177,8 @@
113 177 first.hide();
114 178 } else {
115 179 second.hide();
116 180 first.show();
117 - secondTrigger = false;
118 181 }
119 182
120 183 third.hide();
121 184 parent.css('height', 'auto');
@@ -120,17 +183,15 @@
120 183 third.hide();
121 184 parent.css('height', 'auto');
122 185 second.css('height', 'auto');
123 186 second.css('height', $('.sellkit-checkout-left-column').height());
124 - $('.multistep-headers').css('height', 'auto');
187 + $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
125 188
126 - if ($(window).width() > 600 && secondTrigger) {
127 - sidebar.css('background-color', '#effdf5');
128 - } // Manage Breadcrumb.
129 -
130 -
131 189 breadcrumb.find('.shipping').addClass('current').removeClass('blue-line');
132 190 breadcrumb.find('.payment').removeClass('current').addClass('inactive');
191 + $('html, body').animate({
192 + scrollTop: $('.sellkit-checkout-left-column').offset().top
193 + }, 500);
133 194 }); //Inject login wrapper & functionality.
134 195
135 196 emailProcess();
136 197 LoginProcess(); // Billing method toggle.
@@ -150,8 +211,9 @@
150 211 sellkitCheckoutUpdateCartItem();
151 212 applyCoupon();
152 213 couponToggle();
153 214 fixGatewayListUi();
215 + sellkitDetectShippingMethodChange();
154 216 }); // Fix the payment gateways divider issue.
155 217
156 218 fixGatewayListUi(); //Run when page loads.
157 219
@@ -174,9 +236,21 @@
174 236 sellkitCheckoutOrderBump(); // Sellkit after ajax call is completed.
175 237
176 238 sellkitAfterAjaxComplete(); // Load upsell steps with popup.
177 239
178 - sellkitLoadUpsellSteps();
240 + sellkitLoadUpsellSteps(); // send shipping method to backend after changed
241 +
242 + sellkitDetectShippingMethodChange(); // Run some functions on page load when WooCommerce doing early ajax.
243 +
244 + window.sellkitCheckoutMakeSureJsWorks = function () {
245 + sellkitCheckoutUpdateCartItem();
246 + applyCoupon();
247 + couponToggle();
248 + fixGatewayListUi();
249 + }; // Toggle order notes.
250 +
251 +
252 + orderNotesToggle();
179 253 }
180 254
181 255 var emailProcess = function emailProcess() {
182 256 var emailField = $('#billing_email');
@@ -189,14 +263,26 @@
189 263 var usernameField = usernameWrap.find('input');
190 264 var loginBtn = $('.login-wrapper');
191 265 var createBox = $('.create-desc');
192 266 var createCheck = $('#createaccount');
193 - emailField.on('keyup', function () {
194 - var _this = this;
267 + var emailCheckTimer = null;
268 + var usernameCheckTimer = null;
195 269
196 - setTimeout(function () {
197 - var emailAddress = $(_this).val();
270 + var getCurrentEmailValue = function getCurrentEmailValue() {
271 + return $('#billing_email').val();
272 + };
198 273
274 + var getCurrentUsernameValue = function getCurrentUsernameValue() {
275 + return $('.sellkit-checkout-widget-username-field').find('input').val();
276 + }; // Use input/change (not keyup): iOS Safari soft keyboard often omits or mishandles keyup.
277 +
278 +
279 + emailField.on('input change', function () {
280 + var inputEl = this;
281 + clearTimeout(emailCheckTimer);
282 + emailCheckTimer = setTimeout(function () {
283 + var emailAddress = $(inputEl).val();
284 +
199 285 if (_.isEmpty(emailAddress)) {
200 286 emptyError.show().css('display', 'inline-block');
201 287 errorText.hide();
202 288 createBox.css('display', 'none');
@@ -230,19 +316,27 @@
230 316 email: emailAddress,
231 317 dataType: 'json',
232 318 nonce: sellkit_elementor.nonce
233 319 }).done(function () {
320 + if (emailAddress !== getCurrentEmailValue()) {
321 + return;
322 + }
323 +
234 324 successResultEmailCheck();
235 325 }).fail(function () {
326 + if (emailAddress !== getCurrentEmailValue()) {
327 + return;
328 + }
329 +
236 330 errorResultEmailCheck();
237 331 });
238 332 }, 500);
239 333 });
240 - usernameField.on('keyup', function () {
241 - var _this2 = this;
242 -
243 - setTimeout(function () {
244 - var userValue = $(_this2).val();
334 + usernameField.on('input change', function () {
335 + var inputEl = this;
336 + clearTimeout(usernameCheckTimer);
337 + usernameCheckTimer = setTimeout(function () {
338 + var userValue = $(inputEl).val();
245 339 wp.ajax.post({
246 340 action: 'sellkit_checkout_ajax_handler',
247 341 sub_action: 'search_for_username',
248 342 user: userValue,
@@ -248,10 +342,18 @@
248 342 user: userValue,
249 343 dataType: 'json',
250 344 nonce: sellkit_elementor.nonce
251 345 }).done(function () {
346 + if (userValue !== getCurrentUsernameValue()) {
347 + return;
348 + }
349 +
252 350 $('.sellkit-checkout-widget-username-error').hide();
253 351 }).fail(function () {
352 + if (userValue !== getCurrentUsernameValue()) {
353 + return;
354 + }
355 +
254 356 $('.sellkit-checkout-widget-username-error').show();
255 357 });
256 358 }, 500);
257 359 }); // If user is going to create account show password and username fields if exists.
@@ -328,14 +430,14 @@
328 430
329 431 var secondStepHeader = function secondStepHeader() {
330 432 var email = $('#billing_email');
331 433 $('.multistep-headers > .info-a > div > .mail').text(email.val());
332 - var countryValue = $('#shipping_country option:selected').text();
333 - var state = $('#sellkit-shipping_state');
334 - var postcode = $('#shipping_postcode');
335 - var city = $('#shipping_city');
336 - var addressA = $('#shipping_address_1');
337 - var addressB = $('#shipping_address_2');
434 + var countryValue = $('#shipping_country option:selected').text() ? $('#shipping_country option:selected').text() : $('#billing_country option:selected').text();
435 + var state = $('#sellkit-shipping_state').val() ? $('#sellkit-shipping_state') : $('#sellkit-billing_state');
436 + var postcode = $('#shipping_postcode').val() ? $('#shipping_postcode') : $('#billing_postcode');
437 + var city = $('#shipping_city').val() ? $('#shipping_city') : $('#billing_city');
438 + var addressA = $('#shipping_address_1').val() ? $('#shipping_address_1') : $('#billing_address_1');
439 + var addressB = $('#shipping_address_2').val() ? $('#shipping_address_2') : $('#billing_address_2');
338 440 var finalAddress = postcode.val() ? ', ' + postcode.val() : '';
339 441 finalAddress += addressB.val() ? ', ' + addressB.val() : '';
340 442 finalAddress += addressA.val() ? ', ' + addressA.val() : '';
341 443 finalAddress += city.val() ? ', ' + city.val() : '';
@@ -352,34 +454,84 @@
352 454 $('.multistep-headers > .info-c > div > .method').text(methodTxt);
353 455 };
354 456
355 457 var manageBillingMethod = function manageBillingMethod() {
356 - var billingWrap = $('.sellkit-one-page-checkout-billing');
357 - var methodA = billingWrap.find('.method-a');
358 - var methodB = billingWrap.find('.method-b'); // Get shipping values.
458 + // Hide outer #wrapper-billing_* rows — not inner #billing_*_field <p> tags. Labels (.mini-title) sit
459 + // outside those <p> tags; hiding only the <p> left floating labels with no inputs.
460 + var mirroredSelectors = '#wrapper-billing_first_name, #wrapper-billing_last_name, #wrapper-billing_address_1, #wrapper-billing_address_2, #wrapper-billing_country, #wrapper-billing_state, #wrapper-billing_postcode, #wrapper-billing_city, #wrapper-billing_phone';
461 + /**
462 + * Always re-query the DOM. Checkout fragments replace nodes after update_checkout;
463 + * cached jQuery sets would point at detached elements and .hide() would not affect the live form.
464 + *
465 + * @param {boolean} shouldUseShippingAddress - Whether to use shipping address for billing
466 + *
467 + */
359 468
360 - var name = $('#shipping_first_name');
361 - var last = $('#shipping_last_name');
362 - var addressA = $('#shipping_address_1');
363 - var addressB = $('#shipping_address_2');
364 - var country = $('#shipping_country');
365 - var state = $('#sellkit-shipping_state');
366 - var postcode = $('#shipping_postcode');
367 - var city = $('#shipping_city');
368 - methodA.on('click', function () {
369 - billingWrap.find('.woocommerce-billing-fields__field-wrapper').hide();
370 - $('#billing_first_name').val(name.val());
371 - $('#billing_last_name').val(last.val());
372 - $('#billing_address_1').val(addressA.val());
373 - $('#billing_address_2').val(addressB.val());
374 - $('#billing_country').val(country.val()).trigger('change');
375 - $('#sellkit-billing_state').val(state.val()).trigger('change');
376 - $('#billing_postcode').val(postcode.val());
377 - $('#billing_city').val(city.val());
469 + var toggleBillingFields = function toggleBillingFields(shouldUseShippingAddress) {
470 + var billingWrap = $('.sellkit-one-page-checkout-billing');
471 +
472 + if (!billingWrap.length) {
473 + return;
474 + }
475 +
476 + var billingFieldWrapper = billingWrap.find('.woocommerce-billing-fields__field-wrapper');
477 + var mirroredBillingFields = billingFieldWrapper.find(mirroredSelectors);
478 + var billingOnlyFields = billingFieldWrapper.children().not(mirroredBillingFields);
479 +
480 + if (shouldUseShippingAddress) {
481 + mirroredBillingFields.hide();
482 +
483 + if (billingOnlyFields.length) {
484 + billingOnlyFields.show();
485 + billingFieldWrapper.show().css('display', 'inline-table');
486 + } else {
487 + billingFieldWrapper.hide();
488 + }
489 +
490 + return;
491 + }
492 +
493 + billingFieldWrapper.show().css('display', 'inline-table');
494 + mirroredBillingFields.show();
495 + billingOnlyFields.show();
496 + };
497 +
498 + var syncBillingFieldsFromShipping = function syncBillingFieldsFromShipping() {
499 + window.sellkitSuppressBillingAddressAjax = true;
500 + $('#billing_first_name').val($('#shipping_first_name').val());
501 + $('#billing_last_name').val($('#shipping_last_name').val());
502 + $('#billing_address_1').val($('#shipping_address_1').val());
503 + $('#billing_address_2').val($('#shipping_address_2').val());
504 + $('#billing_country').val($('#shipping_country').val()).trigger('change');
505 + $('#sellkit-billing_state').val($('#sellkit-shipping_state').val()).trigger('change');
506 + $('#billing_postcode').val($('#shipping_postcode').val());
507 + $('#billing_city').val($('#shipping_city').val());
508 +
509 + if ($('#billing_phone').length && $('#shipping_phone').length) {
510 + $('#billing_phone').val($('#shipping_phone').val());
511 + }
512 +
513 + window.sellkitSuppressBillingAddressAjax = false;
514 + }; // Delegated: billing markup can be replaced by WooCommerce checkout AJAX.
515 +
516 +
517 + $(document.body).off('click.sellkitBillMethod', '.sellkit-one-page-checkout-billing .method-a').on('click.sellkitBillMethod', '.sellkit-one-page-checkout-billing .method-a', function () {
518 + syncBillingFieldsFromShipping();
519 + toggleBillingFields(true);
520 + sellkitSetAddressDetails();
378 521 });
379 - methodB.on('click', function () {
522 + $(document.body).off('click.sellkitBillMethodDiff', '.sellkit-one-page-checkout-billing .method-b').on('click.sellkitBillMethodDiff', '.sellkit-one-page-checkout-billing .method-b', function () {
380 523 $('.inner_wrapper').css('height', 'auto');
381 - billingWrap.find('.woocommerce-billing-fields__field-wrapper').show();
524 + toggleBillingFields(false);
525 + }); // After fragments refresh, re-apply hide/show — otherwise mirrored rows show again and layout breaks.
526 +
527 + $(document.body).off('updated_checkout.sellkitBillingVis').on('updated_checkout.sellkitBillingVis', function () {
528 + if (!$('.sellkit-one-page-checkout-billing').length) {
529 + return;
530 + }
531 +
532 + var useSame = $('.sellkit-one-page-checkout-billing input[name="billing-method"]:checked').val() === 'same';
533 + toggleBillingFields(useSame);
382 534 });
383 535 };
384 536
385 537 var mobileSummary = function mobileSummary() {
@@ -386,20 +538,22 @@
386 538 if ($(window).width() < 600) {
387 539 $('#order_review').addClass('sellkit-mobile-multistep-order-summary');
388 540 }
389 541
390 - var toggleBtn = $('.summary_toggle > .title, .summary_toggle > i, .summary_toggle > .icon');
542 + var toggleBtn = $('.summary_toggle > .summery_toggle_link_wrapper > .title, .summary_toggle > .summery_toggle_link_wrapper > .sellkit-checkout-summary-toggle-up, .summary_toggle > .summery_toggle_link_wrapper > .icon, .summary_toggle > .summery_toggle_link_wrapper > .sellkit-checkout-summary-toggle-down');
391 543 var wrap = $('.summary_toggle');
392 544 toggleBtn.on('click', function () {
393 545 $('#order_review').toggle();
394 546
395 - if ('Hide order summary' === toggleBtn.text()) {
547 + if ('Hide order summary' === wrap.find('.title').text()) {
396 548 wrap.find('.title').text((0, _i18n.__)('Show order summary', 'sellkit'));
397 - wrap.find('i').addClass('fa-chevron-down').removeClass('fa-chevron-up');
549 + wrap.find('.sellkit-checkout-summary-toggle-up').hide();
550 + wrap.find('.sellkit-checkout-summary-toggle-down').show();
398 551 wrap.css('border-bottom-width', '0px');
399 552 } else {
400 553 wrap.find('.title').text((0, _i18n.__)('Hide order summary', 'sellkit'));
401 - wrap.find('i').addClass('fa-chevron-up').removeClass('fa-chevron-down');
554 + wrap.find('.sellkit-checkout-summary-toggle-up').show();
555 + wrap.find('.sellkit-checkout-summary-toggle-down').hide();
402 556 wrap.css('border-bottom-width', '1px');
403 557 }
404 558
405 559 var parent = $('#sellkit-checkout-multistep-inner-wrap');
@@ -409,9 +563,9 @@
409 563
410 564 var fieldFocus = function fieldFocus() {
411 565 var $fields = $('.sellkit-checkout-local-fields').find('input, select, hidden, textarea, #sellkit-billing_state ,#sellkit-shipping_state, .validate-email');
412 566 $fields.each(function () {
413 - var _this3 = this;
567 + var _this = this;
414 568
415 569 var miniTitle = $(this).parent().parent().parent().find('.mini-title');
416 570 var $thisValue = $(this).val(); // On load.
417 571
@@ -423,34 +577,34 @@
423 577 } // On change/focusOut
424 578
425 579
426 580 $(this).on('change input focusout', function (e) {
427 - var changedValue = $(_this3).val();
581 + var changedValue = $(_this).val();
428 582
429 - if (changedValue || $(_this3).find('option').length) {
430 - $(_this3).addClass('filled');
431 - $(_this3).removeClass('empty');
432 - $(_this3).parents('.sellkit-widget-checkout-fields').find('.mini-title').css('display', 'flex');
583 + if (changedValue || $(_this).find('option').length) {
584 + $(_this).addClass('filled');
585 + $(_this).removeClass('empty');
586 + $(_this).parents('.sellkit-widget-checkout-fields').find('.mini-title').css('display', 'flex');
433 587 } else {
434 - $(_this3).addClass('empty');
435 - $(_this3).removeClass('filled');
436 - $(_this3).parents('.sellkit-widget-checkout-fields').find('.mini-title').hide();
588 + $(_this).addClass('empty');
589 + $(_this).removeClass('filled');
590 + $(_this).parents('.sellkit-widget-checkout-fields').find('.mini-title').hide();
437 591 } // On focusout validate fields.
438 592
439 593
440 594 if ('focusout' === e.type) {
441 - FieldsMiniTitles($(_this3), 'focusout');
442 - var parent = $(_this3).parent().parent().parent(); // Required validation. return if required field rule is not followed.
595 + FieldsMiniTitles($(_this), 'focusout');
596 + var parent = $(_this).parent().parent().parent(); // Required validation. return if required field rule is not followed.
443 597
444 598 if (parent.hasClass('validate-required')) {
445 - if ('INPUT' === _this3.nodeName && 'checkbox' === $(_this3).attr('type')) {
446 - if (!_this3.checked) {
599 + if ('INPUT' === _this.nodeName && 'checkbox' === $(_this).attr('type')) {
600 + if (!_this.checked) {
447 601 parent.find('.sellkit-required-validation').css('display', 'inline-flex');
448 602 return;
449 603 }
450 604 }
451 605
452 - if (_.isEmpty($(_this3).val())) {
606 + if (_.isEmpty($(_this).val())) {
453 607 parent.find('.sellkit-required-validation').css('display', 'inline-flex');
454 608 return;
455 609 }
456 610
@@ -458,9 +612,9 @@
458 612 } // Required validation of this field if exists, passed successfully. now postcode validation.
459 613
460 614
461 615 if (parent.hasClass('sellkit-checkout-fields-validation-postcode')) {
462 - var postcodeVal = $(_this3).val();
616 + var postcodeVal = $(_this).val();
463 617
464 618 if (_.isEmpty(postcodeVal)) {
465 619 return;
466 620 } // Check field type to get related country value. we can't validate without country code.
@@ -465,9 +619,9 @@
465 619 return;
466 620 } // Check field type to get related country value. we can't validate without country code.
467 621
468 622
469 - var postcodeName = $(_this3).attr('name');
623 + var postcodeName = $(_this).attr('name');
470 624 var postcodeCountry = $('#billing_country');
471 625
472 626 if (postcodeName.includes('shipping')) {
473 627 postcodeCountry = $('#shipping_country');
@@ -488,30 +642,30 @@
488 642 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
489 643 }
490 644
491 645 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
492 - postcodeValidation(postcodeVal, countryCode, $(_this3));
646 + postcodeValidation(postcodeVal, countryCode, $(_this));
493 647 } // Phone validation using woocommerce way.
494 648
495 649
496 650 if (parent.hasClass('sellkit-checkout-fields-validation-phone')) {
497 - var phone = $(_this3).val();
651 + var phone = $(_this).val();
498 652
499 653 if (_.isEmpty(phone)) {
500 654 return;
501 655 }
502 656
503 - phoneNumberValidation(phone, $(_this3));
657 + phoneNumberValidation(phone, $(_this));
504 658 }
505 659 }
506 660
507 - if ('change' === e.type && ('billing_country' === $(_this3).attr('id') || 'shipping_country' === $(_this3).attr('id'))) {
508 - var _countryCode = $(_this3).val();
661 + if ('change' === e.type && ('billing_country' === $(_this).attr('id') || 'shipping_country' === $(_this).attr('id'))) {
662 + var _countryCode = $(_this).val();
509 663
510 664 var states = wcCountries[_countryCode];
511 665 var state = 'sellkit-shipping_state';
512 666
513 - if ('billing_country' === $(_this3).attr('id')) {
667 + if ('billing_country' === $(_this).attr('id')) {
514 668 state = 'sellkit-billing_state';
515 669 }
516 670
517 671 var stateField = document.getElementById(state);
@@ -519,8 +673,12 @@
519 673 if (_.isNull(stateField)) {
520 674 return;
521 675 }
522 676
677 + if (!_.isObject(states)) {
678 + return;
679 + }
680 +
523 681 $(stateField).empty();
524 682
525 683 for (var keys in states) {
526 684 var option = document.createElement('option');
@@ -818,8 +976,30 @@
818 976 });
819 977 });
820 978 };
821 979 /**
980 + * Send shipping method id to backend
981 + *
982 + * The click event used because change event, send shipping method id on page load to backend and make an issue.
983 + *
984 + * @since 2.6.0
985 + */
986 +
987 +
988 +var sellkitDetectShippingMethodChange = function sellkitDetectShippingMethodChange() {
989 + $('input.shipping_method').off('click').on('click', function () {
990 + var selectedMethod = $(this).val();
991 + wp.ajax.post({
992 + action: 'shipping_method_selected',
993 + nonce: sellkit_elementor.nonce,
994 + shipping_method: selectedMethod
995 + }).fail(function (data) {
996 + // eslint-disable-next-line
997 + console.error(data);
998 + });
999 + });
1000 +};
1001 +/**
822 1002 * Toggle coupon form on click event.
823 1003 *
824 1004 * @since 1.2.5
825 1005 */
@@ -1068,8 +1248,12 @@
1068 1248 */
1069 1249
1070 1250
1071 1251 var sellkitSetAddressDetails = function sellkitSetAddressDetails() {
1252 + if (window.sellkitSuppressBillingAddressAjax) {
1253 + return;
1254 + }
1255 +
1072 1256 wp.ajax.post({
1073 1257 action: 'sellkit_checkout_ajax_handler',
1074 1258 sub_action: 'set_customer_details_ajax',
1075 1259 country: document.querySelector('#billing_country') ? document.getElementById('billing_country').value : '',
@@ -1395,8 +1579,9 @@
1395 1579 }).done(function (data) {
1396 1580 $(document.body).trigger('update_checkout');
1397 1581 parent.find('.sellkit-upsell-updating').removeClass('active');
1398 1582 parent.find('.sellkit-upsell-accepted').addClass('active');
1583 + updateSellkitPriceField(data.upsell_prices);
1399 1584 onSuccess(data);
1400 1585 }).fail(function (data) {
1401 1586 // eslint-disable-next-line no-console
1402 1587 console.error(data);
@@ -1440,9 +1625,101 @@
1440 1625 $('button[type=submit]').find('img').remove();
1441 1626 });
1442 1627 };
1443 1628
1444 -},{"@wordpress/i18n":15}],2:[function(require,module,exports){
1629 +var updateSellkitPriceField = function updateSellkitPriceField(data) {
1630 + if (data === 'null' || data === null) {
1631 + return;
1632 + }
1633 +
1634 + var current_val = $('input#sellkit_product_prices').val();
1635 +
1636 + if (!current_val || current_val === '0') {
1637 + $('input#sellkit_product_prices').val(data);
1638 + } else {
1639 + var oldVal = JSON.parse(current_val);
1640 + var newVal = JSON.parse(data);
1641 + var val = JSON.stringify(Object.assign({}, oldVal, newVal));
1642 + $('input#sellkit_product_prices').val(val);
1643 + }
1644 +};
1645 +/**
1646 + * Toggle order notes.
1647 + *
1648 + * @since 1.8.9
1649 + */
1650 +
1651 +
1652 +var orderNotesToggle = function orderNotesToggle() {
1653 + $('#sellkit-add-notes-to-order-box').on('change', function () {
1654 + $(this).parent().next().toggle();
1655 + });
1656 +}; // --- Sellkit: Sync custom state fields to standard WooCommerce fields for gateway compatibility ---
1657 +
1658 +
1659 +var ensureStandardWooFields = function ensureStandardWooFields() {
1660 + try {
1661 + var form = document.querySelector('form.checkout');
1662 +
1663 + if (!form) {
1664 + return;
1665 + } // Billing state
1666 +
1667 +
1668 + var sellkitBillingState = document.getElementById('sellkit-billing_state');
1669 +
1670 + if (sellkitBillingState) {
1671 + var billingState = document.getElementById('billing_state');
1672 +
1673 + if (!billingState) {
1674 + billingState = document.createElement('input');
1675 + billingState.type = 'hidden';
1676 + billingState.id = 'billing_state';
1677 + billingState.name = 'billing_state';
1678 + form.appendChild(billingState);
1679 + }
1680 +
1681 + billingState.value = sellkitBillingState.value;
1682 + } // Shipping state
1683 +
1684 +
1685 + var sellkitShippingState = document.getElementById('sellkit-shipping_state');
1686 +
1687 + if (sellkitShippingState) {
1688 + var shippingState = document.getElementById('shipping_state');
1689 +
1690 + if (!shippingState) {
1691 + shippingState = document.createElement('input');
1692 + shippingState.type = 'hidden';
1693 + shippingState.id = 'shipping_state';
1694 + shippingState.name = 'shipping_state';
1695 + form.appendChild(shippingState);
1696 + }
1697 +
1698 + shippingState.value = sellkitShippingState.value;
1699 + }
1700 + } catch (e) {
1701 + // eslint-disable-next-line no-console
1702 + console.error('[Sellkit] Error syncing state fields for gateway compatibility:', e);
1703 + }
1704 +}; // Attach to form submit and on state field change
1705 +
1706 +
1707 +jQuery(document).ready(function (_$) {
1708 + var form = _$('form.checkout');
1709 +
1710 + if (form.length) {
1711 + form.on('submit', function () {
1712 + ensureStandardWooFields();
1713 + }); // Also update on state field change
1714 +
1715 + _$('#sellkit-billing_state, #sellkit-shipping_state').on('change input', function () {
1716 + ensureStandardWooFields();
1717 + });
1718 + }
1719 +});
1720 +
1721 +},{"./checkout-settings":1,"@babel/runtime/helpers/interopRequireDefault":9,"@wordpress/i18n":16}],3:[function(require,module,exports){
1445 1722 "use strict";
1446 1723
1447 1724 (function ($) {
1448 1725 var SellkitFrontend = function SellkitFrontend() {
@@ -1467,9 +1744,9 @@
1467 1744
1468 1745 window.sellkitFrontend = new SellkitFrontend();
1469 1746 })(jQuery);
1470 1747
1471 -},{"./checkout":1,"./optin/optin":3,"./product-images":6}],3:[function(require,module,exports){
1748 +},{"./checkout":2,"./optin/optin":4,"./product-images":7}],4:[function(require,module,exports){
1472 1749 "use strict";
1473 1750
1474 1751 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1475 1752
@@ -1646,12 +1923,61 @@
1646 1923 return;
1647 1924 }
1648 1925
1649 1926 _.each(addressFields, function (input) {
1650 - new google.maps.places.Autocomplete(input, {
1927 + var autocomplete = new google.maps.places.Autocomplete(input, {
1651 1928 types: ['geocode'],
1652 1929 fields: ['address_components']
1653 1930 });
1931 + autocomplete.addListener('place_changed', function () {
1932 + var place = autocomplete.getPlace(); // Extract address components
1933 +
1934 + var address = {
1935 + street_number: '',
1936 + route: '',
1937 + locality: '',
1938 + administrative_area_level_1: '',
1939 + country: '',
1940 + postal_code: ''
1941 + }; // Map Google Maps address components to your address object
1942 +
1943 + place.address_components.forEach(function (component) {
1944 + var componentType = component.types[0];
1945 +
1946 + switch (componentType) {
1947 + case 'street_number':
1948 + address.street_number = component.long_name;
1949 + break;
1950 +
1951 + case 'route':
1952 + address.route = component.long_name;
1953 + break;
1954 +
1955 + case 'locality':
1956 + address.locality = component.long_name;
1957 + break;
1958 +
1959 + case 'administrative_area_level_1':
1960 + address.administrative_area_level_1 = component.long_name;
1961 + break;
1962 +
1963 + case 'country':
1964 + address.country = component.long_name;
1965 + break;
1966 +
1967 + case 'postal_code':
1968 + address.postal_code = component.long_name;
1969 + break;
1970 + }
1971 + }); // Combine street number and route for the full street address
1972 +
1973 + var addressString = JSON.stringify(address);
1974 + var addressHidenField = input.nextElementSibling;
1975 +
1976 + if (addressHidenField && addressHidenField.type === 'hidden') {
1977 + addressHidenField.value = addressString;
1978 + }
1979 + });
1654 1980 });
1655 1981 }
1656 1982 });
1657 1983
@@ -1660,9 +1986,9 @@
1660 1986 $element: $scope
1661 1987 });
1662 1988 }
1663 1989
1664 -},{"./submodules/field-validation":4,"./submodules/intelligent-tel":5,"@babel/runtime/helpers/interopRequireDefault":8,"@wordpress/i18n":15}],4:[function(require,module,exports){
1990 +},{"./submodules/field-validation":5,"./submodules/intelligent-tel":6,"@babel/runtime/helpers/interopRequireDefault":9,"@wordpress/i18n":16}],5:[function(require,module,exports){
1665 1991 "use strict";
1666 1992
1667 1993 Object.defineProperty(exports, "__esModule", {
1668 1994 value: true
@@ -1819,9 +2145,9 @@
1819 2145 }
1820 2146 };
1821 2147 exports["default"] = _default;
1822 2148
1823 -},{}],5:[function(require,module,exports){
2149 +},{}],6:[function(require,module,exports){
1824 2150 "use strict";
1825 2151
1826 2152 Object.defineProperty(exports, "__esModule", {
1827 2153 value: true
@@ -1901,9 +2227,9 @@
1901 2227 }
1902 2228 };
1903 2229 exports["default"] = _default;
1904 2230
1905 -},{"intl-tel-input":19}],6:[function(require,module,exports){
2231 +},{"intl-tel-input":20}],7:[function(require,module,exports){
1906 2232 "use strict";
1907 2233
1908 2234 Object.defineProperty(exports, "__esModule", {
1909 2235 value: true
@@ -1953,9 +2279,9 @@
1953 2279 $element: $scope
1954 2280 });
1955 2281 }
1956 2282
1957 -},{}],7:[function(require,module,exports){
2283 +},{}],8:[function(require,module,exports){
1958 2284 function _defineProperty(obj, key, value) {
1959 2285 if (key in obj) {
1960 2286 Object.defineProperty(obj, key, {
1961 2287 value: value,
@@ -1970,9 +2296,9 @@
1970 2296 return obj;
1971 2297 }
1972 2298
1973 2299 module.exports = _defineProperty;
1974 -},{}],8:[function(require,module,exports){
2300 +},{}],9:[function(require,module,exports){
1975 2301 function _interopRequireDefault(obj) {
1976 2302 return obj && obj.__esModule ? obj : {
1977 2303 "default": obj
1978 2304 };
@@ -1978,9 +2304,9 @@
1978 2304 };
1979 2305 }
1980 2306
1981 2307 module.exports = _interopRequireDefault;
1982 -},{}],9:[function(require,module,exports){
2308 +},{}],10:[function(require,module,exports){
1983 2309 'use strict';
1984 2310
1985 2311 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
1986 2312
@@ -2015,9 +2341,9 @@
2015 2341 }
2016 2342
2017 2343 module.exports = compile;
2018 2344
2019 -},{"@tannin/evaluate":10,"@tannin/postfix":12}],10:[function(require,module,exports){
2345 +},{"@tannin/evaluate":11,"@tannin/postfix":13}],11:[function(require,module,exports){
2020 2346 'use strict';
2021 2347
2022 2348 /**
2023 2349 * Operator callback functions.
@@ -2131,9 +2457,9 @@
2131 2457 }
2132 2458
2133 2459 module.exports = evaluate;
2134 2460
2135 -},{}],11:[function(require,module,exports){
2461 +},{}],12:[function(require,module,exports){
2136 2462 'use strict';
2137 2463
2138 2464 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
2139 2465
@@ -2157,9 +2483,9 @@
2157 2483 }
2158 2484
2159 2485 module.exports = pluralForms;
2160 2486
2161 -},{"@tannin/compile":9}],12:[function(require,module,exports){
2487 +},{"@tannin/compile":10}],13:[function(require,module,exports){
2162 2488 'use strict';
2163 2489
2164 2490 var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
2165 2491
@@ -2287,9 +2613,9 @@
2287 2613 }
2288 2614
2289 2615 module.exports = postfix;
2290 2616
2291 -},{}],13:[function(require,module,exports){
2617 +},{}],14:[function(require,module,exports){
2292 2618 "use strict";
2293 2619
2294 2620 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2295 2621
@@ -2502,9 +2828,9 @@
2502 2828 };
2503 2829
2504 2830 exports.createI18n = createI18n;
2505 2831
2506 -},{"@babel/runtime/helpers/defineProperty":7,"@babel/runtime/helpers/interopRequireDefault":8,"tannin":22}],14:[function(require,module,exports){
2832 +},{"@babel/runtime/helpers/defineProperty":8,"@babel/runtime/helpers/interopRequireDefault":9,"tannin":23}],15:[function(require,module,exports){
2507 2833 "use strict";
2508 2834
2509 2835 Object.defineProperty(exports, "__esModule", {
2510 2836 value: true
@@ -2621,9 +2947,9 @@
2621 2947 exports._nx = _nx;
2622 2948 var isRTL = i18n.isRTL.bind(i18n);
2623 2949 exports.isRTL = isRTL;
2624 2950
2625 -},{"./create-i18n":13}],15:[function(require,module,exports){
2951 +},{"./create-i18n":14}],16:[function(require,module,exports){
2626 2952 "use strict";
2627 2953
2628 2954 Object.defineProperty(exports, "__esModule", {
2629 2955 value: true
@@ -2696,9 +3022,9 @@
2696 3022 });
2697 3023
2698 3024 var _defaultI18n = require("./default-i18n");
2699 3025
2700 -},{"./create-i18n":13,"./default-i18n":14,"./sprintf":16}],16:[function(require,module,exports){
3026 +},{"./create-i18n":14,"./default-i18n":15,"./sprintf":17}],17:[function(require,module,exports){
2701 3027 "use strict";
2702 3028
2703 3029 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2704 3030
@@ -2748,9 +3074,9 @@
2748 3074 return format;
2749 3075 }
2750 3076 }
2751 3077
2752 -},{"@babel/runtime/helpers/interopRequireDefault":8,"memize":20,"sprintf-js":17}],17:[function(require,module,exports){
3078 +},{"@babel/runtime/helpers/interopRequireDefault":9,"memize":21,"sprintf-js":18}],18:[function(require,module,exports){
2753 3079 /* global window, exports, define */
2754 3080
2755 3081 !function() {
2756 3082 'use strict'
@@ -2981,9 +3307,9 @@
2981 3307 }
2982 3308 /* eslint-enable quote-props */
2983 3309 }(); // eslint-disable-line
2984 3310
2985 -},{}],18:[function(require,module,exports){
3311 +},{}],19:[function(require,module,exports){
2986 3312 /*
2987 3313 * International Telephone Input v17.0.16
2988 3314 * https://github.com/jackocnr/intl-tel-input.git
2989 3315 * Licensed under the MIT license
@@ -4335,15 +4661,15 @@
4335 4661 return iti;
4336 4662 };
4337 4663 }();
4338 4664 });
4339 -},{}],19:[function(require,module,exports){
4665 +},{}],20:[function(require,module,exports){
4340 4666 /**
4341 4667 * Exposing intl-tel-input as a component
4342 4668 */
4343 4669 module.exports = require("./build/js/intlTelInput");
4344 4670
4345 -},{"./build/js/intlTelInput":18}],20:[function(require,module,exports){
4671 +},{"./build/js/intlTelInput":19}],21:[function(require,module,exports){
4346 4672 (function (process){
4347 4673 /**
4348 4674 * Memize options object.
4349 4675 *
@@ -4512,9 +4838,9 @@
4512 4838
4513 4839 module.exports = memize;
4514 4840
4515 4841 }).call(this,require('_process'))
4516 -},{"_process":21}],21:[function(require,module,exports){
4842 +},{"_process":22}],22:[function(require,module,exports){
4517 4843 // shim for using process in browser
4518 4844 var process = module.exports = {};
4519 4845
4520 4846 // cached from whatever global is present so that test runners that stub it
@@ -4698,9 +5024,9 @@
4698 5024 throw new Error('process.chdir is not supported');
4699 5025 };
4700 5026 process.umask = function() { return 0; };
4701 5027
4702 -},{}],22:[function(require,module,exports){
5028 +},{}],23:[function(require,module,exports){
4703 5029 'use strict';
4704 5030
4705 5031 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4706 5032
@@ -4919,5 +5245,5 @@
4919 5245 };
4920 5246
4921 5247 module.exports = Tannin;
4922 5248
4923 -},{"@tannin/plural-forms":11}]},{},[2]);
5249 +},{"@tannin/plural-forms":12}]},{},[3]);