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 +429 -89 1.6.52.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');
@@ -57,8 +120,11 @@
57 120 $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
58 121
59 122 breadcrumb.find('.information').removeClass('current').addClass('blue-line');
60 123 breadcrumb.find('.shipping').addClass('current').removeClass('inactive');
124 + $('html, body').animate({
125 + scrollTop: $('.sellkit-checkout-left-column').offset().top
126 + }, 500);
61 127 });
62 128 $('.go-to-first').on('click', function () {
63 129 first.show();
64 130 third.hide();
@@ -68,8 +134,11 @@
68 134 sidebar.css('background-color', 'transparent'); // Manage Breadcrumb.
69 135
70 136 breadcrumb.find('.information').removeClass('blue-line').addClass('current');
71 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);
72 141 });
73 142 $('.go-to-payment').on('click', function () {
74 143 // Checks if required fields are filled.
75 144 var requiredFieldsError = checkRequiredFields();
@@ -90,8 +159,11 @@
90 159 $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
91 160
92 161 breadcrumb.find('.shipping').addClass('blue-line').removeClass('current');
93 162 breadcrumb.find('.payment').addClass('current').removeClass('inactive');
163 + $('html, body').animate({
164 + scrollTop: $('.sellkit-checkout-left-column').offset().top
165 + }, 500);
94 166 });
95 167 $('.go-to-second , .go-to-second-header').on('click', function () {
96 168 // Checks if required fields are filled.
97 169 var requiredFieldsError = checkRequiredFields();
@@ -115,8 +187,11 @@
115 187 $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
116 188
117 189 breadcrumb.find('.shipping').addClass('current').removeClass('blue-line');
118 190 breadcrumb.find('.payment').removeClass('current').addClass('inactive');
191 + $('html, body').animate({
192 + scrollTop: $('.sellkit-checkout-left-column').offset().top
193 + }, 500);
119 194 }); //Inject login wrapper & functionality.
120 195
121 196 emailProcess();
122 197 LoginProcess(); // Billing method toggle.
@@ -136,8 +211,9 @@
136 211 sellkitCheckoutUpdateCartItem();
137 212 applyCoupon();
138 213 couponToggle();
139 214 fixGatewayListUi();
215 + sellkitDetectShippingMethodChange();
140 216 }); // Fix the payment gateways divider issue.
141 217
142 218 fixGatewayListUi(); //Run when page loads.
143 219
@@ -160,9 +236,21 @@
160 236 sellkitCheckoutOrderBump(); // Sellkit after ajax call is completed.
161 237
162 238 sellkitAfterAjaxComplete(); // Load upsell steps with popup.
163 239
164 - 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();
165 253 }
166 254
167 255 var emailProcess = function emailProcess() {
168 256 var emailField = $('#billing_email');
@@ -175,14 +263,26 @@
175 263 var usernameField = usernameWrap.find('input');
176 264 var loginBtn = $('.login-wrapper');
177 265 var createBox = $('.create-desc');
178 266 var createCheck = $('#createaccount');
179 - emailField.on('keyup', function () {
180 - var _this = this;
267 + var emailCheckTimer = null;
268 + var usernameCheckTimer = null;
181 269
182 - setTimeout(function () {
183 - var emailAddress = $(_this).val();
270 + var getCurrentEmailValue = function getCurrentEmailValue() {
271 + return $('#billing_email').val();
272 + };
184 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 +
185 285 if (_.isEmpty(emailAddress)) {
186 286 emptyError.show().css('display', 'inline-block');
187 287 errorText.hide();
188 288 createBox.css('display', 'none');
@@ -216,19 +316,27 @@
216 316 email: emailAddress,
217 317 dataType: 'json',
218 318 nonce: sellkit_elementor.nonce
219 319 }).done(function () {
320 + if (emailAddress !== getCurrentEmailValue()) {
321 + return;
322 + }
323 +
220 324 successResultEmailCheck();
221 325 }).fail(function () {
326 + if (emailAddress !== getCurrentEmailValue()) {
327 + return;
328 + }
329 +
222 330 errorResultEmailCheck();
223 331 });
224 332 }, 500);
225 333 });
226 - usernameField.on('keyup', function () {
227 - var _this2 = this;
228 -
229 - setTimeout(function () {
230 - 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();
231 339 wp.ajax.post({
232 340 action: 'sellkit_checkout_ajax_handler',
233 341 sub_action: 'search_for_username',
234 342 user: userValue,
@@ -234,10 +342,18 @@
234 342 user: userValue,
235 343 dataType: 'json',
236 344 nonce: sellkit_elementor.nonce
237 345 }).done(function () {
346 + if (userValue !== getCurrentUsernameValue()) {
347 + return;
348 + }
349 +
238 350 $('.sellkit-checkout-widget-username-error').hide();
239 351 }).fail(function () {
352 + if (userValue !== getCurrentUsernameValue()) {
353 + return;
354 + }
355 +
240 356 $('.sellkit-checkout-widget-username-error').show();
241 357 });
242 358 }, 500);
243 359 }); // If user is going to create account show password and username fields if exists.
@@ -314,14 +430,14 @@
314 430
315 431 var secondStepHeader = function secondStepHeader() {
316 432 var email = $('#billing_email');
317 433 $('.multistep-headers > .info-a > div > .mail').text(email.val());
318 - var countryValue = $('#shipping_country option:selected').text();
319 - var state = $('#sellkit-shipping_state');
320 - var postcode = $('#shipping_postcode');
321 - var city = $('#shipping_city');
322 - var addressA = $('#shipping_address_1');
323 - 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');
324 440 var finalAddress = postcode.val() ? ', ' + postcode.val() : '';
325 441 finalAddress += addressB.val() ? ', ' + addressB.val() : '';
326 442 finalAddress += addressA.val() ? ', ' + addressA.val() : '';
327 443 finalAddress += city.val() ? ', ' + city.val() : '';
@@ -338,34 +454,84 @@
338 454 $('.multistep-headers > .info-c > div > .method').text(methodTxt);
339 455 };
340 456
341 457 var manageBillingMethod = function manageBillingMethod() {
342 - var billingWrap = $('.sellkit-one-page-checkout-billing');
343 - var methodA = billingWrap.find('.method-a');
344 - 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 + */
345 468
346 - var name = $('#shipping_first_name');
347 - var last = $('#shipping_last_name');
348 - var addressA = $('#shipping_address_1');
349 - var addressB = $('#shipping_address_2');
350 - var country = $('#shipping_country');
351 - var state = $('#sellkit-shipping_state');
352 - var postcode = $('#shipping_postcode');
353 - var city = $('#shipping_city');
354 - methodA.on('click', function () {
355 - billingWrap.find('.woocommerce-billing-fields__field-wrapper').hide();
356 - $('#billing_first_name').val(name.val());
357 - $('#billing_last_name').val(last.val());
358 - $('#billing_address_1').val(addressA.val());
359 - $('#billing_address_2').val(addressB.val());
360 - $('#billing_country').val(country.val()).trigger('change');
361 - $('#sellkit-billing_state').val(state.val()).trigger('change');
362 - $('#billing_postcode').val(postcode.val());
363 - $('#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();
364 521 });
365 - 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 () {
366 523 $('.inner_wrapper').css('height', 'auto');
367 - 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);
368 534 });
369 535 };
370 536
371 537 var mobileSummary = function mobileSummary() {
@@ -372,20 +538,22 @@
372 538 if ($(window).width() < 600) {
373 539 $('#order_review').addClass('sellkit-mobile-multistep-order-summary');
374 540 }
375 541
376 - 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');
377 543 var wrap = $('.summary_toggle');
378 544 toggleBtn.on('click', function () {
379 545 $('#order_review').toggle();
380 546
381 - if ('Hide order summary' === toggleBtn.text()) {
547 + if ('Hide order summary' === wrap.find('.title').text()) {
382 548 wrap.find('.title').text((0, _i18n.__)('Show order summary', 'sellkit'));
383 - 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();
384 551 wrap.css('border-bottom-width', '0px');
385 552 } else {
386 553 wrap.find('.title').text((0, _i18n.__)('Hide order summary', 'sellkit'));
387 - 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();
388 556 wrap.css('border-bottom-width', '1px');
389 557 }
390 558
391 559 var parent = $('#sellkit-checkout-multistep-inner-wrap');
@@ -395,9 +563,9 @@
395 563
396 564 var fieldFocus = function fieldFocus() {
397 565 var $fields = $('.sellkit-checkout-local-fields').find('input, select, hidden, textarea, #sellkit-billing_state ,#sellkit-shipping_state, .validate-email');
398 566 $fields.each(function () {
399 - var _this3 = this;
567 + var _this = this;
400 568
401 569 var miniTitle = $(this).parent().parent().parent().find('.mini-title');
402 570 var $thisValue = $(this).val(); // On load.
403 571
@@ -409,34 +577,34 @@
409 577 } // On change/focusOut
410 578
411 579
412 580 $(this).on('change input focusout', function (e) {
413 - var changedValue = $(_this3).val();
581 + var changedValue = $(_this).val();
414 582
415 - if (changedValue || $(_this3).find('option').length) {
416 - $(_this3).addClass('filled');
417 - $(_this3).removeClass('empty');
418 - $(_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');
419 587 } else {
420 - $(_this3).addClass('empty');
421 - $(_this3).removeClass('filled');
422 - $(_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();
423 591 } // On focusout validate fields.
424 592
425 593
426 594 if ('focusout' === e.type) {
427 - FieldsMiniTitles($(_this3), 'focusout');
428 - 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.
429 597
430 598 if (parent.hasClass('validate-required')) {
431 - if ('INPUT' === _this3.nodeName && 'checkbox' === $(_this3).attr('type')) {
432 - if (!_this3.checked) {
599 + if ('INPUT' === _this.nodeName && 'checkbox' === $(_this).attr('type')) {
600 + if (!_this.checked) {
433 601 parent.find('.sellkit-required-validation').css('display', 'inline-flex');
434 602 return;
435 603 }
436 604 }
437 605
438 - if (_.isEmpty($(_this3).val())) {
606 + if (_.isEmpty($(_this).val())) {
439 607 parent.find('.sellkit-required-validation').css('display', 'inline-flex');
440 608 return;
441 609 }
442 610
@@ -444,9 +612,9 @@
444 612 } // Required validation of this field if exists, passed successfully. now postcode validation.
445 613
446 614
447 615 if (parent.hasClass('sellkit-checkout-fields-validation-postcode')) {
448 - var postcodeVal = $(_this3).val();
616 + var postcodeVal = $(_this).val();
449 617
450 618 if (_.isEmpty(postcodeVal)) {
451 619 return;
452 620 } // Check field type to get related country value. we can't validate without country code.
@@ -451,9 +619,9 @@
451 619 return;
452 620 } // Check field type to get related country value. we can't validate without country code.
453 621
454 622
455 - var postcodeName = $(_this3).attr('name');
623 + var postcodeName = $(_this).attr('name');
456 624 var postcodeCountry = $('#billing_country');
457 625
458 626 if (postcodeName.includes('shipping')) {
459 627 postcodeCountry = $('#shipping_country');
@@ -474,30 +642,30 @@
474 642 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
475 643 }
476 644
477 645 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
478 - postcodeValidation(postcodeVal, countryCode, $(_this3));
646 + postcodeValidation(postcodeVal, countryCode, $(_this));
479 647 } // Phone validation using woocommerce way.
480 648
481 649
482 650 if (parent.hasClass('sellkit-checkout-fields-validation-phone')) {
483 - var phone = $(_this3).val();
651 + var phone = $(_this).val();
484 652
485 653 if (_.isEmpty(phone)) {
486 654 return;
487 655 }
488 656
489 - phoneNumberValidation(phone, $(_this3));
657 + phoneNumberValidation(phone, $(_this));
490 658 }
491 659 }
492 660
493 - if ('change' === e.type && ('billing_country' === $(_this3).attr('id') || 'shipping_country' === $(_this3).attr('id'))) {
494 - var _countryCode = $(_this3).val();
661 + if ('change' === e.type && ('billing_country' === $(_this).attr('id') || 'shipping_country' === $(_this).attr('id'))) {
662 + var _countryCode = $(_this).val();
495 663
496 664 var states = wcCountries[_countryCode];
497 665 var state = 'sellkit-shipping_state';
498 666
499 - if ('billing_country' === $(_this3).attr('id')) {
667 + if ('billing_country' === $(_this).attr('id')) {
500 668 state = 'sellkit-billing_state';
501 669 }
502 670
503 671 var stateField = document.getElementById(state);
@@ -505,8 +673,12 @@
505 673 if (_.isNull(stateField)) {
506 674 return;
507 675 }
508 676
677 + if (!_.isObject(states)) {
678 + return;
679 + }
680 +
509 681 $(stateField).empty();
510 682
511 683 for (var keys in states) {
512 684 var option = document.createElement('option');
@@ -804,8 +976,30 @@
804 976 });
805 977 });
806 978 };
807 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 +/**
808 1002 * Toggle coupon form on click event.
809 1003 *
810 1004 * @since 1.2.5
811 1005 */
@@ -1054,8 +1248,12 @@
1054 1248 */
1055 1249
1056 1250
1057 1251 var sellkitSetAddressDetails = function sellkitSetAddressDetails() {
1252 + if (window.sellkitSuppressBillingAddressAjax) {
1253 + return;
1254 + }
1255 +
1058 1256 wp.ajax.post({
1059 1257 action: 'sellkit_checkout_ajax_handler',
1060 1258 sub_action: 'set_customer_details_ajax',
1061 1259 country: document.querySelector('#billing_country') ? document.getElementById('billing_country').value : '',
@@ -1381,8 +1579,9 @@
1381 1579 }).done(function (data) {
1382 1580 $(document.body).trigger('update_checkout');
1383 1581 parent.find('.sellkit-upsell-updating').removeClass('active');
1384 1582 parent.find('.sellkit-upsell-accepted').addClass('active');
1583 + updateSellkitPriceField(data.upsell_prices);
1385 1584 onSuccess(data);
1386 1585 }).fail(function (data) {
1387 1586 // eslint-disable-next-line no-console
1388 1587 console.error(data);
@@ -1426,9 +1625,101 @@
1426 1625 $('button[type=submit]').find('img').remove();
1427 1626 });
1428 1627 };
1429 1628
1430 -},{"@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){
1431 1722 "use strict";
1432 1723
1433 1724 (function ($) {
1434 1725 var SellkitFrontend = function SellkitFrontend() {
@@ -1453,9 +1744,9 @@
1453 1744
1454 1745 window.sellkitFrontend = new SellkitFrontend();
1455 1746 })(jQuery);
1456 1747
1457 -},{"./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){
1458 1749 "use strict";
1459 1750
1460 1751 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1461 1752
@@ -1632,12 +1923,61 @@
1632 1923 return;
1633 1924 }
1634 1925
1635 1926 _.each(addressFields, function (input) {
1636 - new google.maps.places.Autocomplete(input, {
1927 + var autocomplete = new google.maps.places.Autocomplete(input, {
1637 1928 types: ['geocode'],
1638 1929 fields: ['address_components']
1639 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 + });
1640 1980 });
1641 1981 }
1642 1982 });
1643 1983
@@ -1646,9 +1986,9 @@
1646 1986 $element: $scope
1647 1987 });
1648 1988 }
1649 1989
1650 -},{"./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){
1651 1991 "use strict";
1652 1992
1653 1993 Object.defineProperty(exports, "__esModule", {
1654 1994 value: true
@@ -1805,9 +2145,9 @@
1805 2145 }
1806 2146 };
1807 2147 exports["default"] = _default;
1808 2148
1809 -},{}],5:[function(require,module,exports){
2149 +},{}],6:[function(require,module,exports){
1810 2150 "use strict";
1811 2151
1812 2152 Object.defineProperty(exports, "__esModule", {
1813 2153 value: true
@@ -1887,9 +2227,9 @@
1887 2227 }
1888 2228 };
1889 2229 exports["default"] = _default;
1890 2230
1891 -},{"intl-tel-input":19}],6:[function(require,module,exports){
2231 +},{"intl-tel-input":20}],7:[function(require,module,exports){
1892 2232 "use strict";
1893 2233
1894 2234 Object.defineProperty(exports, "__esModule", {
1895 2235 value: true
@@ -1939,9 +2279,9 @@
1939 2279 $element: $scope
1940 2280 });
1941 2281 }
1942 2282
1943 -},{}],7:[function(require,module,exports){
2283 +},{}],8:[function(require,module,exports){
1944 2284 function _defineProperty(obj, key, value) {
1945 2285 if (key in obj) {
1946 2286 Object.defineProperty(obj, key, {
1947 2287 value: value,
@@ -1956,9 +2296,9 @@
1956 2296 return obj;
1957 2297 }
1958 2298
1959 2299 module.exports = _defineProperty;
1960 -},{}],8:[function(require,module,exports){
2300 +},{}],9:[function(require,module,exports){
1961 2301 function _interopRequireDefault(obj) {
1962 2302 return obj && obj.__esModule ? obj : {
1963 2303 "default": obj
1964 2304 };
@@ -1964,9 +2304,9 @@
1964 2304 };
1965 2305 }
1966 2306
1967 2307 module.exports = _interopRequireDefault;
1968 -},{}],9:[function(require,module,exports){
2308 +},{}],10:[function(require,module,exports){
1969 2309 'use strict';
1970 2310
1971 2311 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
1972 2312
@@ -2001,9 +2341,9 @@
2001 2341 }
2002 2342
2003 2343 module.exports = compile;
2004 2344
2005 -},{"@tannin/evaluate":10,"@tannin/postfix":12}],10:[function(require,module,exports){
2345 +},{"@tannin/evaluate":11,"@tannin/postfix":13}],11:[function(require,module,exports){
2006 2346 'use strict';
2007 2347
2008 2348 /**
2009 2349 * Operator callback functions.
@@ -2117,9 +2457,9 @@
2117 2457 }
2118 2458
2119 2459 module.exports = evaluate;
2120 2460
2121 -},{}],11:[function(require,module,exports){
2461 +},{}],12:[function(require,module,exports){
2122 2462 'use strict';
2123 2463
2124 2464 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
2125 2465
@@ -2143,9 +2483,9 @@
2143 2483 }
2144 2484
2145 2485 module.exports = pluralForms;
2146 2486
2147 -},{"@tannin/compile":9}],12:[function(require,module,exports){
2487 +},{"@tannin/compile":10}],13:[function(require,module,exports){
2148 2488 'use strict';
2149 2489
2150 2490 var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
2151 2491
@@ -2273,9 +2613,9 @@
2273 2613 }
2274 2614
2275 2615 module.exports = postfix;
2276 2616
2277 -},{}],13:[function(require,module,exports){
2617 +},{}],14:[function(require,module,exports){
2278 2618 "use strict";
2279 2619
2280 2620 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2281 2621
@@ -2488,9 +2828,9 @@
2488 2828 };
2489 2829
2490 2830 exports.createI18n = createI18n;
2491 2831
2492 -},{"@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){
2493 2833 "use strict";
2494 2834
2495 2835 Object.defineProperty(exports, "__esModule", {
2496 2836 value: true
@@ -2607,9 +2947,9 @@
2607 2947 exports._nx = _nx;
2608 2948 var isRTL = i18n.isRTL.bind(i18n);
2609 2949 exports.isRTL = isRTL;
2610 2950
2611 -},{"./create-i18n":13}],15:[function(require,module,exports){
2951 +},{"./create-i18n":14}],16:[function(require,module,exports){
2612 2952 "use strict";
2613 2953
2614 2954 Object.defineProperty(exports, "__esModule", {
2615 2955 value: true
@@ -2682,9 +3022,9 @@
2682 3022 });
2683 3023
2684 3024 var _defaultI18n = require("./default-i18n");
2685 3025
2686 -},{"./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){
2687 3027 "use strict";
2688 3028
2689 3029 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2690 3030
@@ -2734,9 +3074,9 @@
2734 3074 return format;
2735 3075 }
2736 3076 }
2737 3077
2738 -},{"@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){
2739 3079 /* global window, exports, define */
2740 3080
2741 3081 !function() {
2742 3082 'use strict'
@@ -2967,9 +3307,9 @@
2967 3307 }
2968 3308 /* eslint-enable quote-props */
2969 3309 }(); // eslint-disable-line
2970 3310
2971 -},{}],18:[function(require,module,exports){
3311 +},{}],19:[function(require,module,exports){
2972 3312 /*
2973 3313 * International Telephone Input v17.0.16
2974 3314 * https://github.com/jackocnr/intl-tel-input.git
2975 3315 * Licensed under the MIT license
@@ -4321,15 +4661,15 @@
4321 4661 return iti;
4322 4662 };
4323 4663 }();
4324 4664 });
4325 -},{}],19:[function(require,module,exports){
4665 +},{}],20:[function(require,module,exports){
4326 4666 /**
4327 4667 * Exposing intl-tel-input as a component
4328 4668 */
4329 4669 module.exports = require("./build/js/intlTelInput");
4330 4670
4331 -},{"./build/js/intlTelInput":18}],20:[function(require,module,exports){
4671 +},{"./build/js/intlTelInput":19}],21:[function(require,module,exports){
4332 4672 (function (process){
4333 4673 /**
4334 4674 * Memize options object.
4335 4675 *
@@ -4498,9 +4838,9 @@
4498 4838
4499 4839 module.exports = memize;
4500 4840
4501 4841 }).call(this,require('_process'))
4502 -},{"_process":21}],21:[function(require,module,exports){
4842 +},{"_process":22}],22:[function(require,module,exports){
4503 4843 // shim for using process in browser
4504 4844 var process = module.exports = {};
4505 4845
4506 4846 // cached from whatever global is present so that test runners that stub it
@@ -4684,9 +5024,9 @@
4684 5024 throw new Error('process.chdir is not supported');
4685 5025 };
4686 5026 process.umask = function() { return 0; };
4687 5027
4688 -},{}],22:[function(require,module,exports){
5028 +},{}],23:[function(require,module,exports){
4689 5029 'use strict';
4690 5030
4691 5031 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4692 5032
@@ -4905,5 +5245,5 @@
4905 5245 };
4906 5246
4907 5247 module.exports = Tannin;
4908 5248
4909 -},{"@tannin/plural-forms":11}]},{},[2]);
5249 +},{"@tannin/plural-forms":12}]},{},[3]);