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 +566 -104 1.5.72.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');
@@ -21,9 +84,14 @@
21 84 var first = $('.sellkit-multistep-checkout-first');
22 85 var second = $('.sellkit-multistep-checkout-second');
23 86 var third = $('.sellkit-multistep-checkout-third');
24 87 var breadcrumb = $('.sellkit-checkout-widget-breadcrumb-desktop, .sellkit-checkout-widget-breadcrumb-mobile');
88 + var billingMethodA = $('[name="billing-method"].sellkit-billing-method-a');
25 89
90 + if (billingMethodA.length > 0 && billingMethodA[0].checked) {
91 + billingMethodA[0].click();
92 + }
93 +
26 94 if ('1' !== sellkit_elementor.wcNeedShipping || typeof sellkitCheckoutShipping !== 'undefined' && true === sellkitCheckoutShipping) {
27 95 third.show();
28 96 $('.sellkit-one-page-checkout-place-order').css('justify-content', 'flex-end');
29 97 }
@@ -36,9 +104,8 @@
36 104 return;
37 105 }
38 106
39 107 secondStepHeader();
40 - var secondTrigger = true;
41 108 first.hide();
42 109
43 110 if ($('.sellkit-one-page-shipping-methods').children().length > 0) {
44 111 second.show();
@@ -43,13 +110,8 @@
43 110 if ($('.sellkit-one-page-shipping-methods').children().length > 0) {
44 111 second.show();
45 112 } else {
46 113 third.show();
47 - secondTrigger = false;
48 - }
49 -
50 - if ($(window).width() > 600 && secondTrigger) {
51 - sidebar.css('background-color', '#effdf5');
52 114 } //Fix Header & wrapper height.
53 115
54 116
55 117 parent.css('height', 'auto');
@@ -58,8 +120,11 @@
58 120 $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
59 121
60 122 breadcrumb.find('.information').removeClass('current').addClass('blue-line');
61 123 breadcrumb.find('.shipping').addClass('current').removeClass('inactive');
124 + $('html, body').animate({
125 + scrollTop: $('.sellkit-checkout-left-column').offset().top
126 + }, 500);
62 127 });
63 128 $('.go-to-first').on('click', function () {
64 129 first.show();
65 130 third.hide();
@@ -69,8 +134,11 @@
69 134 sidebar.css('background-color', 'transparent'); // Manage Breadcrumb.
70 135
71 136 breadcrumb.find('.information').removeClass('blue-line').addClass('current');
72 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);
73 141 });
74 142 $('.go-to-payment').on('click', function () {
75 143 // Checks if required fields are filled.
76 144 var requiredFieldsError = checkRequiredFields();
@@ -91,8 +159,11 @@
91 159 $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
92 160
93 161 breadcrumb.find('.shipping').addClass('blue-line').removeClass('current');
94 162 breadcrumb.find('.payment').addClass('current').removeClass('inactive');
163 + $('html, body').animate({
164 + scrollTop: $('.sellkit-checkout-left-column').offset().top
165 + }, 500);
95 166 });
96 167 $('.go-to-second , .go-to-second-header').on('click', function () {
97 168 // Checks if required fields are filled.
98 169 var requiredFieldsError = checkRequiredFields();
@@ -100,10 +171,8 @@
100 171 if (true === requiredFieldsError) {
101 172 return;
102 173 }
103 174
104 - var secondTrigger = true;
105 -
106 175 if ($('.sellkit-one-page-shipping-methods').children().length > 0) {
107 176 second.show();
108 177 first.hide();
109 178 } else {
@@ -108,9 +177,8 @@
108 177 first.hide();
109 178 } else {
110 179 second.hide();
111 180 first.show();
112 - secondTrigger = false;
113 181 }
114 182
115 183 third.hide();
116 184 parent.css('height', 'auto');
@@ -115,17 +183,15 @@
115 183 third.hide();
116 184 parent.css('height', 'auto');
117 185 second.css('height', 'auto');
118 186 second.css('height', $('.sellkit-checkout-left-column').height());
119 - $('.multistep-headers').css('height', 'auto');
187 + $('.multistep-headers').css('height', 'auto'); // Manage Breadcrumb.
120 188
121 - if ($(window).width() > 600 && secondTrigger) {
122 - sidebar.css('background-color', '#effdf5');
123 - } // Manage Breadcrumb.
124 -
125 -
126 189 breadcrumb.find('.shipping').addClass('current').removeClass('blue-line');
127 190 breadcrumb.find('.payment').removeClass('current').addClass('inactive');
191 + $('html, body').animate({
192 + scrollTop: $('.sellkit-checkout-left-column').offset().top
193 + }, 500);
128 194 }); //Inject login wrapper & functionality.
129 195
130 196 emailProcess();
131 197 LoginProcess(); // Billing method toggle.
@@ -145,8 +211,9 @@
145 211 sellkitCheckoutUpdateCartItem();
146 212 applyCoupon();
147 213 couponToggle();
148 214 fixGatewayListUi();
215 + sellkitDetectShippingMethodChange();
149 216 }); // Fix the payment gateways divider issue.
150 217
151 218 fixGatewayListUi(); //Run when page loads.
152 219
@@ -167,9 +234,23 @@
167 234 sellkitCheckoutConfigureBundleProducts(); // Order bump.
168 235
169 236 sellkitCheckoutOrderBump(); // Sellkit after ajax call is completed.
170 237
171 - sellkitAfterAjaxComplete();
238 + sellkitAfterAjaxComplete(); // Load upsell steps with popup.
239 +
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();
172 253 }
173 254
174 255 var emailProcess = function emailProcess() {
175 256 var emailField = $('#billing_email');
@@ -182,14 +263,26 @@
182 263 var usernameField = usernameWrap.find('input');
183 264 var loginBtn = $('.login-wrapper');
184 265 var createBox = $('.create-desc');
185 266 var createCheck = $('#createaccount');
186 - emailField.on('keyup', function () {
187 - var _this = this;
267 + var emailCheckTimer = null;
268 + var usernameCheckTimer = null;
188 269
189 - setTimeout(function () {
190 - var emailAddress = $(_this).val();
270 + var getCurrentEmailValue = function getCurrentEmailValue() {
271 + return $('#billing_email').val();
272 + };
191 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 +
192 285 if (_.isEmpty(emailAddress)) {
193 286 emptyError.show().css('display', 'inline-block');
194 287 errorText.hide();
195 288 createBox.css('display', 'none');
@@ -223,19 +316,27 @@
223 316 email: emailAddress,
224 317 dataType: 'json',
225 318 nonce: sellkit_elementor.nonce
226 319 }).done(function () {
320 + if (emailAddress !== getCurrentEmailValue()) {
321 + return;
322 + }
323 +
227 324 successResultEmailCheck();
228 325 }).fail(function () {
326 + if (emailAddress !== getCurrentEmailValue()) {
327 + return;
328 + }
329 +
229 330 errorResultEmailCheck();
230 331 });
231 332 }, 500);
232 333 });
233 - usernameField.on('keyup', function () {
234 - var _this2 = this;
235 -
236 - setTimeout(function () {
237 - 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();
238 339 wp.ajax.post({
239 340 action: 'sellkit_checkout_ajax_handler',
240 341 sub_action: 'search_for_username',
241 342 user: userValue,
@@ -241,10 +342,18 @@
241 342 user: userValue,
242 343 dataType: 'json',
243 344 nonce: sellkit_elementor.nonce
244 345 }).done(function () {
346 + if (userValue !== getCurrentUsernameValue()) {
347 + return;
348 + }
349 +
245 350 $('.sellkit-checkout-widget-username-error').hide();
246 351 }).fail(function () {
352 + if (userValue !== getCurrentUsernameValue()) {
353 + return;
354 + }
355 +
247 356 $('.sellkit-checkout-widget-username-error').show();
248 357 });
249 358 }, 500);
250 359 }); // If user is going to create account show password and username fields if exists.
@@ -321,14 +430,14 @@
321 430
322 431 var secondStepHeader = function secondStepHeader() {
323 432 var email = $('#billing_email');
324 433 $('.multistep-headers > .info-a > div > .mail').text(email.val());
325 - var countryValue = $('#shipping_country option:selected').text();
326 - var state = $('#sellkit-shipping_state');
327 - var postcode = $('#shipping_postcode');
328 - var city = $('#shipping_city');
329 - var addressA = $('#shipping_address_1');
330 - 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');
331 440 var finalAddress = postcode.val() ? ', ' + postcode.val() : '';
332 441 finalAddress += addressB.val() ? ', ' + addressB.val() : '';
333 442 finalAddress += addressA.val() ? ', ' + addressA.val() : '';
334 443 finalAddress += city.val() ? ', ' + city.val() : '';
@@ -345,34 +454,84 @@
345 454 $('.multistep-headers > .info-c > div > .method').text(methodTxt);
346 455 };
347 456
348 457 var manageBillingMethod = function manageBillingMethod() {
349 - var billingWrap = $('.sellkit-one-page-checkout-billing');
350 - var methodA = billingWrap.find('.method-a');
351 - 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 + */
352 468
353 - var name = $('#shipping_first_name');
354 - var last = $('#shipping_last_name');
355 - var addressA = $('#shipping_address_1');
356 - var addressB = $('#shipping_address_2');
357 - var country = $('#shipping_country');
358 - var state = $('#sellkit-shipping_state');
359 - var postcode = $('#shipping_postcode');
360 - var city = $('#shipping_city');
361 - methodA.on('click', function () {
362 - billingWrap.find('.woocommerce-billing-fields__field-wrapper').hide();
363 - $('#billing_first_name').val(name.val());
364 - $('#billing_last_name').val(last.val());
365 - $('#billing_address_1').val(addressA.val());
366 - $('#billing_address_2').val(addressB.val());
367 - $('#billing_country').val(country.val()).trigger('change');
368 - $('#sellkit-billing_state').val(state.val()).trigger('change');
369 - $('#billing_postcode').val(postcode.val());
370 - $('#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();
371 521 });
372 - 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 () {
373 523 $('.inner_wrapper').css('height', 'auto');
374 - 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);
375 534 });
376 535 };
377 536
378 537 var mobileSummary = function mobileSummary() {
@@ -379,20 +538,22 @@
379 538 if ($(window).width() < 600) {
380 539 $('#order_review').addClass('sellkit-mobile-multistep-order-summary');
381 540 }
382 541
383 - 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');
384 543 var wrap = $('.summary_toggle');
385 544 toggleBtn.on('click', function () {
386 545 $('#order_review').toggle();
387 546
388 - if ('Hide order summary' === toggleBtn.text()) {
547 + if ('Hide order summary' === wrap.find('.title').text()) {
389 548 wrap.find('.title').text((0, _i18n.__)('Show order summary', 'sellkit'));
390 - 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();
391 551 wrap.css('border-bottom-width', '0px');
392 552 } else {
393 553 wrap.find('.title').text((0, _i18n.__)('Hide order summary', 'sellkit'));
394 - 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();
395 556 wrap.css('border-bottom-width', '1px');
396 557 }
397 558
398 559 var parent = $('#sellkit-checkout-multistep-inner-wrap');
@@ -402,9 +563,9 @@
402 563
403 564 var fieldFocus = function fieldFocus() {
404 565 var $fields = $('.sellkit-checkout-local-fields').find('input, select, hidden, textarea, #sellkit-billing_state ,#sellkit-shipping_state, .validate-email');
405 566 $fields.each(function () {
406 - var _this3 = this;
567 + var _this = this;
407 568
408 569 var miniTitle = $(this).parent().parent().parent().find('.mini-title');
409 570 var $thisValue = $(this).val(); // On load.
410 571
@@ -416,34 +577,34 @@
416 577 } // On change/focusOut
417 578
418 579
419 580 $(this).on('change input focusout', function (e) {
420 - var changedValue = $(_this3).val();
581 + var changedValue = $(_this).val();
421 582
422 - if (changedValue || $(_this3).find('option').length) {
423 - $(_this3).addClass('filled');
424 - $(_this3).removeClass('empty');
425 - $(_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');
426 587 } else {
427 - $(_this3).addClass('empty');
428 - $(_this3).removeClass('filled');
429 - $(_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();
430 591 } // On focusout validate fields.
431 592
432 593
433 594 if ('focusout' === e.type) {
434 - FieldsMiniTitles($(_this3), 'focusout');
435 - 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.
436 597
437 598 if (parent.hasClass('validate-required')) {
438 - if ('INPUT' === _this3.nodeName && 'checkbox' === $(_this3).attr('type')) {
439 - if (!_this3.checked) {
599 + if ('INPUT' === _this.nodeName && 'checkbox' === $(_this).attr('type')) {
600 + if (!_this.checked) {
440 601 parent.find('.sellkit-required-validation').css('display', 'inline-flex');
441 602 return;
442 603 }
443 604 }
444 605
445 - if (_.isEmpty($(_this3).val())) {
606 + if (_.isEmpty($(_this).val())) {
446 607 parent.find('.sellkit-required-validation').css('display', 'inline-flex');
447 608 return;
448 609 }
449 610
@@ -451,9 +612,9 @@
451 612 } // Required validation of this field if exists, passed successfully. now postcode validation.
452 613
453 614
454 615 if (parent.hasClass('sellkit-checkout-fields-validation-postcode')) {
455 - var postcodeVal = $(_this3).val();
616 + var postcodeVal = $(_this).val();
456 617
457 618 if (_.isEmpty(postcodeVal)) {
458 619 return;
459 620 } // Check field type to get related country value. we can't validate without country code.
@@ -458,9 +619,9 @@
458 619 return;
459 620 } // Check field type to get related country value. we can't validate without country code.
460 621
461 622
462 - var postcodeName = $(_this3).attr('name');
623 + var postcodeName = $(_this).attr('name');
463 624 var postcodeCountry = $('#billing_country');
464 625
465 626 if (postcodeName.includes('shipping')) {
466 627 postcodeCountry = $('#shipping_country');
@@ -481,30 +642,30 @@
481 642 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
482 643 }
483 644
484 645 parent.find('.sellkit-checkout-field-global-errors').hide().text('');
485 - postcodeValidation(postcodeVal, countryCode, $(_this3));
646 + postcodeValidation(postcodeVal, countryCode, $(_this));
486 647 } // Phone validation using woocommerce way.
487 648
488 649
489 650 if (parent.hasClass('sellkit-checkout-fields-validation-phone')) {
490 - var phone = $(_this3).val();
651 + var phone = $(_this).val();
491 652
492 653 if (_.isEmpty(phone)) {
493 654 return;
494 655 }
495 656
496 - phoneNumberValidation(phone, $(_this3));
657 + phoneNumberValidation(phone, $(_this));
497 658 }
498 659 }
499 660
500 - if ('change' === e.type && ('billing_country' === $(_this3).attr('id') || 'shipping_country' === $(_this3).attr('id'))) {
501 - var _countryCode = $(_this3).val();
661 + if ('change' === e.type && ('billing_country' === $(_this).attr('id') || 'shipping_country' === $(_this).attr('id'))) {
662 + var _countryCode = $(_this).val();
502 663
503 664 var states = wcCountries[_countryCode];
504 665 var state = 'sellkit-shipping_state';
505 666
506 - if ('billing_country' === $(_this3).attr('id')) {
667 + if ('billing_country' === $(_this).attr('id')) {
507 668 state = 'sellkit-billing_state';
508 669 }
509 670
510 671 var stateField = document.getElementById(state);
@@ -512,8 +673,12 @@
512 673 if (_.isNull(stateField)) {
513 674 return;
514 675 }
515 676
677 + if (!_.isObject(states)) {
678 + return;
679 + }
680 +
516 681 $(stateField).empty();
517 682
518 683 for (var keys in states) {
519 684 var option = document.createElement('option');
@@ -811,8 +976,30 @@
811 976 });
812 977 });
813 978 };
814 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 +/**
815 1002 * Toggle coupon form on click event.
816 1003 *
817 1004 * @since 1.2.5
818 1005 */
@@ -1061,8 +1248,12 @@
1061 1248 */
1062 1249
1063 1250
1064 1251 var sellkitSetAddressDetails = function sellkitSetAddressDetails() {
1252 + if (window.sellkitSuppressBillingAddressAjax) {
1253 + return;
1254 + }
1255 +
1065 1256 wp.ajax.post({
1066 1257 action: 'sellkit_checkout_ajax_handler',
1067 1258 sub_action: 'set_customer_details_ajax',
1068 1259 country: document.querySelector('#billing_country') ? document.getElementById('billing_country').value : '',
@@ -1303,10 +1494,232 @@
1303 1494 $('.wc_payment_methods hr.sellkit-checkout-widget-divider').each(function (index, item) {
1304 1495 $(item).css('display', $(item).prevAll('li').first().css('display'));
1305 1496 });
1306 1497 };
1498 +/**
1499 + * Prevents checkout form from being submitted before checking upsell offers.
1500 + *
1501 + * @since 1.6.2
1502 + */
1307 1503
1308 -},{"@wordpress/i18n":15}],2:[function(require,module,exports){
1504 +
1505 +var sellkitLoadUpsellSteps = function sellkitLoadUpsellSteps() {
1506 + $('form.checkout').on('checkout_place_order', function () {
1507 + if ($('#sellkit_funnel_has_upsell').length > 0 && 'upsell' === $('#sellkit_funnel_has_upsell').val()) {
1508 + sellkitCallUpsell();
1509 + return false;
1510 + }
1511 +
1512 + return true;
1513 + });
1514 +};
1515 +/**
1516 + * After press place order button, call ajax to make decision for popups.
1517 + *
1518 + * @since 1.6.2
1519 + */
1520 +
1521 +
1522 +var sellkitCallUpsell = function sellkitCallUpsell() {
1523 + var loadingIcon = function loadingIcon() {
1524 + var icon = sellkit_elementor.url.assets + 'img/spinner.png',
1525 + img = document.createElement('img');
1526 + img.setAttribute('src', icon);
1527 + img.setAttribute('width', '35px');
1528 + img.setAttribute('class', 'sellkit-upsell-downsell-preloader');
1529 + return img;
1530 + };
1531 +
1532 + var onEmpty = function onEmpty() {
1533 + $('body').css('overflow', 'auto');
1534 + $('.sellkit_funnel_upsell_popup').css('display', 'none');
1535 + $('#sellkit_funnel_has_upsell').val('done');
1536 + $('#place_order').trigger('click');
1537 + };
1538 +
1539 + var loadNew = function loadNew(data) {
1540 + $('body').css('overflow', 'hidden');
1541 + $('.sellkit-upsell-popup').css('display', 'none');
1542 + $('#sellkit_funnel_popup_step_id').val(data.next_id);
1543 + $('.sellkit_funnel_upsell_popup').css({
1544 + 'z-index': '100',
1545 + display: 'none'
1546 + });
1547 + $('.sellkit_funnel_upsell_popup_' + data.next_id).css({
1548 + 'z-index': 101,
1549 + display: 'block'
1550 + });
1551 + };
1552 +
1553 + var onSuccess = function onSuccess(data) {
1554 + setTimeout(function () {
1555 + if ('thankyou' === data.next_type) {
1556 + onEmpty();
1557 + }
1558 +
1559 + if ('upsell' === data.next_type || 'downsell' === data.next_type) {
1560 + loadNew(data);
1561 + sellkitUpsellOperation();
1562 + }
1563 + }, 1000);
1564 + };
1565 +
1566 + var sellkitUpsellOperation = function sellkitUpsellOperation() {
1567 + $('.sellkit_funnel_upsell_popup .sellkit-upsell-accept-button').off().on('click', function () {
1568 + var parent = $(this).parents('.sellkit_funnel_upsell_popup'),
1569 + upsellId = parent.find('.identify').val(),
1570 + checkoutId = $('#sellkit_current_page_id').val();
1571 + $('.sellkit-upsell-popup').css('display', 'flex');
1572 + parent.find('.sellkit-upsell-updating').addClass('active');
1573 + wp.ajax.post({
1574 + action: 'sellkit_checkout_ajax_handler',
1575 + sub_action: 'perform_upsell_accept_button',
1576 + upsell_id: upsellId,
1577 + checkout_id: checkoutId,
1578 + nonce: sellkit_elementor.nonce
1579 + }).done(function (data) {
1580 + $(document.body).trigger('update_checkout');
1581 + parent.find('.sellkit-upsell-updating').removeClass('active');
1582 + parent.find('.sellkit-upsell-accepted').addClass('active');
1583 + updateSellkitPriceField(data.upsell_prices);
1584 + onSuccess(data);
1585 + }).fail(function (data) {
1586 + // eslint-disable-next-line no-console
1587 + console.error(data);
1588 + });
1589 + });
1590 + $('.sellkit_funnel_upsell_popup .sellkit-upsell-reject-button').off().on('click', function () {
1591 + var parent = $(this).parents('.sellkit_funnel_upsell_popup'),
1592 + upsellId = parent.find('.identify').val(),
1593 + icon = loadingIcon();
1594 + parent.find('.sellkit-upsell-downsell-preloader').remove();
1595 + $(icon).insertAfter(parent.find('.sellkit-accept-reject-button-widget .sellkit-upsell-reject-button'));
1596 + wp.ajax.post({
1597 + action: 'sellkit_checkout_ajax_handler',
1598 + sub_action: 'perform_upsell_reject_button',
1599 + upsell_id: upsellId,
1600 + nonce: sellkit_elementor.nonce
1601 + }).done(function (data) {
1602 + onSuccess(data);
1603 + }).fail(function (data) {
1604 + // eslint-disable-next-line no-console
1605 + console.error(data);
1606 + });
1607 + });
1608 + };
1609 +
1610 + var stepId = $('#sellkit_current_page_id').val(),
1611 + img = loadingIcon();
1612 + $('button[type=submit]').find('img').remove();
1613 + $('button[type=submit]').append(img);
1614 + wp.ajax.post({
1615 + action: 'sellkit_checkout_ajax_handler',
1616 + sub_action: 'call_funnel_popups',
1617 + step: stepId,
1618 + nonce: sellkit_elementor.nonce
1619 + }).done(function (data) {
1620 + onSuccess(data);
1621 + $('button[type=submit]').find('img').remove();
1622 + }).fail(function (data) {
1623 + // eslint-disable-next-line no-console
1624 + console.error(data);
1625 + $('button[type=submit]').find('img').remove();
1626 + });
1627 +};
1628 +
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){
1309 1722 "use strict";
1310 1723
1311 1724 (function ($) {
1312 1725 var SellkitFrontend = function SellkitFrontend() {
@@ -1331,9 +1744,9 @@
1331 1744
1332 1745 window.sellkitFrontend = new SellkitFrontend();
1333 1746 })(jQuery);
1334 1747
1335 -},{"./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){
1336 1749 "use strict";
1337 1750
1338 1751 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1339 1752
@@ -1510,12 +1923,61 @@
1510 1923 return;
1511 1924 }
1512 1925
1513 1926 _.each(addressFields, function (input) {
1514 - new google.maps.places.Autocomplete(input, {
1927 + var autocomplete = new google.maps.places.Autocomplete(input, {
1515 1928 types: ['geocode'],
1516 1929 fields: ['address_components']
1517 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 + });
1518 1980 });
1519 1981 }
1520 1982 });
1521 1983
@@ -1524,9 +1986,9 @@
1524 1986 $element: $scope
1525 1987 });
1526 1988 }
1527 1989
1528 -},{"./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){
1529 1991 "use strict";
1530 1992
1531 1993 Object.defineProperty(exports, "__esModule", {
1532 1994 value: true
@@ -1683,9 +2145,9 @@
1683 2145 }
1684 2146 };
1685 2147 exports["default"] = _default;
1686 2148
1687 -},{}],5:[function(require,module,exports){
2149 +},{}],6:[function(require,module,exports){
1688 2150 "use strict";
1689 2151
1690 2152 Object.defineProperty(exports, "__esModule", {
1691 2153 value: true
@@ -1765,9 +2227,9 @@
1765 2227 }
1766 2228 };
1767 2229 exports["default"] = _default;
1768 2230
1769 -},{"intl-tel-input":19}],6:[function(require,module,exports){
2231 +},{"intl-tel-input":20}],7:[function(require,module,exports){
1770 2232 "use strict";
1771 2233
1772 2234 Object.defineProperty(exports, "__esModule", {
1773 2235 value: true
@@ -1817,9 +2279,9 @@
1817 2279 $element: $scope
1818 2280 });
1819 2281 }
1820 2282
1821 -},{}],7:[function(require,module,exports){
2283 +},{}],8:[function(require,module,exports){
1822 2284 function _defineProperty(obj, key, value) {
1823 2285 if (key in obj) {
1824 2286 Object.defineProperty(obj, key, {
1825 2287 value: value,
@@ -1834,9 +2296,9 @@
1834 2296 return obj;
1835 2297 }
1836 2298
1837 2299 module.exports = _defineProperty;
1838 -},{}],8:[function(require,module,exports){
2300 +},{}],9:[function(require,module,exports){
1839 2301 function _interopRequireDefault(obj) {
1840 2302 return obj && obj.__esModule ? obj : {
1841 2303 "default": obj
1842 2304 };
@@ -1842,9 +2304,9 @@
1842 2304 };
1843 2305 }
1844 2306
1845 2307 module.exports = _interopRequireDefault;
1846 -},{}],9:[function(require,module,exports){
2308 +},{}],10:[function(require,module,exports){
1847 2309 'use strict';
1848 2310
1849 2311 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
1850 2312
@@ -1879,9 +2341,9 @@
1879 2341 }
1880 2342
1881 2343 module.exports = compile;
1882 2344
1883 -},{"@tannin/evaluate":10,"@tannin/postfix":12}],10:[function(require,module,exports){
2345 +},{"@tannin/evaluate":11,"@tannin/postfix":13}],11:[function(require,module,exports){
1884 2346 'use strict';
1885 2347
1886 2348 /**
1887 2349 * Operator callback functions.
@@ -1995,9 +2457,9 @@
1995 2457 }
1996 2458
1997 2459 module.exports = evaluate;
1998 2460
1999 -},{}],11:[function(require,module,exports){
2461 +},{}],12:[function(require,module,exports){
2000 2462 'use strict';
2001 2463
2002 2464 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
2003 2465
@@ -2021,9 +2483,9 @@
2021 2483 }
2022 2484
2023 2485 module.exports = pluralForms;
2024 2486
2025 -},{"@tannin/compile":9}],12:[function(require,module,exports){
2487 +},{"@tannin/compile":10}],13:[function(require,module,exports){
2026 2488 'use strict';
2027 2489
2028 2490 var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
2029 2491
@@ -2151,9 +2613,9 @@
2151 2613 }
2152 2614
2153 2615 module.exports = postfix;
2154 2616
2155 -},{}],13:[function(require,module,exports){
2617 +},{}],14:[function(require,module,exports){
2156 2618 "use strict";
2157 2619
2158 2620 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2159 2621
@@ -2366,9 +2828,9 @@
2366 2828 };
2367 2829
2368 2830 exports.createI18n = createI18n;
2369 2831
2370 -},{"@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){
2371 2833 "use strict";
2372 2834
2373 2835 Object.defineProperty(exports, "__esModule", {
2374 2836 value: true
@@ -2485,9 +2947,9 @@
2485 2947 exports._nx = _nx;
2486 2948 var isRTL = i18n.isRTL.bind(i18n);
2487 2949 exports.isRTL = isRTL;
2488 2950
2489 -},{"./create-i18n":13}],15:[function(require,module,exports){
2951 +},{"./create-i18n":14}],16:[function(require,module,exports){
2490 2952 "use strict";
2491 2953
2492 2954 Object.defineProperty(exports, "__esModule", {
2493 2955 value: true
@@ -2560,9 +3022,9 @@
2560 3022 });
2561 3023
2562 3024 var _defaultI18n = require("./default-i18n");
2563 3025
2564 -},{"./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){
2565 3027 "use strict";
2566 3028
2567 3029 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2568 3030
@@ -2612,9 +3074,9 @@
2612 3074 return format;
2613 3075 }
2614 3076 }
2615 3077
2616 -},{"@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){
2617 3079 /* global window, exports, define */
2618 3080
2619 3081 !function() {
2620 3082 'use strict'
@@ -2845,9 +3307,9 @@
2845 3307 }
2846 3308 /* eslint-enable quote-props */
2847 3309 }(); // eslint-disable-line
2848 3310
2849 -},{}],18:[function(require,module,exports){
3311 +},{}],19:[function(require,module,exports){
2850 3312 /*
2851 3313 * International Telephone Input v17.0.16
2852 3314 * https://github.com/jackocnr/intl-tel-input.git
2853 3315 * Licensed under the MIT license
@@ -4199,15 +4661,15 @@
4199 4661 return iti;
4200 4662 };
4201 4663 }();
4202 4664 });
4203 -},{}],19:[function(require,module,exports){
4665 +},{}],20:[function(require,module,exports){
4204 4666 /**
4205 4667 * Exposing intl-tel-input as a component
4206 4668 */
4207 4669 module.exports = require("./build/js/intlTelInput");
4208 4670
4209 -},{"./build/js/intlTelInput":18}],20:[function(require,module,exports){
4671 +},{"./build/js/intlTelInput":19}],21:[function(require,module,exports){
4210 4672 (function (process){
4211 4673 /**
4212 4674 * Memize options object.
4213 4675 *
@@ -4376,9 +4838,9 @@
4376 4838
4377 4839 module.exports = memize;
4378 4840
4379 4841 }).call(this,require('_process'))
4380 -},{"_process":21}],21:[function(require,module,exports){
4842 +},{"_process":22}],22:[function(require,module,exports){
4381 4843 // shim for using process in browser
4382 4844 var process = module.exports = {};
4383 4845
4384 4846 // cached from whatever global is present so that test runners that stub it
@@ -4562,9 +5024,9 @@
4562 5024 throw new Error('process.chdir is not supported');
4563 5025 };
4564 5026 process.umask = function() { return 0; };
4565 5027
4566 -},{}],22:[function(require,module,exports){
5028 +},{}],23:[function(require,module,exports){
4567 5029 'use strict';
4568 5030
4569 5031 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4570 5032
@@ -4783,5 +5245,5 @@
4783 5245 };
4784 5246
4785 5247 module.exports = Tannin;
4786 5248
4787 -},{"@tannin/plural-forms":11}]},{},[2]);
5249 +},{"@tannin/plural-forms":12}]},{},[3]);