Changeset 3481811
- Timestamp:
- 03/13/2026 09:42:18 AM (2 weeks ago)
- Location:
- yayextra/trunk
- Files:
-
- 20 added
- 2 deleted
- 18 edited
-
assets/css/yayextra.css (modified) (3 diffs)
-
assets/dist/css/main.css (deleted)
-
assets/dist/js/main.bundle.js (deleted)
-
assets/dist/js/main.js (added)
-
assets/dist/style.css (added)
-
assets/images (added)
-
assets/images/avatar.png (added)
-
assets/images/bg-pro.png (added)
-
assets/images/employee-avatars.png (added)
-
assets/images/favicon.svg (added)
-
assets/images/logos-payment.svg (added)
-
assets/images/money-back.svg (added)
-
assets/images/preview.jpg (added)
-
assets/js/yayextra.js (modified) (96 diffs)
-
includes/Classes/ProductPage.php (modified) (17 diffs)
-
includes/Helper/Database.php (modified) (3 diffs)
-
includes/Helper/Utils.php (modified) (5 diffs)
-
includes/Init/Ajax.php (modified) (6 diffs)
-
includes/Init/CustomPostType.php (modified) (5 diffs)
-
includes/Init/Settings.php (modified) (16 diffs)
-
includes/Integrations (added)
-
includes/Integrations.php (added)
-
includes/Integrations/YayCurrency.php (added)
-
includes/Register (added)
-
includes/Register/RegisterDev.php (added)
-
includes/Register/RegisterFacade.php (added)
-
includes/Register/RegisterProd.php (added)
-
includes/Register/ScriptName.php (added)
-
includes/Templates/button_field.php (modified) (2 diffs)
-
includes/Templates/checkbox_field.php (modified) (3 diffs)
-
includes/Templates/dropdown_field.php (modified) (3 diffs)
-
includes/Templates/radio_field.php (modified) (3 diffs)
-
includes/Templates/swatches_field.php (modified) (2 diffs)
-
includes/Utils (added)
-
includes/Utils/SingletonTrait.php (added)
-
includes/YayCommerceMenu/OtherPluginsMenu.php (modified) (2 diffs)
-
includes/YayCommerceMenu/RegisterMenu.php (modified) (2 diffs)
-
includes/YayCommerceMenu/views/other-plugins-content.php (modified) (4 diffs)
-
readme.txt (modified) (4 diffs)
-
yayextra.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
yayextra/trunk/assets/css/yayextra.css
r3317357 r3481811 96 96 color: #fff; 97 97 text-align: center; 98 padding: 8px 21px;99 border-radius: 3px;98 padding: 6px 10px; 99 border-radius: 4px; 100 100 z-index: 10; 101 101 opacity: 0; … … 103 103 max-width: 250px; 104 104 box-sizing: border-box; 105 font-size: 1 5px;106 line-height: 20px;105 font-size: 14px; 106 line-height: 1.4; 107 107 } 108 108 … … 119 119 transform: translateX(-50%); 120 120 margin-bottom: 11px; 121 } 122 123 .yayextra-opt-button .yayextra-tooltip-top { 124 margin-bottom: 15px; 125 } 126 .yayextra-opt-button .yayextra-tooltip-bottom { 127 margin-bottom: 15px; 121 128 } 122 129 -
yayextra/trunk/assets/js/yayextra.js
r3383835 r3481811 1 1 (function ($) { 2 'use strict';2 "use strict"; 3 3 const optionSetList = YAYE_CLIENT_DATA.OPTION_SET_LIST; 4 4 const yayeSettings = YAYE_CLIENT_DATA.settings; 5 5 $(document).ready(function ($) { 6 7 6 // Add to cart by ajax 8 $( 'form button.add_to_cart_button.ajax_add_to_cart' ).on( 'click', function() { 9 if($('.yayextra-option-field-wrap').length > 0) { 10 $( 'form.cart' ).trigger('submit'); 7 $("form button.add_to_cart_button.ajax_add_to_cart").on( 8 "click", 9 function () { 10 if ($(".yayextra-option-field-wrap").length > 0) { 11 $("form.cart").trigger("submit"); 12 } 11 13 } 12 });14 ); 13 15 14 16 $.each(optionSetList, function (_, optionSet) { 15 if ( 1 === parseInt(optionSet.status)) {17 if (1 === parseInt(optionSet.status)) { 16 18 const optionSetId = optionSet.id; 17 19 let referenceObject = {}; 18 20 $.each(optionSet.options, function (_, option) { 19 21 $.each(option.logics, function (_, logic) { 20 if (logic.option && logic.option.id) {22 if (logic.option && logic.option.id) { 21 23 if (logic.option.id in referenceObject) { 22 24 referenceObject[logic.option.id].push(option); … … 32 34 return; 33 35 } 34 36 35 37 if (checkLogic(optionSetId, option)) { 36 38 showOption(option); … … 39 41 hideReferenceOption(optionSetId, option, referenceObject); 40 42 } 41 43 42 44 $.each(option.logics, function (_, logic) { 43 45 createEvent(optionSetId, option, logic, referenceObject); … … 48 50 49 51 // Show/hide adition description of Select option field. 50 const selectOptionFields = $( '.yayextra-option-field-wrap select');52 const selectOptionFields = $(".yayextra-option-field-wrap select"); 51 53 if (selectOptionFields.length > 0) { 52 54 $.each(selectOptionFields, function (idx, el) { 53 55 showHideAdditionDescSelectOpt(el); 54 56 55 $(el).on( 'change', function () {57 $(el).on("change", function () { 56 58 showHideAdditionDescSelectOpt(this); 57 59 getTotalCost(); … … 61 63 62 64 // Catch option swatched Event 63 const swatchOptionFields = $( '.yayextra-option-field-swatches-label');65 const swatchOptionFields = $(".yayextra-option-field-swatches-label"); 64 66 if (swatchOptionFields.length > 0) { 65 67 $.each(swatchOptionFields, function (idx, el) { 66 const inputEl = $(el).siblings( 'input');67 const optId = $(inputEl).attr( 'data-opt-id');68 const optImg = $(inputEl).attr( 'data-opt-img');69 const prodImg = $(inputEl).attr( 'data-product-img');70 const optSetId = $(inputEl).attr( 'data-optset-id');68 const inputEl = $(el).siblings("input"); 69 const optId = $(inputEl).attr("data-opt-id"); 70 const optImg = $(inputEl).attr("data-opt-img"); 71 const prodImg = $(inputEl).attr("data-product-img"); 72 const optSetId = $(inputEl).attr("data-optset-id"); 71 73 72 74 let isMultiSelectable = false; 73 const optionFieldWraps = $(el).parents( '.yayextra-option-field-wrap');75 const optionFieldWraps = $(el).parents(".yayextra-option-field-wrap"); 74 76 if (optionFieldWraps.length > 0) { 75 77 const optFieldWrap = optionFieldWraps[0]; 76 78 isMultiSelectable = 77 $(optFieldWrap).attr( 'data-multi-selectable') == 1 ? true : false;79 $(optFieldWrap).attr("data-multi-selectable") == 1 ? true : false; 78 80 } 79 81 80 82 // Check input is checked init ? 81 if ($(inputEl).is( ':checked')) {82 $(el).addClass( 'checked');83 if ($(inputEl).is(":checked")) { 84 $(el).addClass("checked"); 83 85 84 86 showHideAdditionDescSwatchesButtonOpt(inputEl); … … 91 93 $.each(optionValues, function (idx, optVal) { 92 94 if ( 93 'image'=== optVal.swatchesType &&95 "image" === optVal.swatchesType && 94 96 optionValChecked === optVal.value && 95 97 optId === optionData.id … … 103 105 104 106 // Event click; 105 $(el).on( 'click', function () {106 if (!$(inputEl).is( ':checked')) {107 $(el).addClass( 'checked');108 $(inputEl).prop( 'checked', true);107 $(el).on("click", function () { 108 if (!$(inputEl).is(":checked")) { 109 $(el).addClass("checked"); 110 $(inputEl).prop("checked", true); 109 111 110 112 showHideAdditionDescSwatchesButtonOpt(inputEl); … … 117 119 $.each(optionValues, function (idx, optVal) { 118 120 if ( 119 'image'=== optVal.swatchesType &&121 "image" === optVal.swatchesType && 120 122 optionValChecked === optVal.value && 121 123 optId === optionData.id … … 129 131 } 130 132 } else { 131 $(el).removeClass('checked'); 132 $(inputEl).prop('checked', false); 133 $(el).removeClass("checked"); 134 $(inputEl).prop("checked", false); 135 showHideAdditionDescSwatchesButtonOpt(inputEl); 133 136 } 134 137 … … 136 139 if (!isMultiSelectable) { 137 140 const optSwatchesSiblings = $(el) 138 .closest( '.yayextra-opt-swatches')141 .closest(".yayextra-opt-swatches") 139 142 .siblings(); 140 143 if (optSwatchesSiblings.length > 0) { 141 144 $.each(optSwatchesSiblings, function (idx, el1) { 142 145 $(el1) 143 .find('.yayextra-option-field-swatches-label') 144 .removeClass('checked'); 145 if ( 146 $(el1) 147 .find('input') 148 .is(':checked') 149 ) { 150 $(el1) 151 .find('input') 152 .prop('checked', false); 146 .find(".yayextra-option-field-swatches-label") 147 .removeClass("checked"); 148 if ($(el1).find("input").is(":checked")) { 149 $(el1).find("input").prop("checked", false); 153 150 } 154 151 }); … … 156 153 } 157 154 158 inputEl.trigger( 'change');155 inputEl.trigger("change"); 159 156 }); 160 157 }); … … 162 159 163 160 // Catch option button type Event 164 const buttonOptions = $( '.yayextra-option-button-label');161 const buttonOptions = $(".yayextra-option-button-label"); 165 162 if (buttonOptions.length > 0) { 166 163 $.each(buttonOptions, function (idx, el) { 167 164 // const labelEl = $(el).siblings('.yayextra-option-button-label'); 168 const inputEl = $(el).siblings( 'input');165 const inputEl = $(el).siblings("input"); 169 166 170 167 let isMultiSelectable = false; 171 const optionFieldWraps = $(el).parents( '.yayextra-option-field-wrap');168 const optionFieldWraps = $(el).parents(".yayextra-option-field-wrap"); 172 169 if (optionFieldWraps.length > 0) { 173 170 const optFieldWrap = optionFieldWraps[0]; 174 171 isMultiSelectable = 175 $(optFieldWrap).attr( 'data-multi-selectable') == 1 ? true : false;172 $(optFieldWrap).attr("data-multi-selectable") == 1 ? true : false; 176 173 } 177 174 178 175 // Check input is checked init ? 179 if ($(inputEl).is( ':checked')) {180 $(el).addClass( 'checked');176 if ($(inputEl).is(":checked")) { 177 $(el).addClass("checked"); 181 178 182 179 showHideAdditionDescSwatchesButtonOpt(inputEl); … … 184 181 185 182 // Event click; 186 $(el).on( 'click', function () {187 if (!$(inputEl).is( ':checked')) {188 $(el).addClass( 'checked');189 $(inputEl).prop( 'checked', true);183 $(el).on("click", function () { 184 if (!$(inputEl).is(":checked")) { 185 $(el).addClass("checked"); 186 $(inputEl).prop("checked", true); 190 187 191 188 showHideAdditionDescSwatchesButtonOpt(inputEl); 192 189 } else { 193 $(el).removeClass('checked'); 194 $(inputEl).prop('checked', false); 190 $(el).removeClass("checked"); 191 $(inputEl).prop("checked", false); 192 showHideAdditionDescSwatchesButtonOpt(inputEl); 195 193 } 196 194 … … 198 196 if (!isMultiSelectable) { 199 197 const optButtonSiblings = $(el) 200 .closest( '.yayextra-opt-button')198 .closest(".yayextra-opt-button") 201 199 .siblings(); 202 200 if (optButtonSiblings.length > 0) { 203 201 $.each(optButtonSiblings, function (idx, el1) { 204 202 $(el1) 205 .find('.yayextra-option-button-label') 206 .removeClass('checked'); 207 if ( 208 $(el1) 209 .find('input') 210 .is(':checked') 211 ) { 212 $(el1) 213 .find('input') 214 .prop('checked', false); 203 .find(".yayextra-option-button-label") 204 .removeClass("checked"); 205 if ($(el1).find("input").is(":checked")) { 206 $(el1).find("input").prop("checked", false); 215 207 } 216 208 }); … … 218 210 } 219 211 220 inputEl.trigger( 'change');212 inputEl.trigger("change"); 221 213 }); 222 214 }); 223 215 } 224 216 225 const datePickerFields = $( '.yayextra-date-picker');217 const datePickerFields = $(".yayextra-date-picker"); 226 218 if (datePickerFields.length > 0) { 227 219 $.each(datePickerFields, function (idx, el) { 228 const datePickerFieldId = $(el).attr( 'id');229 $( '#'+ datePickerFieldId).datepicker();230 }); 231 } 232 233 const timePickerInputFields = $( '.yayextra-time-picker-input');220 const datePickerFieldId = $(el).attr("id"); 221 $("#" + datePickerFieldId).datepicker(); 222 }); 223 } 224 225 const timePickerInputFields = $(".yayextra-time-picker-input"); 234 226 if (timePickerInputFields.length > 0) { 235 227 $.each(timePickerInputFields, function (idx, el) { 236 $(el).on( 'click', function () {237 const timePickerFieldInputId = $(this).attr( 'id');238 const timePickerDivClass = '.'+ timePickerFieldInputId;228 $(el).on("click", function () { 229 const timePickerFieldInputId = $(this).attr("id"); 230 const timePickerDivClass = "." + timePickerFieldInputId; 239 231 $(timePickerDivClass).show(); 240 232 $(timePickerDivClass).datetimepicker({ 241 baseCls: 'yayextra-datetimepicker',233 baseCls: "yayextra-datetimepicker", 242 234 date: new Date(), 243 viewMode: 'HM',235 viewMode: "HM", 244 236 onDateChange: function () { 245 237 const datetime = new Date(this.getValue()).toLocaleTimeString( 246 238 [], 247 239 { 248 hour: '2-digit',249 minute: '2-digit',240 hour: "2-digit", 241 minute: "2-digit", 250 242 } 251 243 ); 252 $( '#'+ timePickerFieldInputId).val(datetime);253 $( '#' + timePickerFieldInputId).trigger('change');244 $("#" + timePickerFieldInputId).val(datetime); 245 $("#" + timePickerFieldInputId).trigger("change"); 254 246 }, 255 247 onOk: function () { … … 259 251 260 252 // Hide timepicker icon plus, minus 261 const timePickerIconI = $( '.yayextra-option-field-wrap').find(262 '.yayextra-datetimepicker i'253 const timePickerIconI = $(".yayextra-option-field-wrap").find( 254 ".yayextra-datetimepicker i" 263 255 ); 264 256 if (timePickerIconI.length > 0) { 265 257 $.each(timePickerIconI, function (idx, el) { 266 $(el) 267 .parent('td') 268 .hide(); 258 $(el).parent("td").hide(); 269 259 }); 270 260 } … … 274 264 275 265 $(document).mousedown(function (e) { 276 if ($(e.target).closest( '.yayextra-datetimepicker').length === 0) {277 $( '.yayextra-time-picker').hide();266 if ($(e.target).closest(".yayextra-datetimepicker").length === 0) { 267 $(".yayextra-time-picker").hide(); 278 268 } 279 269 }); … … 406 396 407 397 // Validate value of Text field - start 408 const optionTextFields = $('.yayextra-option-field-wrap input.yayextra-text'); 398 const optionTextFields = $( 399 ".yayextra-option-field-wrap input.yayextra-text" 400 ); 409 401 if (optionTextFields.length > 0) { 410 402 $.each(optionTextFields, function (_, el) { 411 $(el).on( 'keyup', function () {412 let elMessage = $(this).siblings( '.error-message-text');403 $(el).on("keyup", function () { 404 let elMessage = $(this).siblings(".error-message-text"); 413 405 if ($(this).val().length > 0) { 414 elMessage.html( '').hide();415 const textFormat = $(this).attr( 'data-text-format');416 if ( 'url'=== textFormat) {406 elMessage.html("").hide(); 407 const textFormat = $(this).attr("data-text-format"); 408 if ("url" === textFormat) { 417 409 validateUrl($(this).val(), elMessage); 418 } else if ( 'email'=== textFormat) {410 } else if ("email" === textFormat) { 419 411 validateEmail($(this).val(), elMessage); 420 412 } … … 432 424 if (optionCheckboxRadioFields.length > 0) { 433 425 $.each(optionCheckboxRadioFields, function (_, el) { 434 $(el).on( 'click', function () {426 $(el).on("click", function () { 435 427 getTotalCost(); 436 428 }); … … 440 432 // Event swatches change 441 433 const optionSwatchesButtonFields = $( 442 '.yayextra-option-field-wrap .yayextra-opt-swatches input,.yayextra-option-field-wrap .yayextra-opt-button input'434 ".yayextra-option-field-wrap .yayextra-opt-swatches input,.yayextra-option-field-wrap .yayextra-opt-button input" 443 435 ); 444 436 if (optionSwatchesButtonFields.length > 0) { 445 437 $.each(optionSwatchesButtonFields, function (_, el) { 446 $(el).on( 'change', function () {438 $(el).on("change", function () { 447 439 getTotalCost(); 448 440 }); … … 451 443 452 444 // Event Textarea click 453 const optionTextareaFields = $( '.yayextra-option-field-wrap textarea');445 const optionTextareaFields = $(".yayextra-option-field-wrap textarea"); 454 446 if (optionTextareaFields.length > 0) { 455 447 $.each(optionTextareaFields, function (_, el) { 456 $(el).on( 'keyup', function () {448 $(el).on("keyup", function () { 457 449 getTotalCost(); 458 450 }); … … 461 453 462 454 // Event input click 463 const optionNumberFields = $('.yayextra-option-field-wrap input[type="number"]'); 455 const optionNumberFields = $( 456 '.yayextra-option-field-wrap input[type="number"]' 457 ); 464 458 if (optionNumberFields.length > 0) { 465 459 $.each(optionNumberFields, function (_, el) { 466 $(el).on( 'input change', function () {460 $(el).on("input change", function () { 467 461 getTotalCost(); 468 462 }); … … 472 466 // Event input yayextra-date-picker/yayextra-time-picker-input change 473 467 const optionDateTimeFields = $( 474 '.yayextra-option-field-wrap input.yayextra-date-picker, .yayextra-option-field-wrap input.yayextra-time-picker-input'468 ".yayextra-option-field-wrap input.yayextra-date-picker, .yayextra-option-field-wrap input.yayextra-time-picker-input" 475 469 ); 476 470 if (optionDateTimeFields.length > 0) { 477 471 $.each(optionDateTimeFields, function (_, el) { 478 $(el).on( 'change', function () {472 $(el).on("change", function () { 479 473 getTotalCost(); 480 474 }); … … 483 477 484 478 // Event product quantity input 485 $( '.quantity input.qty').on('change', function () {479 $(".quantity input.qty").on("change", function () { 486 480 getTotalCost(); 487 481 }); … … 490 484 getTotalCost(); 491 485 492 // Events of variations product 493 if($('.product form.variations_form').length > 0){ 494 let productVariationForm = $('.product form.variations_form'); 486 // Events of variations product 487 if ($(".product form.variations_form").length > 0) { 488 $(".yaye-product-price-original").attr("data-product-price-original", 0); 489 490 let productVariationForm = $(".product form.variations_form"); 495 491 let variationProductsMeta = getVariationProductsMeta(); 496 492 // if ($('.yayextra-total-price').length > 0 || $('.yayextra-extra-subtotal-price').length > 0) { 497 let prodVariationData = {};498 productVariationForm.find('.variations select').each(function() {499 let attrName = $(this).data('attribute_name') || $(this).attr('name');500 let value = $(this).val() || '';501 prodVariationData[ attrName] = value;502 503 // Event select;504 $(this).on('change', function () {505 let valueE = $(this).val() || '';506 if( valueE ){507 prodVariationData[ attrName] = valueE;508 509 const variationProductPrice = updateTotalPriceByVariationProduct(variationProductsMeta, prodVariationData);510 511 // Change option addition price for percetage type512 if ( variationProductPrice ) {513 changeAdditionCostByVariationProduct(variationProductPrice) 514 } else {515 changeAdditionCostByVariationProduct(0)516 }493 let prodVariationData = {}; 494 productVariationForm.find(".variations select").each(function () { 495 let attrName = $(this).data("attribute_name") || $(this).attr("name"); 496 let value = $(this).val() || ""; 497 prodVariationData[attrName] = value; 498 499 // Event select; 500 $(this).on("change", function () { 501 let valueE = $(this).val() || ""; 502 if (valueE) { 503 prodVariationData[attrName] = valueE; 504 505 const variationProductPrice = updateTotalPriceByVariationProduct( 506 variationProductsMeta, 507 prodVariationData 508 ); 509 510 // Change option addition price for percetage type 511 if (variationProductPrice) { 512 changeAdditionCostByVariationProduct(variationProductPrice); 517 513 } else { 518 changeAdditionCostByVariationProduct(0) 519 $('.yayextra-total-price .total-price').attr('data-total-price', 0); 514 changeAdditionCostByVariationProduct(0); 520 515 } 521 522 getTotalCost(); 523 }) 516 } else { 517 changeAdditionCostByVariationProduct(0); 518 $(".yayextra-total-price .total-price").attr("data-total-price", 0); 519 $(".yaye-product-price-original").attr( 520 "data-product-price-original", 521 0 522 ); 523 } 524 525 getTotalCost(); 524 526 }); 525 526 if( Object.keys(prodVariationData).length === 0 ) { 527 $('.yayextra-total-price .total-price').attr('data-total-price', 0); 528 // getTotalCost(); 529 } else { 530 for (const attr in prodVariationData) { 531 if( '' === prodVariationData[attr] ){ 532 $('.yayextra-total-price .total-price').attr('data-total-price', 0); 533 // getTotalCost(); 534 break; 535 } 527 }); 528 529 if (Object.keys(prodVariationData).length === 0) { 530 $(".yayextra-total-price .total-price").attr("data-total-price", 0); 531 $(".yaye-product-price-original").attr( 532 "data-product-price-original", 533 0 534 ); 535 // getTotalCost(); 536 } else { 537 for (const attr in prodVariationData) { 538 if ("" === prodVariationData[attr]) { 539 $(".yayextra-total-price .total-price").attr("data-total-price", 0); 540 $(".yaye-product-price-original").attr( 541 "data-product-price-original", 542 0 543 ); 544 // getTotalCost(); 545 break; 536 546 } 537 547 } 538 539 const variationProductPriceInit = updateTotalPriceByVariationProduct(variationProductsMeta, prodVariationData); 540 541 // Change option addition price for percetage type 542 if ( variationProductPriceInit ) { 543 changeAdditionCostByVariationProduct(variationProductPriceInit) 544 } else { 545 changeAdditionCostByVariationProduct(0) 546 } 547 548 getTotalCost(); 548 } 549 550 const variationProductPriceInit = updateTotalPriceByVariationProduct( 551 variationProductsMeta, 552 prodVariationData 553 ); 554 555 // Change option addition price for percetage type 556 if (variationProductPriceInit) { 557 changeAdditionCostByVariationProduct(variationProductPriceInit); 558 } else { 559 changeAdditionCostByVariationProduct(0); 560 } 561 562 getTotalCost(); 549 563 // } 550 564 } … … 552 566 // Init set Visibility option id into hidden field 553 567 getVisibilityOption(); 554 555 568 }); 556 569 … … 559 572 const optionWrapper = $("[data-option-field-id='" + option.id + "']"); 560 573 561 let fieldDataObjs = optionWrapper.find( 'input');562 if ( 'dropdown'== option.type.value) {563 fieldDataObjs = optionWrapper.find( 'select');564 } else if ( 'textarea'== option.type.value) {565 fieldDataObjs = optionWrapper.find( 'textarea');574 let fieldDataObjs = optionWrapper.find("input"); 575 if ("dropdown" == option.type.value) { 576 fieldDataObjs = optionWrapper.find("select"); 577 } else if ("textarea" == option.type.value) { 578 fieldDataObjs = optionWrapper.find("textarea"); 566 579 } 567 580 568 581 if (optionWrapper.length) { 569 582 optionWrapper.show(); 570 583 for (const fieldDataObj of fieldDataObjs) { 571 $(fieldDataObj).prop( 'disabled', false);584 $(fieldDataObj).prop("disabled", false); 572 585 } 573 586 } 574 587 575 588 getTotalCost(); 576 589 getVisibilityOption(); … … 587 600 588 601 function hideOption(option) { 589 if ( option && option.id) {602 if (option && option.id) { 590 603 const optionWrapper = $("[data-option-field-id='" + option.id + "']"); 591 604 592 let fieldDataObjs = optionWrapper.find( 'input');593 if ( 'dropdown'== option.type.value) {594 fieldDataObjs = optionWrapper.find( 'select');595 } else if ( 'textarea'== option.type.value) {596 fieldDataObjs = optionWrapper.find( 'textarea');605 let fieldDataObjs = optionWrapper.find("input"); 606 if ("dropdown" == option.type.value) { 607 fieldDataObjs = optionWrapper.find("select"); 608 } else if ("textarea" == option.type.value) { 609 fieldDataObjs = optionWrapper.find("textarea"); 597 610 } 598 611 599 612 if (optionWrapper.length) { 600 613 optionWrapper.hide(); 601 614 for (const fieldDataObj of fieldDataObjs) { 602 $(fieldDataObj).prop( 'disabled', true);615 $(fieldDataObj).prop("disabled", true); 603 616 } 604 617 } 605 618 resetElement(option); 606 619 607 620 getTotalCost(); 608 621 getVisibilityOption(); … … 619 632 function resetElement(option) { 620 633 const currentField = $("[data-option-field-id='" + option.id + "']"); 621 const currentFieldType = currentField.attr( 'data-option-field-type');634 const currentFieldType = currentField.attr("data-option-field-type"); 622 635 if ( 623 'text'=== currentFieldType ||624 'number'=== currentFieldType ||625 'date_picker'=== currentFieldType ||626 'time_picker'=== currentFieldType636 "text" === currentFieldType || 637 "number" === currentFieldType || 638 "date_picker" === currentFieldType || 639 "time_picker" === currentFieldType 627 640 ) { 628 const element = currentField.find('input'); 629 element.val(''); 630 } else if ( 'textarea' === currentFieldType ) { 631 const element = currentField.find('textarea'); 632 element.val(''); 633 } else if (['radio', 'checkbox', 'button', 'swatches', 'button_multi', 'swatches_multi'].includes(currentFieldType)) { 634 const elements = currentField.find('input'); 641 const element = currentField.find("input"); 642 element.val(""); 643 } else if ("textarea" === currentFieldType) { 644 const element = currentField.find("textarea"); 645 element.val(""); 646 } else if ( 647 [ 648 "radio", 649 "checkbox", 650 "button", 651 "swatches", 652 "button_multi", 653 "swatches_multi", 654 ].includes(currentFieldType) 655 ) { 656 const elements = currentField.find("input"); 635 657 $.each(elements, function (index, element) { 636 if(option.optionValues[index] && option.optionValues[index].isDefault) { 658 if ( 659 option.optionValues[index] && 660 option.optionValues[index].isDefault 661 ) { 637 662 element.checked = option.optionValues[index].isDefault; 638 663 } 639 664 }); 640 } else if ( 'dropdown'=== currentFieldType) {641 const element = currentField.find( 'select');665 } else if ("dropdown" === currentFieldType) { 666 const element = currentField.find("select"); 642 667 const findingDefault = option.optionValues.find( 643 668 (option) => option.isDefault … … 648 673 function checkTextLogic(optionSetId, logic) { 649 674 const optionId = 650 typeof logic.option !== 'undefined'675 typeof logic.option !== "undefined" 651 676 ? logic.option.value 652 677 : logic.optionId.value; 653 678 654 679 let logicVal = logic.value; 655 if( undefined === logicVal|| ( Array.isArray(logicVal) && null === logicVal[0])) { 680 if ( 681 undefined === logicVal || 682 (Array.isArray(logicVal) && null === logicVal[0]) 683 ) { 656 684 logicVal = ""; 657 685 } 658 686 659 687 const fieldLogic = $( 660 "input[name='option_field_data[" + optionSetId + ']['+ optionId + "]']"661 ); 662 663 if (fieldLogic.prop( 'disabled')) return false;688 "input[name='option_field_data[" + optionSetId + "][" + optionId + "]']" 689 ); 690 691 if (fieldLogic.prop("disabled")) return false; 664 692 665 693 const fieldLogicVal = fieldLogic.val(); 666 694 667 if ( 'match'=== logic.comparation.value) {695 if ("match" === logic.comparation.value) { 668 696 if (fieldLogicVal === logicVal) return true; 669 697 } 670 if ( 'not_match'=== logic.comparation.value) {698 if ("not_match" === logic.comparation.value) { 671 699 if (fieldLogicVal !== logicVal) return true; 672 700 } 673 if ( 'contains'=== logic.comparation.value && fieldLogicVal) {701 if ("contains" === logic.comparation.value && fieldLogicVal) { 674 702 if (fieldLogicVal.includes(logicVal)) return true; 675 703 } … … 678 706 function checkTextareaLogic(optionSetId, logic) { 679 707 const optionId = 680 typeof logic.option !== 'undefined'708 typeof logic.option !== "undefined" 681 709 ? logic.option.value 682 710 : logic.optionId.value; 683 711 684 712 let logicVal = logic.value; 685 if( undefined === logicVal || ( Array.isArray(logicVal) && null === logicVal[0])) { 713 if ( 714 undefined === logicVal || 715 (Array.isArray(logicVal) && null === logicVal[0]) 716 ) { 686 717 logicVal = ""; 687 718 } 688 719 689 720 const fieldLogic = $( 690 "textarea[name='option_field_data[" + optionSetId + '][' + optionId + "]']" 691 ); 692 693 if (fieldLogic.prop('disabled')) return false; 721 "textarea[name='option_field_data[" + 722 optionSetId + 723 "][" + 724 optionId + 725 "]']" 726 ); 727 728 if (fieldLogic.prop("disabled")) return false; 694 729 695 730 const fieldLogicVal = fieldLogic.val(); 696 731 697 if ( 'match'=== logic.comparation.value) {732 if ("match" === logic.comparation.value) { 698 733 if (fieldLogicVal === logicVal) return true; 699 734 } 700 if ( 'not_match'=== logic.comparation.value) {735 if ("not_match" === logic.comparation.value) { 701 736 if (fieldLogicVal !== logicVal) return true; 702 737 } 703 if ( 'contains'=== logic.comparation.value && fieldLogicVal) {738 if ("contains" === logic.comparation.value && fieldLogicVal) { 704 739 if (fieldLogicVal.includes(logicVal)) return true; 705 740 } … … 708 743 function checkNumberLogic(optionSetId, logic) { 709 744 const optionId = 710 typeof logic.option !== 'undefined'745 typeof logic.option !== "undefined" 711 746 ? logic.option.value 712 747 : logic.optionId.value; 713 748 714 749 const fieldLogic = $( 715 "input[name='option_field_data[" + optionSetId + ']['+ optionId + "]']"716 ); 717 718 if (fieldLogic.prop( 'disabled')) return false;750 "input[name='option_field_data[" + optionSetId + "][" + optionId + "]']" 751 ); 752 753 if (fieldLogic.prop("disabled")) return false; 719 754 720 755 const fieldLogicVal = parseFloat(fieldLogic.val()); 721 756 722 if ( 'NaN'== fieldLogicVal) return false;723 724 if ( 'equal'=== logic.comparation.value) {757 if ("NaN" == fieldLogicVal) return false; 758 759 if ("equal" === logic.comparation.value) { 725 760 if (fieldLogicVal == parseFloat(logic.value)) return true; 726 } else if ( 'less_than'=== logic.comparation.value) {761 } else if ("less_than" === logic.comparation.value) { 727 762 if (fieldLogicVal < parseFloat(logic.value)) return true; 728 } else if ( 'greater_than'=== logic.comparation.value) {763 } else if ("greater_than" === logic.comparation.value) { 729 764 if (fieldLogicVal > parseFloat(logic.value)) return true; 730 } else if ( 'less_than_or_equal'=== logic.comparation.value) {765 } else if ("less_than_or_equal" === logic.comparation.value) { 731 766 if (fieldLogicVal <= parseFloat(logic.value)) return true; 732 } else if ( 'greater_than_or_equal'=== logic.comparation.value) {767 } else if ("greater_than_or_equal" === logic.comparation.value) { 733 768 if (fieldLogicVal >= parseFloat(logic.value)) return true; 734 769 } … … 737 772 function checkCheckboxLogic(optionSetId, logic) { 738 773 const optionId = 739 typeof logic.option !== 'undefined'774 typeof logic.option !== "undefined" 740 775 ? logic.option.value 741 776 : logic.optionId.value; … … 743 778 const checkboxes = $( 744 779 "input[name='option_field_data[" + 745 optionSetId +746 ']['+747 optionId +748 "][]']:checked"749 ); 750 if (checkboxes.prop( 'disabled')) return false;780 optionSetId + 781 "][" + 782 optionId + 783 "][]']:checked" 784 ); 785 if (checkboxes.prop("disabled")) return false; 751 786 752 787 let values = []; 753 788 if (Array.isArray(logic.value)) { 754 789 values = logic.value.map((v) => v.value); 755 } else if ( logic.value) {790 } else if (logic.value) { 756 791 values.push(logic.value.value); 757 792 } … … 759 794 values.includes($(checkbox).val()) 760 795 ); 761 if (logic.comparation.value === 'is_one_of') {796 if (logic.comparation.value === "is_one_of") { 762 797 if (findingResult === undefined) return false; 763 798 return true; … … 769 804 function checkRadioLogic(optionSetId, logic) { 770 805 const optionId = 771 typeof logic.option !== 'undefined'806 typeof logic.option !== "undefined" 772 807 ? logic.option.value 773 808 : logic.optionId.value; … … 775 810 const radio = $( 776 811 "input[name='option_field_data[" + 777 optionSetId + 778 '][' + 779 optionId + 780 "]']:checked" 781 ); 782 if (radio.prop('disabled')) return false; 783 784 const logicValue = Array.isArray(logic.value) ? logic.value[0].value : logic.value.value; 785 if (logic.comparation.value === 'is') { 812 optionSetId + 813 "][" + 814 optionId + 815 "]']:checked" 816 ); 817 if (radio.prop("disabled")) return false; 818 819 const logicValue = Array.isArray(logic.value) 820 ? logic.value[0].value 821 : logic.value.value; 822 if (logic.comparation.value === "is") { 786 823 return logicValue === radio.val(); 787 824 } … … 790 827 function checkButtonLogic(optionSetId, logic) { 791 828 const optionId = 792 typeof logic.option !== 'undefined'829 typeof logic.option !== "undefined" 793 830 ? logic.option.value 794 831 : logic.optionId.value; … … 796 833 const buttons = $( 797 834 "input[name='option_field_data[" + 798 optionSetId +799 ']['+800 optionId +801 "][]']:checked"835 optionSetId + 836 "][" + 837 optionId + 838 "][]']:checked" 802 839 ); 803 840 … … 807 844 }); 808 845 809 if (buttons.prop('disabled')) return false; 810 811 const logicValue = Array.isArray(logic.value) ? logic.value[0].value : logic.value.value; 846 if (buttons.prop("disabled")) return false; 847 848 const logicValue = Array.isArray(logic.value) 849 ? logic.value[0].value 850 : logic.value.value; 812 851 const findingResult = buttonVals.includes(logicValue); 813 852 814 if (logic.comparation.value === 'is') {853 if (logic.comparation.value === "is") { 815 854 if (findingResult) return true; 816 855 return false; … … 821 860 function checkButtonMultiLogic(optionSetId, logic) { 822 861 const optionId = 823 typeof logic.option !== 'undefined'862 typeof logic.option !== "undefined" 824 863 ? logic.option.value 825 864 : logic.optionId.value; … … 827 866 const buttones = $( 828 867 "input[name='option_field_data[" + 829 optionSetId +830 ']['+831 optionId +832 "][]']:checked"833 ); 834 if (buttones.prop( 'disabled')) return false;868 optionSetId + 869 "][" + 870 optionId + 871 "][]']:checked" 872 ); 873 if (buttones.prop("disabled")) return false; 835 874 836 875 let values = []; 837 876 if (Array.isArray(logic.value)) { 838 877 values = logic.value.map((v) => v.value); 839 } else if ( logic.value) {878 } else if (logic.value) { 840 879 values.push(logic.value.value); 841 880 } … … 843 882 values.includes($(button).val()) 844 883 ); 845 if (logic.comparation.value === 'is_one_of') {884 if (logic.comparation.value === "is_one_of") { 846 885 if (findingResult === undefined) return false; 847 886 return true; … … 853 892 function checkSelectLogic(optionSetId, logic) { 854 893 const optionId = 855 typeof logic.option !== 'undefined'894 typeof logic.option !== "undefined" 856 895 ? logic.option.value 857 896 : logic.optionId.value; 858 897 859 898 const fieldLogic = $( 860 "select[name='option_field_data[" + optionSetId + ']['+ optionId + "]']"861 ); 862 863 if (fieldLogic.prop( 'disabled')) return false;899 "select[name='option_field_data[" + optionSetId + "][" + optionId + "]']" 900 ); 901 902 if (fieldLogic.prop("disabled")) return false; 864 903 865 904 const fieldLogicVal = String(fieldLogic.val()); 866 const logicValue = Array.isArray(logic.value) ? logic.value[0].value : logic.value.value; 867 if ('is' === logic.comparation.value) { 905 const logicValue = Array.isArray(logic.value) 906 ? logic.value[0].value 907 : logic.value.value; 908 if ("is" === logic.comparation.value) { 868 909 if (fieldLogicVal == String(logicValue)) return true; 869 } else if ( 'is_not'=== logic.comparation.value) {910 } else if ("is_not" === logic.comparation.value) { 870 911 if (fieldLogicVal != String(logicValue)) return true; 871 912 } … … 874 915 function checkSwatchesLogic(optionSetId, logic) { 875 916 const optionId = 876 typeof logic.option !== 'undefined'917 typeof logic.option !== "undefined" 877 918 ? logic.option.value 878 919 : logic.optionId.value; … … 880 921 const swatches = $( 881 922 "input[name='option_field_data[" + 882 optionSetId +883 ']['+884 optionId +885 "][]']:checked"923 optionSetId + 924 "][" + 925 optionId + 926 "][]']:checked" 886 927 ); 887 928 … … 891 932 }); 892 933 893 if (swatches.prop('disabled')) return false; 894 895 const logicValue = Array.isArray(logic.value) ? logic.value[0].value : logic.value.value; 934 if (swatches.prop("disabled")) return false; 935 936 const logicValue = Array.isArray(logic.value) 937 ? logic.value[0].value 938 : logic.value.value; 896 939 const findingResult = swatchesVals.includes(logicValue); 897 940 898 if (logic.comparation.value === 'is') {941 if (logic.comparation.value === "is") { 899 942 if (findingResult) return true; 900 943 return false; … … 905 948 function checkSwatchesMultiLogic(optionSetId, logic) { 906 949 const optionId = 907 typeof logic.option !== 'undefined'950 typeof logic.option !== "undefined" 908 951 ? logic.option.value 909 952 : logic.optionId.value; … … 911 954 const swatches = $( 912 955 "input[name='option_field_data[" + 913 optionSetId +914 ']['+915 optionId +916 "][]']:checked"917 ); 918 if (swatches.prop( 'disabled')) return false;956 optionSetId + 957 "][" + 958 optionId + 959 "][]']:checked" 960 ); 961 if (swatches.prop("disabled")) return false; 919 962 920 963 let values = []; 921 964 if (Array.isArray(logic.value)) { 922 965 values = logic.value.map((v) => v.value); 923 } else if ( logic.value) {966 } else if (logic.value) { 924 967 values.push(logic.value.value); 925 968 } … … 927 970 values.includes($(swatch).val()) 928 971 ); 929 if (logic.comparation.value === 'is_one_of') {972 if (logic.comparation.value === "is_one_of") { 930 973 if (findingResult === undefined) return false; 931 974 return true; … … 937 980 function checkDatePickerLogic(optionSetId, logic) { 938 981 const optionId = 939 typeof logic.option !== 'undefined'982 typeof logic.option !== "undefined" 940 983 ? logic.option.value 941 984 : logic.optionId.value; 942 985 943 986 const fieldLogic = $( 944 "input[name='option_field_data[" + optionSetId + ']['+ optionId + "]']"945 ); 946 947 if (fieldLogic.prop( 'disabled')) return false;987 "input[name='option_field_data[" + optionSetId + "][" + optionId + "]']" 988 ); 989 990 if (fieldLogic.prop("disabled")) return false; 948 991 949 992 const fieldLogicVal = fieldLogic.val(); … … 953 996 const currentDate = new Date(fieldLogicVal).toLocaleDateString(); 954 997 955 if ( 'between'=== logic.comparation.value) {998 if ("between" === logic.comparation.value) { 956 999 if (startDate <= currentDate && currentDate <= endDate) return true; 957 1000 } 958 if ( 'not_between'=== logic.comparation.value) {1001 if ("not_between" === logic.comparation.value) { 959 1002 if (startDate > currentDate || currentDate > endDate) return true; 960 1003 } … … 963 1006 function checkTimePickerLogic(optionSetId, logic) { 964 1007 const optionId = 965 typeof logic.option !== 'undefined'1008 typeof logic.option !== "undefined" 966 1009 ? logic.option.value 967 1010 : logic.optionId.value; 968 1011 969 1012 const fieldLogic = $( 970 "input[name='option_field_data[" + optionSetId + ']['+ optionId + "]']"971 ); 972 973 if (fieldLogic.prop( 'disabled')) return false;1013 "input[name='option_field_data[" + optionSetId + "][" + optionId + "]']" 1014 ); 1015 1016 if (fieldLogic.prop("disabled")) return false; 974 1017 975 1018 const startTime = convertTimeAMPM( 976 1019 new Date(logic.value.from_time).toLocaleTimeString([], { 977 hour: '2-digit',978 minute: '2-digit',1020 hour: "2-digit", 1021 minute: "2-digit", 979 1022 }) 980 1023 ); 981 1024 const endTime = convertTimeAMPM( 982 1025 new Date(logic.value.to_time).toLocaleTimeString([], { 983 hour: '2-digit',984 minute: '2-digit',1026 hour: "2-digit", 1027 minute: "2-digit", 985 1028 }) 986 1029 ); … … 989 1032 if (null === currentTime) return false; 990 1033 991 if ( 'between'=== logic.comparation.value) {1034 if ("between" === logic.comparation.value) { 992 1035 if (startTime <= currentTime && currentTime <= endTime) return true; 993 1036 } 994 if ( 'not_between'=== logic.comparation.value) {1037 if ("not_between" === logic.comparation.value) { 995 1038 if (startTime > currentTime || currentTime > endTime) return true; 996 1039 } … … 999 1042 1000 1043 function getLogicResult(optionSetId, logic) { 1001 if( !logic.option || ! logic.option.type || !logic.option.type.value ) return false; 1002 1003 if (logic.option.type.value === 'text') 1044 if (!logic.option || !logic.option.type || !logic.option.type.value) 1045 return false; 1046 1047 if (logic.option.type.value === "text") 1004 1048 return checkTextLogic(optionSetId, logic); 1005 if (logic.option.type.value === 'textarea')1049 if (logic.option.type.value === "textarea") 1006 1050 return checkTextareaLogic(optionSetId, logic); 1007 if (logic.option.type.value === 'number')1051 if (logic.option.type.value === "number") 1008 1052 return checkNumberLogic(optionSetId, logic); 1009 if (logic.option.type.value === 'checkbox')1053 if (logic.option.type.value === "checkbox") 1010 1054 return checkCheckboxLogic(optionSetId, logic); 1011 if (logic.option.type.value === 'radio')1055 if (logic.option.type.value === "radio") 1012 1056 return checkRadioLogic(optionSetId, logic); 1013 if (logic.option.type.value === 'button')1057 if (logic.option.type.value === "button") 1014 1058 return checkButtonLogic(optionSetId, logic); 1015 if (logic.option.type.value === 'button_multi')1059 if (logic.option.type.value === "button_multi") 1016 1060 return checkButtonMultiLogic(optionSetId, logic); 1017 if (logic.option.type.value === 'dropdown')1061 if (logic.option.type.value === "dropdown") 1018 1062 return checkSelectLogic(optionSetId, logic); 1019 if (logic.option.type.value === 'swatches')1063 if (logic.option.type.value === "swatches") 1020 1064 return checkSwatchesLogic(optionSetId, logic); 1021 if (logic.option.type.value === 'swatches_multi')1065 if (logic.option.type.value === "swatches_multi") 1022 1066 return checkSwatchesMultiLogic(optionSetId, logic); 1023 if (logic.option.type.value === 'date_picker')1067 if (logic.option.type.value === "date_picker") 1024 1068 return checkDatePickerLogic(optionSetId, logic); 1025 if (logic.option.type.value === 'time_picker')1069 if (logic.option.type.value === "time_picker") 1026 1070 return checkTimePickerLogic(optionSetId, logic); 1027 1071 } … … 1029 1073 const { matchType, displayType } = option; 1030 1074 let result = false; 1031 if (matchType.value === 'any') {1075 if (matchType.value === "any") { 1032 1076 const check = option.logics.find((logic) => { 1033 1077 return getLogicResult(optionSetId, logic); … … 1040 1084 if (check === undefined) result = true; 1041 1085 } 1042 if (displayType.value === 'display') return result;1086 if (displayType.value === "display") return result; 1043 1087 1044 1088 return !result; … … 1047 1091 const checkboxes = $( 1048 1092 "input[name='option_field_data[" + 1049 optionSetId +1050 ']['+1051 logic.option.value +1052 "][]']"1093 optionSetId + 1094 "][" + 1095 logic.option.value + 1096 "][]']" 1053 1097 ); 1054 1098 1055 1099 $.each(checkboxes, function (_, checkbox) { 1056 $(checkbox).on( 'change', function () {1100 $(checkbox).on("change", function () { 1057 1101 if (checkLogic(optionSetId, option)) { 1058 1102 showOption(option); … … 1068 1112 const radios = $( 1069 1113 "input[name='option_field_data[" + 1070 optionSetId +1071 ']['+1072 logic.option.value +1073 "]']"1114 optionSetId + 1115 "][" + 1116 logic.option.value + 1117 "]']" 1074 1118 ); 1075 1119 $.each(radios, function (_, radio) { 1076 $(radio).on( 'change', function () {1120 $(radio).on("change", function () { 1077 1121 if (checkLogic(optionSetId, option)) { 1078 1122 showOption(option); … … 1088 1132 const radios = $( 1089 1133 "input[name='option_field_data[" + 1090 optionSetId +1091 ']['+1092 logic.option.value +1093 "][]']"1134 optionSetId + 1135 "][" + 1136 logic.option.value + 1137 "][]']" 1094 1138 ); 1095 1139 $.each(radios, function (_, radio) { 1096 $(radio).on( 'change', function () {1140 $(radio).on("change", function () { 1097 1141 if (checkLogic(optionSetId, option)) { 1098 1142 showOption(option); … … 1108 1152 const texts = $( 1109 1153 "input[name='option_field_data[" + 1110 optionSetId +1111 ']['+1112 logic.option.value +1113 "]']"1154 optionSetId + 1155 "][" + 1156 logic.option.value + 1157 "]']" 1114 1158 ); 1115 1159 1116 1160 $.each(texts, function (_, text) { 1117 $(text).on( 'change', function () {1161 $(text).on("change", function () { 1118 1162 if (checkLogic(optionSetId, option)) { 1119 1163 showOption(option); … … 1129 1173 const textareas = $( 1130 1174 "textarea[name='option_field_data[" + 1131 optionSetId +1132 ']['+1133 logic.option.value +1134 "]']"1175 optionSetId + 1176 "][" + 1177 logic.option.value + 1178 "]']" 1135 1179 ); 1136 1180 1137 1181 $.each(textareas, function (_, textarea) { 1138 $(textarea).on( 'change', function () {1182 $(textarea).on("change", function () { 1139 1183 if (checkLogic(optionSetId, option)) { 1140 1184 showOption(option); … … 1150 1194 const numbers = $( 1151 1195 "input[name='option_field_data[" + 1152 optionSetId +1153 ']['+1154 logic.option.value +1155 "]']"1196 optionSetId + 1197 "][" + 1198 logic.option.value + 1199 "]']" 1156 1200 ); 1157 1201 1158 1202 $.each(numbers, function (_, number) { 1159 $(number).on( 'change', function () {1203 $(number).on("change", function () { 1160 1204 if (checkLogic(optionSetId, option)) { 1161 1205 showOption(option); … … 1171 1215 const selects = $( 1172 1216 "select[name='option_field_data[" + 1173 optionSetId +1174 ']['+1175 logic.option.value +1176 "]']"1217 optionSetId + 1218 "][" + 1219 logic.option.value + 1220 "]']" 1177 1221 ); 1178 1222 1179 1223 $.each(selects, function (_, select) { 1180 $(select).on( 'change', function () {1224 $(select).on("change", function () { 1181 1225 if (checkLogic(optionSetId, option)) { 1182 1226 showOption(option); … … 1192 1236 const swatches = $( 1193 1237 "input[name='option_field_data[" + 1194 optionSetId +1195 ']['+1196 logic.option.value +1197 "][]']"1238 optionSetId + 1239 "][" + 1240 logic.option.value + 1241 "][]']" 1198 1242 ); 1199 1243 $.each(swatches, function (_, swatch) { 1200 $(swatch).on( 'change', function () {1244 $(swatch).on("change", function () { 1201 1245 if (checkLogic(optionSetId, option)) { 1202 1246 showOption(option); … … 1212 1256 const datepickers = $( 1213 1257 "input[name='option_field_data[" + 1214 optionSetId +1215 ']['+1216 logic.option.value +1217 "]']"1258 optionSetId + 1259 "][" + 1260 logic.option.value + 1261 "]']" 1218 1262 ); 1219 1263 1220 1264 $.each(datepickers, function (_, text) { 1221 $(text).on( 'change', function () {1265 $(text).on("change", function () { 1222 1266 if (checkLogic(optionSetId, option)) { 1223 1267 showOption(option); … … 1233 1277 const timepickers = $( 1234 1278 "input[name='option_field_data[" + 1235 optionSetId +1236 ']['+1237 logic.option.value +1238 "]']"1279 optionSetId + 1280 "][" + 1281 logic.option.value + 1282 "]']" 1239 1283 ); 1240 1284 1241 1285 $.each(timepickers, function (_, text) { 1242 $(text).on( 'change', function () {1286 $(text).on("change", function () { 1243 1287 if (checkLogic(optionSetId, option)) { 1244 1288 showOption(option); … … 1253 1297 function createEvent(optionSetId, option, logic, referenceObject) { 1254 1298 const optionType = logic?.option?.type?.value; 1255 if (optionType === 'checkbox')1299 if (optionType === "checkbox") 1256 1300 createCheckboxEvent(optionSetId, option, logic, referenceObject); 1257 if (optionType === 'radio')1301 if (optionType === "radio") 1258 1302 createRadioEvent(optionSetId, option, logic, referenceObject); 1259 if (optionType === 'button' || optionType === 'button_multi')1303 if (optionType === "button" || optionType === "button_multi") 1260 1304 createButtonEvent(optionSetId, option, logic, referenceObject); 1261 if (optionType === 'text')1305 if (optionType === "text") 1262 1306 createTextEvent(optionSetId, option, logic, referenceObject); 1263 if (optionType === 'textarea')1307 if (optionType === "textarea") 1264 1308 createTextareaEvent(optionSetId, option, logic, referenceObject); 1265 if (optionType === 'number')1309 if (optionType === "number") 1266 1310 createNumberEvent(optionSetId, option, logic, referenceObject); 1267 if (optionType === 'dropdown')1311 if (optionType === "dropdown") 1268 1312 createSelectEvent(optionSetId, option, logic, referenceObject); 1269 if (optionType === 'swatches' || optionType === 'swatches_multi')1313 if (optionType === "swatches" || optionType === "swatches_multi") 1270 1314 createSwatchesEvent(optionSetId, option, logic, referenceObject); 1271 if (optionType === 'date_picker')1315 if (optionType === "date_picker") 1272 1316 createDatePickerEvent(optionSetId, option, logic, referenceObject); 1273 if (optionType === 'time_picker')1317 if (optionType === "time_picker") 1274 1318 createTimePickerEvent(optionSetId, option, logic, referenceObject); 1275 1319 } 1276 1320 function showHideAdditionDescSelectOpt(el) { 1277 const optionId = $(el).attr( 'id');1321 const optionId = $(el).attr("id"); 1278 1322 const value = el.value.replaceAll('"', '\\"'); 1279 1323 const optionDes = $("[data-option-field-id='" + optionId + "']").find( 1280 1324 '.yayextra-addition-des-dropdown[data-opt-id="' + 1281 optionId +1282 '"][data-opt-val="' +1283 value +1284 '"]'1325 optionId + 1326 '"][data-opt-val="' + 1327 value + 1328 '"]' 1285 1329 ); 1286 1330 1287 1331 if (optionDes.length > 0) { 1288 1332 optionDes.show(); 1289 optionDes.siblings( 'p.yayextra-addition-des-dropdown').hide();1333 optionDes.siblings("p.yayextra-addition-des-dropdown").hide(); 1290 1334 } else { 1291 1335 $("[data-option-field-id='" + optionId + "']") 1292 .find( '.yayextra-addition-des-dropdown')1336 .find(".yayextra-addition-des-dropdown") 1293 1337 .hide(); 1294 1338 } … … 1296 1340 1297 1341 function showHideAdditionDescSwatchesButtonOpt(el) { 1298 const optionId = $(el).attr( 'data-opt-id');1342 const optionId = $(el).attr("data-opt-id"); 1299 1343 const value = $(el).val().replaceAll('"', '\\"'); 1300 1344 1301 1345 const optionDes = $("[data-option-field-id='" + optionId + "']").find( 1302 1346 '.yayextra-addition-des-swatches-button[data-opt-id="' + 1303 optionId +1304 '"][data-opt-val="' +1305 value +1306 '"]'1347 optionId + 1348 '"][data-opt-val="' + 1349 value + 1350 '"]' 1307 1351 ); 1308 1352 1309 1353 if (optionDes.length > 0) { 1310 optionDes.show(); 1311 optionDes.siblings('p.yayextra-addition-des-swatches-button').hide(); 1354 if ($(el).is(":checked")) { 1355 optionDes.show(); 1356 } else { 1357 optionDes.hide(); 1358 } 1359 optionDes.siblings("p.yayextra-addition-des-swatches-button").hide(); 1312 1360 } else { 1313 1361 $("[data-option-field-id='" + optionId + "']") 1314 .find( '.yayextra-addition-des-swatches-button')1362 .find(".yayextra-addition-des-swatches-button") 1315 1363 .hide(); 1316 1364 } … … 1322 1370 var minutes = Number(time.match(/:(\d+)/)[1]); 1323 1371 var AMPM = time.match(/\s(.*)$/)[1]; 1324 if ((AMPM == 'PM' || AMPM == 'pm') && hours < 12) hours = hours + 12;1325 if ((AMPM == 'AM' || AMPM == 'am') && hours == 12) hours = hours - 12;1372 if ((AMPM == "PM" || AMPM == "pm") && hours < 12) hours = hours + 12; 1373 if ((AMPM == "AM" || AMPM == "am") && hours == 12) hours = hours - 12; 1326 1374 var sHours = hours.toString(); 1327 1375 var sMinutes = minutes.toString(); 1328 if (hours < 10) sHours = '0'+ sHours;1329 if (minutes < 10) sMinutes = '0'+ sMinutes;1330 return sHours + ':'+ sMinutes;1376 if (hours < 10) sHours = "0" + sHours; 1377 if (minutes < 10) sMinutes = "0" + sMinutes; 1378 return sHours + ":" + sMinutes; 1331 1379 } 1332 1380 return null; … … 1337 1385 '<div class="yayextra-notification"><div class="yayextra-notification-content">' + 1338 1386 messages + 1339 '</div></div>';1340 1341 $( '.'+ containerClass).after(notifyHtml);1387 "</div></div>"; 1388 1389 $("." + containerClass).after(notifyHtml); 1342 1390 setTimeout(function () { 1343 $( '.yayextra-notification').addClass('NslideDown');1344 $( '.yayextra-notification').remove();1391 $(".yayextra-notification").addClass("NslideDown"); 1392 $(".yayextra-notification").remove(); 1345 1393 }, 1500); 1346 1394 } … … 1352 1400 spinnerHtml += 1353 1401 '<circle class="woocommerce-spinner__circle" fill="none" stroke-width="5" stroke-linecap="round" cx="50" cy="50" r="30"></circle>'; 1354 spinnerHtml += '/<svg>';1355 spinnerHtml += '</div>';1402 spinnerHtml += "/<svg>"; 1403 spinnerHtml += "</div>"; 1356 1404 if (isShow) { 1357 if (typeof containerClass === 'string') {1358 $( '.'+ containerClass).append(spinnerHtml);1405 if (typeof containerClass === "string") { 1406 $("." + containerClass).append(spinnerHtml); 1359 1407 } else { 1360 1408 $(containerClass).append(spinnerHtml); 1361 1409 } 1362 1410 } else { 1363 $( '.yayextra-spinner').remove();1411 $(".yayextra-spinner").remove(); 1364 1412 } 1365 1413 } … … 1369 1417 if (optionSetList.length > 0) { 1370 1418 $.each(optionSetList, function (_, optionSet) { 1371 if ( optSetId == optionSet.id) {1419 if (optSetId == optionSet.id) { 1372 1420 const optionList = optionSet.options; 1373 1421 if (optionList.length > 0) { … … 1378 1426 } 1379 1427 }); 1380 if ( result) return false;1428 if (result) return false; 1381 1429 } 1382 } 1430 } 1383 1431 }); 1384 1432 } … … 1386 1434 } 1387 1435 1388 function replaceProductImage(imageUrl, setTimeOut) { 1389 let productGalleryImgList = $('.woocommerce-product-gallery').find( 1390 '.woocommerce-product-gallery__image' 1436 function replaceProductImage(imageUrlOriginal, setTimeOut) { 1437 let imageUrl = 1438 window.location.protocol !== "https:" 1439 ? imageUrlOriginal 1440 : imageUrlOriginal.replaceAll("http://", "https://"); 1441 1442 let productGalleryImgList = $(".woocommerce-product-gallery").find( 1443 ".woocommerce-product-gallery__image" 1391 1444 ); 1392 1445 1393 1446 if (productGalleryImgList.length > 0) { 1394 1447 let productGalleryImgFirst = productGalleryImgList[0]; 1395 $(productGalleryImgFirst).attr('data-thumb', imageUrl); 1396 $(productGalleryImgFirst) 1397 .find('a') 1398 .attr('href', imageUrl); 1448 $(productGalleryImgFirst).attr("data-thumb", imageUrl); 1449 $(productGalleryImgFirst).find("a").attr("href", imageUrl); 1399 1450 1400 1451 let productGalleryImgEl = $(productGalleryImgFirst).find( 1401 'img.wp-post-image'1452 "img.wp-post-image" 1402 1453 ); 1403 $(productGalleryImgEl).attr( 'src', imageUrl);1404 $(productGalleryImgEl).attr( 'data-src', imageUrl);1405 $(productGalleryImgEl).attr( 'data-large_image', imageUrl);1406 $(productGalleryImgEl).attr( 'srcset', imageUrl);1454 $(productGalleryImgEl).attr("src", imageUrl); 1455 $(productGalleryImgEl).attr("data-src", imageUrl); 1456 $(productGalleryImgEl).attr("data-large_image", imageUrl); 1457 $(productGalleryImgEl).attr("srcset", imageUrl); 1407 1458 1408 1459 if (true === setTimeOut) { 1409 1460 setTimeout(function () { 1410 1461 let productGalleryImgZoomEl = $(productGalleryImgFirst).find( 1411 'img.zoomImg'1462 "img.zoomImg" 1412 1463 ); 1413 1464 if (productGalleryImgZoomEl.length > 0) { 1414 $(productGalleryImgZoomEl).attr( 'src', imageUrl);1465 $(productGalleryImgZoomEl).attr("src", imageUrl); 1415 1466 } 1416 1467 }, 1000); 1417 1468 } else { 1418 1469 let productGalleryImgZoomEl = $(productGalleryImgFirst).find( 1419 'img.zoomImg'1470 "img.zoomImg" 1420 1471 ); 1421 1472 if (productGalleryImgZoomEl.length > 0) { 1422 $(productGalleryImgZoomEl).attr( 'src', imageUrl);1473 $(productGalleryImgZoomEl).attr("src", imageUrl); 1423 1474 } 1424 1475 } 1425 1476 } 1426 1477 1427 let productGalleryThumbList = $( '.woocommerce-product-gallery').find(1428 '.flex-control-thumbs li'1478 let productGalleryThumbList = $(".woocommerce-product-gallery").find( 1479 ".flex-control-thumbs li" 1429 1480 ); 1430 1481 1431 1482 if (productGalleryThumbList.length > 0) { 1432 1483 let productGalleryThumbFirst = productGalleryThumbList[0]; 1433 $(productGalleryThumbFirst) 1434 .find('img') 1435 .attr('src', imageUrl); 1484 $(productGalleryThumbFirst).find("img").attr("src", imageUrl); 1436 1485 } 1437 1486 } … … 1443 1492 ) 1444 1493 ) { 1445 elMessage.html( '').hide();1494 elMessage.html("").hide(); 1446 1495 return true; 1447 1496 } 1448 elMessage.html( 'You have entered an invalid email address!').show();1497 elMessage.html("You have entered an invalid email address!").show(); 1449 1498 return false; 1450 1499 } … … 1452 1501 function validateUrl(url, elMessage) { 1453 1502 let pattern = new RegExp( 1454 '^(https?:\\/\\/)?'+ // protocol1455 '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name1456 '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address1457 '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path1458 '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string1459 '(\\#[-a-z\\d_]*)?$',1460 'i'1503 "^(https?:\\/\\/)?" + // protocol 1504 "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name 1505 "((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address 1506 "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path 1507 "(\\?[;&a-z\\d%_.~+=-]*)?" + // query string 1508 "(\\#[-a-z\\d_]*)?$", 1509 "i" 1461 1510 ); // fragment locator 1462 1511 if (pattern.test(url)) { 1463 elMessage.html( '').hide();1512 elMessage.html("").hide(); 1464 1513 return true; 1465 1514 } 1466 elMessage.html( 'You have entered an invalid URL!').show();1515 elMessage.html("You have entered an invalid URL!").show(); 1467 1516 return false; 1468 1517 } 1469 1518 1470 1519 function checkLogicAction(optionSetId, action) { 1471 if ( !action || !action.conditions || !action.matchType.value) return false;1520 if (!action || !action.conditions || !action.matchType.value) return false; 1472 1521 1473 1522 let conditions = action.conditions; … … 1478 1527 } 1479 1528 1480 if ( 'any'=== matchType) {1529 if ("any" === matchType) { 1481 1530 let result = false; 1482 1531 $.each(conditions, function (_, condition) { … … 1504 1553 1505 1554 function getLogicActionResult(optionSetId, condition) { 1506 if( !condition || !condition.type || !condition.type.value ) return false; 1507 1508 if ( ! $(".yayextra-option-field-wrap[data-option-field-id=" + condition.optionId.id + "]" ).is(':visible')) return false; 1509 1555 if (!condition || !condition.type || !condition.type.value) return false; 1556 1557 if ( 1558 !$( 1559 ".yayextra-option-field-wrap[data-option-field-id=" + 1560 condition.optionId.id + 1561 "]" 1562 ).is(":visible") 1563 ) 1564 return false; 1565 1510 1566 const optionType = condition.type.value; 1511 1567 1512 if (optionType === 'text') {1568 if (optionType === "text") { 1513 1569 return checkTextLogic(optionSetId, condition); 1514 1570 } 1515 if (optionType === 'textarea') {1571 if (optionType === "textarea") { 1516 1572 return checkTextareaLogic(optionSetId, condition); 1517 1573 } 1518 if (optionType === 'number') {1574 if (optionType === "number") { 1519 1575 return checkNumberLogic(optionSetId, condition); 1520 1576 } 1521 if (optionType === 'checkbox') {1577 if (optionType === "checkbox") { 1522 1578 return checkCheckboxLogic(optionSetId, condition); 1523 1579 } 1524 if (optionType === 'radio') {1580 if (optionType === "radio") { 1525 1581 return checkRadioLogic(optionSetId, condition); 1526 1582 } 1527 if (optionType === 'button') {1583 if (optionType === "button") { 1528 1584 return checkButtonLogic(optionSetId, condition); 1529 1585 } 1530 if (optionType === 'button_multi') {1586 if (optionType === "button_multi") { 1531 1587 return checkButtonMultiLogic(optionSetId, condition); 1532 1588 } 1533 if (optionType === 'dropdown') {1589 if (optionType === "dropdown") { 1534 1590 return checkSelectLogic(optionSetId, condition); 1535 1591 } 1536 if (optionType === 'swatches') {1592 if (optionType === "swatches") { 1537 1593 return checkSwatchesLogic(optionSetId, condition); 1538 1594 } 1539 if (optionType === 'swatches_multi') {1595 if (optionType === "swatches_multi") { 1540 1596 return checkSwatchesMultiLogic(optionSetId, condition); 1541 1597 } 1542 if (optionType === 'date_picker') {1598 if (optionType === "date_picker") { 1543 1599 return checkDatePickerLogic(optionSetId, condition); 1544 1600 } 1545 if (optionType === 'time_picker') {1601 if (optionType === "time_picker") { 1546 1602 return checkTimePickerLogic(optionSetId, condition); 1547 1603 } 1548 1604 } 1549 1605 1550 function getFeeDiscountFromAction(optionSets ) {1606 function getFeeDiscountFromAction(optionSets, isOriginal) { 1551 1607 let feeDiscountArray = []; 1552 1608 $.each(optionSets, function (_, optionSet) { 1553 if ( 1 == parseInt(optionSet.status) ){1609 if (1 == parseInt(optionSet.status)) { 1554 1610 const optionSetId = optionSet.id; 1555 1611 $.each(optionSet.actions, function (_, action) { 1556 1612 if (checkLogicAction(optionSetId, action)) { 1557 1613 const subActions = action.subActions; 1558 1614 1559 1615 if (subActions.length > 0) { 1560 1616 $.each(subActions, function (_, subAction) { 1561 const actionVal = ( undefined !== subAction.subActionValueYayCurrency ) ? subAction.subActionValueYayCurrency : 0; 1617 let actionVal = 0; 1618 if (isOriginal) { 1619 actionVal = 1620 undefined !== subAction.subActionValue 1621 ? subAction.subActionValue 1622 : 0; 1623 } else { 1624 actionVal = 1625 undefined !== subAction.subActionValueYayCurrency 1626 ? subAction.subActionValueYayCurrency 1627 : 0; 1628 } 1629 1562 1630 feeDiscountArray.push({ 1563 1631 type: subAction.subActionType.value, 1564 1632 name: subAction.subActionName, 1565 value: actionVal 1633 value: actionVal, 1566 1634 }); 1567 1635 }); … … 1576 1644 $.each(feeDiscountArray, function (_, feeDiscount) { 1577 1645 let price = 1578 'add_fee'=== feeDiscount.type1646 "add_fee" === feeDiscount.type 1579 1647 ? parseFloat(feeDiscount.value) 1580 1648 : parseFloat(-feeDiscount.value); … … 1587 1655 1588 1656 function yayeNumberFormat(number, decimals, decPoint, thousandsSep) { 1589 number = (number + '').replace(/[^0-9+\-Ee.]/g, '');1657 number = (number + "").replace(/[^0-9+\-Ee.]/g, ""); 1590 1658 var n = !isFinite(+number) ? 0 : +number; 1591 1659 var prec = !isFinite(+decimals) ? 0 : Math.abs(decimals); 1592 var sep = typeof thousandsSep === 'undefined' ? ',': thousandsSep;1593 var dec = typeof decPoint === 'undefined' ? '.': decPoint;1594 var s = '';1660 var sep = typeof thousandsSep === "undefined" ? "," : thousandsSep; 1661 var dec = typeof decPoint === "undefined" ? "." : decPoint; 1662 var s = ""; 1595 1663 1596 1664 var toFixedFix = function toFixedFix(n, prec) { 1597 if (( '' + n).indexOf('e') === -1) {1598 return +(Math.round(n + 'e+' + prec) + 'e-'+ prec);1665 if (("" + n).indexOf("e") === -1) { 1666 return +(Math.round(n + "e+" + prec) + "e-" + prec); 1599 1667 } else { 1600 var arr = ( '' + n).split('e');1601 var sig = '';1668 var arr = ("" + n).split("e"); 1669 var sig = ""; 1602 1670 if (+arr[1] + prec > 0) { 1603 sig = '+';1671 sig = "+"; 1604 1672 } 1605 1673 return (+( 1606 Math.round(+arr[0] + 'e'+ sig + (+arr[1] + prec)) +1607 'e-'+1674 Math.round(+arr[0] + "e" + sig + (+arr[1] + prec)) + 1675 "e-" + 1608 1676 prec 1609 1677 )).toFixed(prec); … … 1612 1680 1613 1681 // @todo: for IE parseFloat(0.55).toFixed(0) = 0; 1614 s = (prec ? toFixedFix(n, prec).toString() : '' + Math.round(n)).split('.');1682 s = (prec ? toFixedFix(n, prec).toString() : "" + Math.round(n)).split("."); 1615 1683 if (s[0].length > 3) { 1616 1684 s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); 1617 1685 } 1618 if ((s[1] || '').length < prec) {1619 s[1] = s[1] || '';1620 s[1] += new Array(prec - s[1].length + 1).join( '0');1686 if ((s[1] || "").length < prec) { 1687 s[1] = s[1] || ""; 1688 s[1] += new Array(prec - s[1].length + 1).join("0"); 1621 1689 } 1622 1690 … … 1626 1694 function getTotalCost() { 1627 1695 let additionCostSum = 0; 1696 let additionCostSumOriginal = 0; 1628 1697 let feeDiscounts = 0; 1698 let feeDiscountsOriginal = 0; 1629 1699 1630 1700 let quantityProduct = 0; 1631 if ( $('.quantity input.qty').length > 0) {1632 quantityProduct = $( '.quantity input.qty').val();1633 } else if ( $('.quantity select.qty').length > 0) {1634 quantityProduct = $( '.quantity select.qty').val();1701 if ($(".quantity input.qty").length > 0) { 1702 quantityProduct = $(".quantity input.qty").val(); 1703 } else if ($(".quantity select.qty").length > 0) { 1704 quantityProduct = $(".quantity select.qty").val(); 1635 1705 } 1636 1706 1637 1707 if ( 1638 $( '.yayextra-total-price').length > 0 ||1639 $( '.yayextra-extra-subtotal-price').length > 01708 $(".yayextra-total-price").length > 0 || 1709 $(".yayextra-extra-subtotal-price").length > 0 1640 1710 ) { 1641 const optionFields = $( 'body').find('.yayextra-option-field-wrap');1711 const optionFields = $("body").find(".yayextra-option-field-wrap"); 1642 1712 const optHasVals = [ 1643 'radio',1644 'dropdown',1645 'checkbox',1646 'button',1647 'button_multi',1648 'swatches',1649 'swatches_multi',1713 "radio", 1714 "dropdown", 1715 "checkbox", 1716 "button", 1717 "button_multi", 1718 "swatches", 1719 "swatches_multi", 1650 1720 ]; 1651 1721 1652 1722 if (optionFields.length > 0) { 1653 1723 $.each(optionFields, function (idx, el) { 1654 if ($(el).is( ':visible')) {1724 if ($(el).is(":visible")) { 1655 1725 // Sum value of value option field 1656 const optType = $(el).attr( 'data-option-field-type');1726 const optType = $(el).attr("data-option-field-type"); 1657 1727 if (optHasVals.includes(optType)) { 1658 if ( 'dropdown'=== optType) {1659 let valEls = $(el).find( 'select');1728 if ("dropdown" === optType) { 1729 let valEls = $(el).find("select"); 1660 1730 if (valEls.length > 0) { 1661 1731 $.each(valEls, function (_, valEl) { 1662 let selectedOption = $(valEl).find( 'option:selected');1732 let selectedOption = $(valEl).find("option:selected"); 1663 1733 if (selectedOption.length > 0) { 1664 1734 additionCostSum += parseFloat( 1665 selectedOption.attr('data-addition-cost') 1735 selectedOption.attr("data-addition-cost") 1736 ); 1737 additionCostSumOriginal += parseFloat( 1738 selectedOption.attr("data-option-org-cost") 1666 1739 ); 1667 1740 } … … 1669 1742 } 1670 1743 } else { 1671 let valEls = $(el).find( 'input');1744 let valEls = $(el).find("input"); 1672 1745 if (valEls.length > 0) { 1673 1746 $.each(valEls, function (_, valEl) { 1674 if ($(valEl).is( ':checked')) {1747 if ($(valEl).is(":checked")) { 1675 1748 additionCostSum += parseFloat( 1676 $(valEl).attr('data-addition-cost') 1749 $(valEl).attr("data-addition-cost") 1750 ); 1751 additionCostSumOriginal += parseFloat( 1752 $(valEl).attr("data-option-org-cost") 1677 1753 ); 1678 1754 } … … 1685 1761 } 1686 1762 1687 feeDiscounts = getFeeDiscountFromAction(optionSetList); 1763 feeDiscounts = getFeeDiscountFromAction(optionSetList, false); 1764 feeDiscountsOriginal = getFeeDiscountFromAction(optionSetList, true); 1765 1766 // Update data into hidden input 1767 $("input.yaye-total-options-original").attr( 1768 "data-total-options-price-original", 1769 additionCostSumOriginal 1770 ); 1771 $("input.yaye-total-fee-original").attr( 1772 "data-total-fee-original", 1773 feeDiscountsOriginal.feeDiscountTotal 1774 ); 1688 1775 } 1689 1776 1690 1777 // Total price - start 1691 if ($( '.yayextra-total-price').length > 0) {1778 if ($(".yayextra-total-price").length > 0) { 1692 1779 totalPriceHtml( 1693 'yayextra-total-price',1780 "yayextra-total-price", 1694 1781 additionCostSum, 1695 1782 feeDiscounts, … … 1700 1787 1701 1788 // Extra subtotal price - start 1702 if ($( '.yayextra-extra-subtotal-price').length > 0) {1789 if ($(".yayextra-extra-subtotal-price").length > 0) { 1703 1790 totalPriceHtml( 1704 'yayextra-extra-subtotal-price',1791 "yayextra-extra-subtotal-price", 1705 1792 additionCostSum, 1706 1793 feeDiscounts, … … 1717 1804 quantityProduct 1718 1805 ) { 1719 let dataTokenReplace = $('.' + elementWrap + ' .total-price').attr( 1720 'data-token-replace' 1721 ); 1722 1723 let currentPrice = $('.' + elementWrap + ' .total-price').attr( 1724 'data-total-price' 1725 ); 1726 1806 let dataTokenReplace = $("." + elementWrap + " .total-price").attr( 1807 "data-token-replace" 1808 ); 1809 1810 let currentPrice = $("." + elementWrap + " .total-price").attr( 1811 "data-total-price" 1812 ); 1813 1814 // Remove fee/discount total 1815 //let totalPrice = (additionCostSum + parseFloat(currentPrice)) * parseInt(quantityProduct) + parseFloat(feeDiscounts.feeDiscountTotal); 1727 1816 let totalPrice = 1728 (additionCostSum + parseFloat(currentPrice)) * parseInt(quantityProduct) + parseFloat(feeDiscounts.feeDiscountTotal);1817 (additionCostSum + parseFloat(currentPrice)) * parseInt(quantityProduct); 1729 1818 1730 1819 let totalPriceFormat = yayeNumberFormat( … … 1735 1824 ); 1736 1825 1737 let priceString = $( '.' + elementWrap + ' .total-price').html();1826 let priceString = $("." + elementWrap + " .total-price").html(); 1738 1827 let stringReplace = yayeNumberFormat( 1739 1828 parseFloat(dataTokenReplace), … … 1744 1833 1745 1834 // Update data-token-replace for later 1746 $( '.' + elementWrap + ' .total-price').attr(1747 'data-token-replace',1835 $("." + elementWrap + " .total-price").attr( 1836 "data-token-replace", 1748 1837 totalPrice 1749 1838 ); … … 1751 1840 let priceStringFinal = priceString.replace(stringReplace, totalPriceFormat); 1752 1841 1753 if ( 'yayextra-total-price' === elementWrap) {1842 if ("yayextra-total-price" === elementWrap) { 1754 1843 let productId = 0; 1755 if ( $('button[name="add-to-cart"').length && '' != $('button[name="add-to-cart"').val() ) { // regular product 1756 productId = parseInt( $('button[name="add-to-cart"').val() ); 1757 } else if ( $('input[name="variation_id"').length && '' != $('input[name="variation_id"').val() ) { // variation product 1758 productId = parseInt( $('input[name="variation_id"').val() ); 1844 if ( 1845 $('button[name="add-to-cart"').length && 1846 "" != $('button[name="add-to-cart"').val() 1847 ) { 1848 // regular product 1849 productId = parseInt($('button[name="add-to-cart"').val()); 1850 } else if ( 1851 $('input[name="variation_id"').length && 1852 "" != $('input[name="variation_id"').val() 1853 ) { 1854 // variation product 1855 productId = parseInt($('input[name="variation_id"').val()); 1759 1856 } 1760 1857 // yaye_total_price_hook 1761 $('.' + elementWrap + ' .total-price').html( wp.hooks.applyFilters( 'yaye_total_price_hook', priceStringFinal, totalPrice, productId ) ); 1858 const totalPriceOriginalData = getTotalPriceOriginalData(); 1859 priceStringFinal = wp.hooks.applyFilters( 1860 "yaye_total_price_hook", 1861 priceStringFinal, 1862 quantityProduct, 1863 totalPriceOriginalData 1864 ); 1865 $("." + elementWrap + " .total-price").html(priceStringFinal); 1762 1866 } else { 1763 $('.' + elementWrap + ' .total-price').html(priceStringFinal); 1764 } 1765 } 1766 1767 function getVariationProductsMeta(){ 1768 if($('.product form.variations_form').length > 0){ 1769 let variationsMeta = $('.product form.variations_form').attr('data-product_variations'); 1867 $("." + elementWrap + " .total-price").html(priceStringFinal); 1868 } 1869 } 1870 1871 function getVariationProductsMeta() { 1872 if ($(".product form.variations_form").length > 0) { 1873 let variationsMeta = $(".product form.variations_form").attr( 1874 "data-product_variations" 1875 ); 1770 1876 return JSON.parse(variationsMeta); 1771 1877 } … … 1774 1880 1775 1881 // Return price of variable product or null 1776 function updateTotalPriceByVariationProduct(variationProductsMeta, prodVariationData){ 1777 if(variationProductsMeta !== null && variationProductsMeta.length > 0) { 1778 for(let variationProduct of variationProductsMeta){ 1779 const findVariationProd = findVariationProduct(variationProduct, prodVariationData); 1780 if(findVariationProd){ 1781 $('.yayextra-total-price .total-price').attr('data-total-price', parseFloat(variationProduct.display_price)); 1882 function updateTotalPriceByVariationProduct( 1883 variationProductsMeta, 1884 prodVariationData 1885 ) { 1886 if (variationProductsMeta !== null && variationProductsMeta.length > 0) { 1887 for (let variationProduct of variationProductsMeta) { 1888 const findVariationProd = findVariationProduct( 1889 variationProduct, 1890 prodVariationData 1891 ); 1892 if (findVariationProd) { 1893 const productPrice = parseFloat(variationProduct.display_price); 1894 1895 $(".yayextra-total-price .total-price").attr( 1896 "data-total-price", 1897 productPrice 1898 ); 1899 1900 let productPriceOriginal = productPrice; 1901 if ("undefined" !== typeof YayCurrency_Callback) { 1902 productPriceOriginal = 1903 YayCurrency_Callback.Helper.handelRevertPrice(productPrice); 1904 } 1905 $(".yaye-product-price-original").attr( 1906 "data-product-price-original", 1907 productPriceOriginal 1908 ); 1909 1782 1910 // getTotalCost(); 1783 return parseFloat(variationProduct.display_price); 1784 } 1785 }; 1911 return productPrice; 1912 } else { 1913 $(".yaye-product-price-original").attr( 1914 "data-product-price-original", 1915 0 1916 ); 1917 } 1918 } 1786 1919 } 1787 1920 return null; 1788 1921 } 1789 1922 1790 // Find variation product 1923 // Find variation product 1791 1924 function findVariationProduct(variationProduct, prodVariationData) { 1792 1925 let result = true; 1793 1926 let attrs = variationProduct.attributes; 1794 1927 for (const attr in attrs) { 1795 if ( ! prodVariationData[attr]) {1796 result = false 1928 if (!prodVariationData[attr]) { 1929 result = false; 1797 1930 break; 1798 1931 } else { 1799 if ( attrs[attr] && attrs[attr] !== prodVariationData[attr]) {1800 result = false 1932 if (attrs[attr] && attrs[attr] !== prodVariationData[attr]) { 1933 result = false; 1801 1934 break; 1802 1935 } … … 1806 1939 return result; 1807 1940 } 1808 1809 function changeAdditionCostByVariationProduct( variationProductPrice) {1810 let optionAdditionPercentageCostEls = $( '.option-addition-percentage-cost')1811 if (optionAdditionPercentageCostEls.length > 0){1941 1942 function changeAdditionCostByVariationProduct(variationProductPrice) { 1943 let optionAdditionPercentageCostEls = $(".option-addition-percentage-cost"); 1944 if (optionAdditionPercentageCostEls.length > 0) { 1812 1945 for (const valOptLabel of optionAdditionPercentageCostEls) { 1813 const optionValId = $(valOptLabel).attr('data-opt-val-id') 1814 const optionCostOrg = $(valOptLabel).attr('data-option-org-cost') 1815 const additionCost = parseFloat( optionCostOrg ) * variationProductPrice / 100; 1816 1946 const optionValId = $(valOptLabel).attr("data-opt-val-id"); 1947 const optionCostOrg = $(valOptLabel).attr("data-option-org-val"); 1948 const additionCost = 1949 (parseFloat(optionCostOrg) * variationProductPrice) / 100; 1950 1817 1951 // update data-addition-cost for input element 1818 const inputEl = $('[id="' + optionValId + '"]') 1819 if(inputEl.length > 0){ 1820 $(inputEl[0]).attr('data-addition-cost', additionCost) 1821 } else { // Case for Dropdown option 1822 const selectEl = $('option[data-opt-val-id="' + optionValId + '"]') 1823 if(selectEl.length > 0){ 1824 $(selectEl[0]).attr('data-addition-cost', additionCost) 1952 const inputEl = $('[id="' + optionValId + '"]'); 1953 if (inputEl.length > 0) { 1954 $(inputEl[0]).attr("data-addition-cost", additionCost); 1955 } else { 1956 // Case for Dropdown option 1957 const selectEl = $('option[data-opt-val-id="' + optionValId + '"]'); 1958 if (selectEl.length > 0) { 1959 $(selectEl[0]).attr("data-addition-cost", additionCost); 1825 1960 } 1826 1961 } … … 1835 1970 1836 1971 let dataTokenReplace = $(valOptLabel).attr( 1837 'data-option-org-cost-token-replace'1972 "data-option-org-cost-token-replace" 1838 1973 ); 1839 1974 … … 1847 1982 1848 1983 // Update data-token-replace for later 1849 $(valOptLabel).attr( 1850 'data-option-org-cost-token-replace', 1851 additionCost 1984 $(valOptLabel).attr("data-option-org-cost-token-replace", additionCost); 1985 1986 let priceStringFinal = priceString.replace( 1987 stringReplace, 1988 additionCostFormat 1852 1989 ); 1853 1990 1854 let priceStringFinal = priceString.replace(stringReplace, additionCostFormat);1855 1856 1991 $(valOptLabel).html(priceStringFinal); 1857 1858 1992 } 1859 1993 } … … 1861 1995 1862 1996 function getVisibilityOption() { 1863 let optionFieldList = $( 'form').find('.yayextra-option-field-wrap:visible');1997 let optionFieldList = $("form").find(".yayextra-option-field-wrap:visible"); 1864 1998 let optionIdList = []; 1865 1999 $.each(optionFieldList, function (_, optField) { 1866 const optId = $(optField).attr( 'data-option-field-id');2000 const optId = $(optField).attr("data-option-field-id"); 1867 2001 optionIdList.push(optId); 1868 }) 2002 }); 1869 2003 1870 2004 // Set option id to hidden field to php handle … … 1872 2006 } 1873 2007 2008 function getTotalPriceOriginalData() { 2009 const totalOptionsOriginal = $(".yaye-total-options-original").attr( 2010 "data-total-options-price-original" 2011 ); 2012 const totalFeeOriginal = $(".yaye-total-fee-original").attr( 2013 "data-total-fee-original" 2014 ); 2015 const productPriceOriginal = $(".yaye-product-price-original").attr( 2016 "data-product-price-original" 2017 ); 2018 2019 return { 2020 total_options_original: totalOptionsOriginal, 2021 total_fee_original: totalFeeOriginal, 2022 product_price_original: productPriceOriginal, 2023 }; 2024 } 1874 2025 })(jQuery); -
yayextra/trunk/includes/Classes/ProductPage.php
r3383835 r3481811 121 121 $opt_field['type']['value'] . '_field', 122 122 array( 123 'opt_set_id' => $opt_set_data['id'], 124 'data' => $opt_field, 125 'product_price' => $product_price, 126 'is_edit_option_mode' => $this->is_edit_option_mode(), 127 'settings' => $settings, 123 'opt_set_id' => $opt_set_data['id'], 124 'data' => $opt_field, 125 'product_price' => $product_price, 126 'product_price_original' => $product->get_price( 'original' ), 127 'is_edit_option_mode' => $this->is_edit_option_mode(), 128 'settings' => $settings, 128 129 ) 129 130 ); … … 137 138 138 139 if ( isset( $settings['general'] ) && true === $settings['general']['show_extra_subtotal'] ) { 140 $subtotal_text = apply_filters( 'yaye_subtotal_text', esc_html__( 'Extra subtotal:', 'yayextra' ) ); 139 141 echo '<div class="yayextra-extra-subtotal-price">'; 140 echo '<span class="total-price-title">' . esc_html __( 'Extra subtotal:', 'yayextra') . '</span>';142 echo '<span class="total-price-title">' . esc_html( $subtotal_text ) . '</span>'; 141 143 echo '<span class="total-price" data-token-replace="0" data-total-price="0">' . wp_kses_post( Utils::get_formatted_price_from_yaycurrency( 0 ) ) . '</span>'; 142 144 echo '</div>'; … … 144 146 145 147 if ( isset( $settings['general'] ) && true === $settings['general']['show_total_price'] ) { 148 $total_price_text = apply_filters( 'yaye_total_price_text', esc_html__( 'Total price:', 'yayextra' ) ); 146 149 echo '<div class="yayextra-total-price">'; 147 echo '<span class="total-price-title">' . esc_html __( 'Total price:', 'yayextra') . '</span>';150 echo '<span class="total-price-title">' . esc_html( $total_price_text ) . '</span>'; 148 151 echo '<span class="total-price" data-token-replace="' . esc_attr( $product_price ) . '" data-total-price="' . esc_attr( $product_price ) . '">' . wp_kses_post( Utils::get_formatted_price_from_yaycurrency( $product_price ) ) . '</span>'; 149 152 echo '</div>'; … … 162 165 // For YayExtra pro version. 163 166 } 167 168 // Store original total options price, fee, linked product price for later 3rd plugin 169 echo '<input type="hidden" class="yaye-total-options-original" data-total-options-price-original="0" />'; 170 echo '<input type="hidden" class="yaye-total-fee-original" data-total-fee-original="0" />'; 171 echo '<input type="hidden" class="yaye-product-price-original" data-product-price-original="' . esc_attr( $product->get_price( 'original' ) ) . '" data-product-regular-price-original="' . esc_attr( $product->get_regular_price( 'original' ) ) . '"/>'; 164 172 } 165 173 … … 634 642 foreach ( $cart_object->cart_contents as $cart_value ) { 635 643 if( !empty($cart_value['data']) ) { 636 $cost_total = Utils::get_price_fixed_from_currency_plugin( $cart_value['product_id'], floatval( $cart_value['data']->get_price( 'original' ) ), true); 637 $cost_regular_total = Utils::get_price_fixed_from_currency_plugin( $cart_value['product_id'], floatval( $cart_value['data']->get_regular_price( 'original' ) ), true); 644 $product = wc_get_product( $cart_value['data']->get_id() ); 645 $cost_total = Utils::get_price_fixed_from_currency_plugin( $cart_value['product_id'], floatval( $product->get_price( 'original' ) ), true); 646 $cost_regular_total = Utils::get_price_fixed_from_currency_plugin( $cart_value['product_id'], floatval( $product->get_regular_price( 'original' ) ), true); 638 647 639 648 if ( ! empty( $cart_value['yaye_custom_option'] ) ) { … … 660 669 ); 661 670 662 $cost_total = apply_filters('yaye_cart_line_total', Utils::get_price_from_currency_plugin( $cost_total ), $cart_value); 663 $cost_regular_total = apply_filters('yaye_cart_line_regular_total', Utils::get_price_from_currency_plugin( $cost_regular_total ), $cart_value); 671 672 if ( function_exists( 'Yay_Currency\\plugin_init' )) { 673 $cost_total = apply_filters('yaye_cart_line_total', $cost_total, $cart_value); 674 $cost_regular_total = apply_filters('yaye_cart_line_regular_total', $cost_regular_total, $cart_value); 675 } else { 676 $cost_total = apply_filters('yaye_cart_line_total', Utils::get_price_from_currency_plugin( $cost_total ), $cart_value); 677 $cost_regular_total = apply_filters('yaye_cart_line_regular_total', Utils::get_price_from_currency_plugin( $cost_regular_total ), $cart_value); 678 } 664 679 665 680 $cart_value['data']->set_price( $cost_total ); … … 744 759 745 760 // Add edit option field link with product has applied opiton field. 746 if ( is_cart() && ! empty( $product_permalink ) ) {761 if ( is_cart() && ! empty( $product_permalink ) && ! wp_is_block_theme() ) { 747 762 $current_prod_id = $_product->get_parent_id(); 748 763 if ( empty( $current_prod_id ) ) { … … 760 775 ); 761 776 777 $edit_option_text = apply_filters( 'yaye_edit_option_text', esc_html__( 'Edit option field', 'yayextra' ) ); 762 778 $cart_data[] = array( 763 'name' => '<a href="' . $edit_link . '" class="yayextra-option-edit-link">' . esc_html__( 'Edit option field', 'yayextra' ). '</a>',779 'name' => '<a href="' . $edit_link . '" class="yayextra-option-edit-link">' . $edit_option_text . '</a>', 764 780 'value' => '', 765 781 ); … … 1147 1163 $opt_val_temp = array(); 1148 1164 foreach ( $option_value as $opt_val ) { 1149 array_push( $opt_val_temp, $opt_val['value']);1165 array_push( $opt_val_temp, trim($opt_val['value']) ); 1150 1166 } 1151 1167 $option_value = $opt_val_temp; 1152 1168 } elseif ( 'radio' === $option_type || 'button' === $option_type || 'dropdown' === $option_type || 'swatches' === $option_type ) { 1153 $opt_val_temp = ! empty( $option_value['value'] ) ? $option_value['value'] : $option_value[0]['value'];1169 $opt_val_temp = ! empty( $option_value['value'] ) ? trim($option_value['value']) : trim($option_value[0]['value']); 1154 1170 $option_value = $opt_val_temp; 1155 1171 } … … 1218 1234 if ( 'is_one_of' === $comparation ) { 1219 1235 foreach ( $option['option_value'] as $opt_cart_val ) { 1220 if ( in_array( $opt_cart_val['option_val'], $option_value, true ) ) {1236 if ( in_array( trim($opt_cart_val['option_val']), $option_value, true ) ) { 1221 1237 return true; 1222 1238 }; … … 1225 1241 } elseif ( 'is_not_one_of' === $comparation ) { 1226 1242 foreach ( $option['option_value'] as $opt_cart_val ) { 1227 if ( in_array( $opt_cart_val['option_val'], $option_value, true ) ) {1243 if ( in_array( trim($opt_cart_val['option_val']), $option_value, true ) ) { 1228 1244 return false; 1229 1245 }; … … 1361 1377 */ 1362 1378 public function add_link_edit_option_field_in_minicart( $cart_item_quantity_product_price_span, $cart_item, $cart_item_key ) { 1363 if ( is_cart() ) return $cart_item_quantity_product_price_span;1379 if ( is_cart() && ! wp_is_block_theme() ) return $cart_item_quantity_product_price_span; 1364 1380 1365 1381 $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); … … 1384 1400 $product_permalink 1385 1401 ); 1386 echo '<p><a href="' . esc_attr( $edit_link ) . '" class="yayextra-option-edit-link-minicart">' . esc_html__( 'Edit option field', 'yayextra' ) . '</a></p>'; 1402 1403 $edit_option_text = apply_filters( 'yaye_edit_option_text', esc_html__( 'Edit option field', 'yayextra' ) ); 1404 echo '<p><a href="' . esc_attr( $edit_link ) . '" class="yayextra-option-edit-link-minicart">' . esc_html( $edit_option_text ) . '</a></p>'; 1387 1405 } 1388 1406 } … … 1587 1605 $css .= '}'; 1588 1606 1589 $css .= '.yayextra-total-price .total-price , .yayextra-extra-subtotal-price .total-price{';1607 $css .= '.yayextra-total-price .total-price {'; 1590 1608 if ( ! empty( $general_setts['total_price_font_size'] ) && '0px' !== $general_setts['total_price_font_size'] ) { 1591 1609 $css .= 'font-size: ' . $general_setts['total_price_font_size'] . 'px !important;'; … … 1593 1611 if ( ! empty( $general_setts['total_price_font_weight'] ) ) { 1594 1612 $css .= 'font-weight: ' . $general_setts['total_price_font_weight']['value'] . ' !important;'; 1613 } 1614 1615 $css .= '}'; 1616 1617 $css .= '.yayextra-extra-subtotal-price .total-price {'; 1618 if ( ! empty( $general_setts['subtotal_price_font_size'] ) && '0px' !== $general_setts['subtotal_price_font_size'] ) { 1619 $css .= 'font-size: ' . $general_setts['subtotal_price_font_size'] . 'px !important;'; 1620 } 1621 if ( ! empty( $general_setts['subtotal_price_font_weight'] ) ) { 1622 $css .= 'font-weight: ' . $general_setts['subtotal_price_font_weight']['value'] . ' !important;'; 1595 1623 } 1596 1624 … … 1706 1734 } 1707 1735 } 1736 } elseif ( 3 === $prod_filter_type ) { // Choose all products. 1737 $prod_apply_list = 'all'; 1708 1738 } 1709 1739 … … 2035 2065 2036 2066 if ( ! empty( $prod_apply_list ) ) { 2037 if ( in_array( $current_prod_id, $prod_apply_list, true ) ) { 2067 if ( is_array( $prod_apply_list ) && in_array( $current_prod_id, $prod_apply_list, true ) ) { 2068 if ( isset( $settings['general'] ) && 'first_applicable' === $settings['general']['applied_option_sets']['value'] ) { 2069 return array( $opt_set_data ); 2070 } else { 2071 array_push( $result, $opt_set_data ); 2072 } 2073 } else if ( 'all' === $prod_apply_list ) { // Choose all products. 2038 2074 if ( isset( $settings['general'] ) && 'first_applicable' === $settings['general']['applied_option_sets']['value'] ) { 2039 2075 return array( $opt_set_data ); -
yayextra/trunk/includes/Helper/Database.php
r3326588 r3481811 1 1 <?php 2 2 namespace YayExtra\Helper; 3 4 defined( 'ABSPATH' ) || exit; 3 5 4 6 /** … … 402 404 global $wpdb; 403 405 406 $filters = $this->expand_category_conditions( $filters ); 407 404 408 $this->filters = $filters; 405 409 $this->apply = $apply; … … 412 416 return $result_query_all; 413 417 } 418 419 /** 420 * Expand product_category conditions to include children categories automatically. 421 * 422 * @param array $filters 423 * @return array 424 */ 425 public function expand_category_conditions( $filters ) { 426 if ( empty( $filters ) || ! is_array( $filters ) ) { 427 return $filters; 428 } 429 430 foreach ( $filters as &$cond ) { 431 432 if ( 433 isset( $cond['type']['value'] ) && 434 $cond['type']['value'] === 'prod_category' && 435 ! empty( $cond['value'] ) 436 ) { 437 $selected_ids = array_map( 438 'intval', 439 wp_list_pluck( $cond['value'], 'value' ) 440 ); 441 442 $all_cat_ids = []; 443 444 foreach ( $selected_ids as $cid ) { 445 446 $children = get_term_children( $cid, 'product_cat' ); 447 448 if ( is_array( $children ) ) { 449 $all_cat_ids = array_merge( $all_cat_ids, $children ); 450 } 451 452 $all_cat_ids[] = $cid; 453 } 454 455 $all_cat_ids = array_unique( array_map( 'intval', $all_cat_ids ) ); 456 457 $cond['value'] = array_map( function ( $id ) { 458 $term = get_term( $id ); 459 return [ 460 'value' => $id, 461 'label' => $term && ! is_wp_error( $term ) ? $term->name : '', 462 ]; 463 }, $all_cat_ids ); 464 } 465 } 466 467 return $filters; 468 } 414 469 } -
yayextra/trunk/includes/Helper/Utils.php
r3383835 r3481811 433 433 return x_currency_exchange( $price ); 434 434 } 435 436 return $price; 437 } 438 439 /** 440 * Convert price by YayCurrency cookie. 441 * 442 * @param float $price Price value. 443 * 444 * @return array 445 */ 446 public static function get_price_from_yaycurrency_cookie( $price ) { 447 if ( function_exists( 'Yay_Currency\\plugin_init' ) ) { 448 if (class_exists('Yay_Currency\Helpers\YayCurrencyHelper')) { 449 if ( method_exists( 'Yay_Currency\Helpers\YayCurrencyHelper', 'calculate_price_by_currency_cookie' ) ) { 450 return YayCurrencyHelper::calculate_price_by_currency_cookie( $price, false ); 451 } 452 } 453 } 435 // PBOC multicurrency 436 elseif ( function_exists('wcpbc_the_zone') && wcpbc_the_zone()) { 437 return wcpbc_the_zone()->get_exchange_rate_price( $price ); 438 } 439 454 440 return $price; 455 441 } … … 504 490 method_exists( 'Yay_Currency\Helpers\YayCurrencyHelper', 'detect_current_currency' ) 505 491 ) { 492 $original_price = $product_price; 506 493 $apply_currency = YayCurrencyHelper::detect_current_currency(); 507 494 if ( ! empty( $apply_currency ) ) { … … 517 504 YayCurrencyHelper::disable_fallback_option_in_checkout_page( $apply_currency ) ) 518 505 { 519 return wc_get_product( $product_id )->get_price( 'original' ); 506 // return wc_get_product( $product_id )->get_price( 'original' ); 507 return $original_price; 520 508 } 521 509 return self::get_reverse_price_from_yaycurrency( $product_price ); … … 531 519 } 532 520 return x_currency_exchange( $product_price ); 521 } 522 // PBOC multicurrency 523 elseif ( function_exists('wcpbc_the_zone') && wcpbc_the_zone()) { 524 if ( $force_original ) { 525 return $product_price; 526 } 527 return wcpbc_the_zone()->get_exchange_rate_price( $product_price ); 533 528 } 534 529 … … 742 737 public static function gen_uuid() { 743 738 return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', 744 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),745 mt_rand( 0, 0xffff ),746 mt_rand( 0, 0x0fff ) | 0x4000,747 mt_rand( 0, 0x3fff ) | 0x8000,748 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )739 wp_rand( 0, 0xffff ), wp_rand( 0, 0xffff ), 740 wp_rand( 0, 0xffff ), 741 wp_rand( 0, 0x0fff ) | 0x4000, 742 wp_rand( 0, 0x3fff ) | 0x8000, 743 wp_rand( 0, 0xffff ), wp_rand( 0, 0xffff ), wp_rand( 0, 0xffff ) 749 744 ); 750 745 } -
yayextra/trunk/includes/Init/Ajax.php
r3262042 r3481811 5 5 use YayExtra\Init\CustomPostType; 6 6 use YayExtra\Classes\ProductPage; 7 defined( 'ABSPATH' ) || exit; 7 8 /** 8 9 * Ajax class … … 55 56 'get_settings', 56 57 'update_option_set_products_one_by_one', 58 'update_reviewed_flag', 57 59 ); 58 60 } … … 116 118 117 119 /** 120 * Add missing UUIDs to optionValues inside Option Set. 121 */ 122 private function migrate_option_value_id($option_set) { 123 124 $has_changed = false; 125 126 if (empty($option_set['options']) || !is_array($option_set['options'])) { 127 return array( 128 'data' => $option_set, 129 'has_changed' => false, 130 ); 131 } 132 133 foreach ($option_set['options'] as &$option) { 134 135 if (empty($option['optionValues']) || !is_array($option['optionValues'])) { 136 continue; 137 } 138 139 $first = $option['optionValues'][0] ?? null; 140 141 // if id is not empty -> skip 142 if (!empty($first['id'])) { 143 continue; 144 } 145 146 // if id is empty -> migrate for all items 147 foreach ($option['optionValues'] as &$valueItem) { 148 if (empty($valueItem['id'])) { 149 $valueItem['id'] = wp_generate_uuid4(); 150 $has_changed = true; 151 } 152 } 153 } 154 155 return array( 156 'data' => $option_set, 157 'has_changed' => $has_changed, 158 ); 159 } 160 161 /** 162 * Migrate old logic value data to include id (id in optionValue). 163 */ 164 private function migrate_option_set_logic_value( $option_set ) { 165 $has_changed = false; 166 167 if ( empty( $option_set['options'] ) || ! is_array( $option_set['options'] ) ) { 168 return array( 'data' => $option_set, 'has_changed' => false ); 169 } 170 171 /** 172 * Helper: always return array of items 173 */ 174 $normalize_value = function( $value ) { 175 if ( empty( $value ) ) { 176 return array(); 177 } 178 // If already array of objects → return 179 if ( is_array( $value ) && isset( $value[0] ) && is_array( $value[0] ) ) { 180 return $value; 181 } 182 // Convert single object → array 183 return array( $value ); 184 }; 185 186 /** 187 * MIGRATE LOGICS 188 */ 189 $force_array_types = array( 'checkbox', 'button_multi', 'swatches_multi' ); 190 foreach ( $option_set['options'] as &$option ) { 191 192 if ( empty( $option['logics'] ) ) { 193 continue; 194 } 195 196 foreach ( $option['logics'] as &$logic ) { 197 198 // If already has ID → skip 199 if ( isset( $logic['value']['id'] ) && $logic['value']['id'] !== '' ) { 200 continue; 201 } 202 203 if ( empty( $logic['option']['id'] ) ) { 204 continue; 205 } 206 207 $target_option_id = $logic['option']['id']; 208 209 // Find corresponding option 210 $target_option = null; 211 foreach ( $option_set['options'] as $opt ) { 212 if ( $opt['id'] === $target_option_id ) { 213 $target_option = $opt; 214 break; 215 } 216 } 217 if ( ! $target_option || empty( $target_option['optionValues'] ) ) { 218 continue; 219 } 220 221 // Normalize value to array 222 $original_value = $logic['value']; 223 $value_list = $normalize_value( $original_value ); 224 225 $mapped_list = array(); 226 227 foreach ( $value_list as $item ) { 228 $current_value = $item['value'] ?? null; 229 if ( ! $current_value ) { 230 $mapped_list[] = $item; 231 continue; 232 } 233 234 // Match in optionValues 235 $found = false; 236 foreach ( $target_option['optionValues'] as $ov ) { 237 if ( $ov['value'] === $current_value ) { 238 $mapped_list[] = array( 239 'id' => $ov['id'], 240 'value' => $ov['value'], 241 'label' => $item['label'] ?? $ov['value'], 242 ); 243 $has_changed = true; 244 $found = true; 245 break; 246 } 247 } 248 249 if ( ! $found ) { 250 // fallback 251 $mapped_list[] = $item; 252 } 253 } 254 255 // Restore single or array 256 $option_type = $logic['option']['type']['value'] ?? null; 257 if ( in_array( $option_type, $force_array_types, true ) ) { 258 $logic['value'] = $mapped_list; 259 } else { 260 $logic['value'] = ( count( $mapped_list ) === 1 ) ? $mapped_list[0] : $mapped_list; 261 } 262 } 263 } 264 265 /** 266 * MIGRATE ACTION CONDITIONS 267 */ 268 if ( ! empty( $option_set['actions'] ) ) { 269 foreach ( $option_set['actions'] as &$action ) { 270 271 if ( empty( $action['conditions'] ) ) { 272 continue; 273 } 274 275 foreach ( $action['conditions'] as &$condition ) { 276 277 if ( isset( $condition['value']['id'] ) && $condition['value']['id'] !== '' ) { 278 continue; 279 } 280 281 $target_option_id = $condition['optionId']['id'] ?? null; 282 if ( ! $target_option_id ) { 283 continue; 284 } 285 286 // Find corresponding option 287 $target_option = null; 288 foreach ( $option_set['options'] as $opt ) { 289 if ( $opt['id'] === $target_option_id ) { 290 $target_option = $opt; 291 break; 292 } 293 } 294 if ( ! $target_option ) { 295 continue; 296 } 297 298 $original_value = $condition['value']; 299 $value_list = $normalize_value( $original_value ); 300 301 $mapped_list = array(); 302 303 foreach ( $value_list as $item ) { 304 $current_value = $item['value'] ?? null; 305 306 if ( ! $current_value ) { 307 $mapped_list[] = $item; 308 continue; 309 } 310 311 $found = false; 312 foreach ( $target_option['optionValues'] as $ov ) { 313 if ( $ov['value'] === $current_value ) { 314 $mapped_list[] = array( 315 'id' => $ov['id'], 316 'value' => $ov['value'], 317 'label' => $item['label'] ?? $ov['value'], 318 ); 319 $has_changed = true; 320 $found = true; 321 break; 322 } 323 } 324 325 if ( ! $found ) { 326 $mapped_list[] = $item; 327 } 328 } 329 330 $cond_type = $condition['type']['value'] ?? null; 331 if ( in_array( $cond_type, $force_array_types, true ) ) { 332 $condition['value'] = $mapped_list; 333 } else { 334 $condition['value'] = ( count( $mapped_list ) === 1 ) ? $mapped_list[0] : $mapped_list; 335 } 336 } 337 } 338 } 339 340 return array( 341 'data' => $option_set, 342 'has_changed' => $has_changed, 343 ); 344 } 345 346 /** 118 347 * Ajax get option set by id. 119 348 * … … 130 359 $id = sanitize_text_field( wp_unslash( isset( $_POST['id'] ) ? $_POST['id'] : null ) ); 131 360 $option_set = CustomPostType::get_option_set( $id ); 132 361 //migrate option set data 362 $migrated_option_value_id = $this->migrate_option_value_id( $option_set ); 363 $option_set = $migrated_option_value_id['data']; 364 365 if ( $migrated_option_value_id['has_changed'] ) { 366 update_post_meta( $id, '_yaye_options', $option_set['options'] ); 367 } 368 369 $migrated_logics_actions = $this->migrate_option_set_logic_value( $option_set ); 370 $option_set = $migrated_logics_actions['data']; 371 372 if ( $migrated_logics_actions['has_changed'] ) { 373 update_post_meta( $id, '_yaye_options', $option_set['options'] ); 374 update_post_meta( $id, '_yaye_actions', $option_set['actions'] ); 375 } 376 377 378 //get products 133 379 $filters = get_post_meta( $id, '_yaye_products', true ); 134 380 … … 271 517 } 272 518 519 $data = array_reverse( $data ); 273 520 foreach ( $data as $option_set ) { 274 521 /** … … 591 838 } 592 839 } 840 841 public function update_reviewed_flag() { 842 try { 843 Utils::check_nonce(); 844 update_option( 'yaye_reviewed_flag', true ); 845 wp_send_json_success( 'success', 200 ); 846 } catch ( \Exception $ex ) { 847 wp_send_json_error( array( 'msg' => $ex->getMessage() ) ); 848 } catch ( \Error $err ) { 849 wp_send_json_error( array( 'msg' => $err->getMessage() ) ); 850 } 851 } 593 852 } -
yayextra/trunk/includes/Init/CustomPostType.php
r3383835 r3481811 55 55 56 56 /** 57 * Get list option set with params or get all without params. 57 * Get all option sets. 58 * 59 * @param int $option_set_id Option set id. 60 * @param string $search Search keyword. 61 * 62 * @return array 63 */ 64 protected static function get_all_option_sets( $option_set_id = 0, $search = '' ) { 65 $args = array( 66 'posts_per_page' => -1, 67 'post_type' => 'yaye_option_set', 68 'post_status' => 'publish', 69 'order' => 'DESC', 70 'orderby' => array( 71 'date' => 'DESC', 72 'ID' => 'DESC', 73 ), 74 ); 75 76 if ( ! empty( $option_set_id ) ) { 77 $args['p'] = $option_set_id; 78 } else { 79 $args['meta_query'] = array( 80 array( 81 'key' => '_yaye_name', 82 'value' => $search, 83 'compare' => 'LIKE', 84 ), 85 ); 86 } 87 88 $option_sets = get_posts( $args ); 89 return $option_sets; 90 } 91 92 /** 93 * Get paginated option sets. 94 * 95 * @param int $limit Limit of option sets. 96 * @param int $page Page number. 97 * @param int $option_set_id Option set id. 98 * @param string $search Search keyword. 99 * 100 * @return array 101 */ 102 protected static function get_paginated_option_sets( $limit = 10, $page = 1, $option_set_id = 0, $search = '' ) { 103 $args = array( 104 'posts_per_page' => $limit, 105 'paged' => $page, 106 'post_type' => 'yaye_option_set', 107 'post_status' => 'publish', 108 'order' => 'DESC', 109 'orderby' => array( 110 'date' => 'DESC', 111 'ID' => 'DESC', 112 ), 113 ); 114 115 if ( ! empty( $option_set_id ) ) { 116 $args['p'] = $option_set_id; 117 } else { 118 $args['meta_query'] = array( 119 array( 120 'key' => '_yaye_name', 121 'value' => $search, 122 'compare' => 'LIKE', 123 ), 124 ); 125 } 126 127 $option_sets = get_posts( $args ); 128 return $option_sets; 129 } 130 131 132 /** 133 * Get list option set with pagination or get all without pagination. 58 134 * 59 135 * @param array $params filter information. 60 * @param boolean $force_all Allow get all option sets.136 * @param boolean $force_all Allow get all option sets. 61 137 * 62 138 * @return array 63 139 */ 64 140 public static function get_list_option_set( $params = array(), $force_all = false ) { 65 global $wpdb; 66 67 $search = ! empty( $params['search'] ) ? $params['search'] : ''; // Option set name 68 $option_set_id = ! empty( $params['option_set_id'] ) && is_numeric( $params['option_set_id'] ) ? (int) $params['option_set_id'] : 0; // Option set ID 69 $limit = ! empty( $params['page_size'] ) && is_numeric( $params['page_size'] ) ? (int) $params['page_size'] : 10; 70 $page = ! empty( $params['current'] ) && is_numeric( $params['current'] ) ? (int) $params['current'] : 1; 71 72 // Build query components 73 $base_where = "p.post_type = 'yaye_option_set' AND p.post_status = 'publish'"; 74 75 // Handle search by ID 76 if ( ! empty( $option_set_id ) ) { 77 $join_clause = ''; 78 $search_where = " AND p.ID = %d"; 79 $search_params = array( $option_set_id ); 80 } else { 81 // Handle search by name (existing functionality) 82 $join_clause = ! empty( $search ) ? " INNER JOIN {$wpdb->prefix}postmeta pm ON p.ID = pm.post_id" : ''; 83 $search_where = ! empty( $search ) ? " AND pm.meta_key = '_yaye_name' AND pm.meta_value LIKE %s" : ''; 84 $search_params = ! empty( $search ) ? array( '%' . $wpdb->esc_like( $search ) . '%' ) : array(); 85 } 141 $search = ! empty( $params['search'] ) ? $params['search'] : ''; 142 $option_set_id = ! empty( $params['option_set_id'] ) && is_numeric( $params['option_set_id'] ) ? (int) $params['option_set_id'] : 0; 143 $limit = ! empty( $params['page_size'] ) && is_numeric( $params['page_size'] ) ? (int) $params['page_size'] : 10; 144 $page = ! empty( $params['current'] ) && is_numeric( $params['current'] ) ? (int) $params['current'] : 1; 86 145 87 146 // Get total count 88 $count_query = "SELECT COUNT(DISTINCT p.ID) FROM {$wpdb->prefix}posts p{$join_clause} WHERE {$base_where}{$search_where}"; 89 $total_items = ! empty( $search_params ) ? $wpdb->get_var( $wpdb->prepare( $count_query, $search_params ) ) : $wpdb->get_var( $count_query ); 90 91 // Handle force_all case 147 $option_sets = self::get_all_option_sets(); 148 $total_items = count( $option_sets ); 149 92 150 if ( $force_all ) { 93 $all_query = "SELECT DISTINCT p.* FROM {$wpdb->prefix}posts p{$join_clause} WHERE {$base_where}{$search_where} ORDER BY p.post_date DESC"; 94 return ! empty( $search_params ) ? $wpdb->get_results( $wpdb->prepare( $all_query, $search_params ) ) : $wpdb->get_results( $all_query ); 95 } 96 97 // Get paginated results 98 $offset = ( $page - 1 ) * $limit; 99 $query = "SELECT DISTINCT p.* FROM {$wpdb->prefix}posts p{$join_clause} WHERE {$base_where}{$search_where} ORDER BY p.post_date DESC LIMIT %d OFFSET %d"; 100 $final_params = array_merge( $search_params, array( $limit, $offset ) ); 101 $query_result = $wpdb->get_results( $wpdb->prepare( $query, $final_params ) ); 102 // Build option set list 151 return $option_sets; 152 } 153 154 // Get paginated data 155 $option_sets_paginated = self::get_paginated_option_sets( $limit, $page, $option_set_id, $search ); 156 103 157 $option_set_list = array(); 104 if ( ! empty( $ query_result) ) {105 foreach ( $ query_resultas $post ) {158 if ( ! empty( $option_sets_paginated ) ) { 159 foreach ( $option_sets_paginated as $post ) { 106 160 $option_set_list[] = self::build_option_set_data( $post->ID ); 107 161 } … … 151 205 */ 152 206 public static function get_option_set( $option_set_id ) { 207 153 208 return self::build_option_set_data( $option_set_id, true ); 209 154 210 } 155 211 … … 233 289 update_post_meta( $insert_id, '_yaye_name', 'Sample Option Set' ); 234 290 update_post_meta( $insert_id, '_yaye_description', 'Sample description' ); 235 update_post_meta( $insert_id, '_yaye_status', 0);291 update_post_meta( $insert_id, '_yaye_status', 1 ); 236 292 update_post_meta( $insert_id, '_yaye_options', array() ); 237 293 update_post_meta( $insert_id, '_yaye_actions', array() ); … … 240 296 '_yaye_products', 241 297 array( 242 'product_filter_type' => 1, // 1 : one by one (default), 2 : by conditions,298 'product_filter_type' => 3, // 1 : one by one, 2 : by conditions, 3 : all products, 243 299 'product_filter_one_by_one' => array(), 244 300 'product_filter_by_conditions' => array( … … 318 374 } 319 375 320 update_post_meta( $insert_id, '_yaye_name', $option_set_org['name'] ); 376 $clone_name = $option_set_org['name'] . '_Copy'; 377 update_post_meta( $insert_id, '_yaye_name', $clone_name ); 321 378 update_post_meta( $insert_id, '_yaye_description', $option_set_org['description'] ); 322 379 update_post_meta( $insert_id, '_yaye_status', $option_set_org['status'] ); -
yayextra/trunk/includes/Init/Settings.php
r3317357 r3481811 7 7 use YayExtra\Classes\ProductPage; 8 8 use YayExtra\Helper\Utils; 9 9 use YayExtra\Utils\SingletonTrait; 10 use YayExtra\Register\ScriptName; 10 11 defined( 'ABSPATH' ) || exit; 11 12 /** … … 16 17 class Settings { 17 18 18 /** 19 * Single instance of class 20 * 21 * @var Settings 22 */ 23 protected static $_instance = null; 24 25 /** 26 * Function ensure only one instance created 27 * 28 * @return Settings 29 */ 30 public static function get_instance() { 31 if ( is_null( self::$_instance ) ) { 32 self::$_instance = new self(); 33 } 34 return self::$_instance; 35 } 36 37 /** 38 * Constructor 39 * 40 * @return void 41 */ 19 use SingletonTrait; 20 42 21 private function __construct() { 43 22 if ( ! function_exists( 'WC' ) ) { … … 48 27 add_action( 49 28 'before_woocommerce_init', 50 function () {29 function () { 51 30 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 52 31 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', YAYE_PLUGIN_FILE, true ); … … 54 33 } 55 34 ); 56 35 add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); 57 36 add_action( 'admin_menu', array( $this, 'admin_menu' ), YAYE_MENU_PRIORITY ); 58 37 add_filter( 'plugin_action_links_' . YAYE_BASENAME, array( $this, 'plugin_action_links' ) ); … … 68 47 } 69 48 49 public function admin_body_class( $classes ) { 50 if ( strpos( $classes, 'yay-ui' ) === false ) { 51 $classes .= ' yay-ui'; 52 } 53 return $classes; 54 } 70 55 /** 71 56 * Call back for admin_menu action … … 115 100 $current_screen = get_current_screen(); 116 101 if ( 'yaycommerce_page_yayextra' === $current_screen->id ) { 117 118 // Enqueue react bundle.119 wp_enqueue_script( YAYE_PREFIX, YAYE_URL . 'assets/dist/js/main.bundle.js', array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'wp-components', 'wc-components' ), YAYE_VERSION, true );120 wp_enqueue_style( YAYE_PREFIX, YAYE_URL . 'assets/dist/css/main.css', array( 'wp-components', 'wc-components' ), YAYE_VERSION );121 122 102 // Enqueue script for wp.media . 123 103 wp_enqueue_media(); … … 139 119 $option_set_id_list = $this->get_option_set_id_list(); 140 120 121 wp_enqueue_script( ScriptName::PAGE_SETTINGS ); 122 wp_enqueue_style( ScriptName::STYLE_SETTINGS ); 123 wp_enqueue_style( 'yayextra-css', YAYE_URL . 'assets/css/yayextra.css', array(), YAYE_VERSION ); 124 141 125 // Localize script for react. 142 126 wp_localize_script( 143 YAYE_PREFIX,127 ScriptName::PAGE_SETTINGS, //YAYE_PREFIX, 144 128 'yaye_data', 145 129 array( … … 148 132 'ajax_url' => admin_url( 'admin-ajax.php' ), 149 133 'nonce' => wp_create_nonce( 'yaye_nonce' ), 150 ' image_url' => YAYE_URL . '/assets/dist/images/',134 'plugin_url' => YAYE_URL, 151 135 'site_url' => YAYE_SITE_URL, 152 136 'default_image_url' => \wc_placeholder_img_src(), … … 156 140 'mine_types' => Utils::get_mime_types(), 157 141 'size_allow' => size_format( wp_max_upload_size() ), 142 'rest_url' => esc_url_raw( rest_url() ), 143 'rest_nonce' => wp_create_nonce( 'wp_rest' ), 144 'rest_base' => 'yayextra/v1', 145 'settings' => get_option( 'yaye_settings' ), 146 'reviewed' => get_option( 'yaye_reviewed_flag' ), 147 'currency' => html_entity_decode( get_woocommerce_currency_symbol() ), 158 148 ) 159 149 ); 150 160 151 } 161 152 } … … 264 255 'value' => 400, 265 256 ), 257 'subtotal_price_font_size' => '16', 258 'subtotal_price_font_weight' => array( 259 'label' => '400', 260 'value' => 400, 261 ), 266 262 // 'total_price_color' => '#6d6d6d', 267 263 ), … … 326 322 'width' => '38', 327 323 'height' => '38', 328 'border_width' => ' 0',329 'border_color' => '# 43454b',324 'border_width' => '2', 325 'border_color' => '#f5f5f5', 330 326 'border_style' => array( 331 327 'label' => 'Solid', … … 333 329 ), 334 330 'selected_border_width' => '2', 335 'selected_border_color' => '# 43454b',331 'selected_border_color' => '#333333', 336 332 'selected_border_style' => array( 337 333 'label' => 'Solid', … … 342 338 'value' => 'bottom', 343 339 ), 344 'tooltip_background_color' => '# 555',340 'tooltip_background_color' => '##333333', 345 341 'tooltip_text_color' => '#fff', 342 'corner_radius' => '3', 346 343 ), 347 344 'button' => array( … … 352 349 'value' => 'solid', 353 350 ), 354 'border_color' => '# bcbcbc',351 'border_color' => '#e4e4e7', 355 352 'background_color' => '#fff', 356 'text_color' => '# 6d6d6d',353 'text_color' => '##333333', 357 354 // 'hover_styling' => false, 358 //'hover_border_color' => '#333333',359 //'hover_background_color' => '#fff',360 // 'hover_text_color' => '#6d6d6d',355 'hover_border_color' => '#333333', 356 'hover_background_color' => '#fff', 357 'hover_text_color' => '#333333', 361 358 'selected_border_color' => '#333333', 362 359 'selected_background_color' => '#333333', … … 366 363 'value' => 'bottom', 367 364 ), 368 'tooltip_background_color' => '# 555',365 'tooltip_background_color' => '#333333', 369 366 'tooltip_text_color' => '#fff', 370 367 ), … … 397 394 398 395 } 399 400 396 } -
yayextra/trunk/includes/Templates/button_field.php
r3383835 r3481811 82 82 $id_opt = $data['id'] . (string) $index; 83 83 $addition_cost = 0; 84 $addition_cost_original = 0; 84 85 if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) { 85 86 $cost_type = $opt['additionalCost']['costType']['value']; 86 87 if ( 'fixed' === $cost_type ) { 87 88 $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) ); 89 $addition_cost_original = floatval( $opt['additionalCost']['value'] ); 88 90 } else { 89 91 if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) { 90 92 $addition_cost = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price'] ) / 100; 93 $addition_cost_original = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price_original'] ) / 100; 91 94 } 92 95 } … … 95 98 if ( ! empty( $general_settings['show_additional_price'] ) && ! empty( $addition_cost ) ) { 96 99 if ( isset($cost_type) && 'percentage' === $cost_type ) { 97 $tooltip = '<strong class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . $addition_cost . '" data-option-org-cost="' . floatval( $opt['additionalCost']['value'] ) . '">' . $opt['value'] . ' ( + ' . wc_price( $addition_cost) . ' )</strong>';100 $tooltip = '<strong class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . esc_attr( $addition_cost ) . '" data-option-org-val="' . floatval( esc_attr( $opt['additionalCost']['value'] ) ) . '">' . esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr( $addition_cost ) ) . ' )</strong>'; 98 101 } else { 99 $tooltip = '<strong>' . $opt['value'] . ' ( + ' . wc_price( $addition_cost) . ' )</strong>';102 $tooltip = '<strong>' . esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr( $addition_cost ) ) . ' )</strong>'; 100 103 } 101 104 } else { 102 $tooltip = '<strong>' . $opt['value']. '</strong>';105 $tooltip = '<strong>' . esc_attr( $opt['value'] ) . '</strong>'; 103 106 } 104 107 105 108 echo '<div class="yayextra-opt-button yayextra-tooltip">'; 106 echo '<input id="' . esc_attr( $id_opt ) . '" name="option_field_data[' . esc_attr( $opt_set_id ) . '][' . esc_attr( $data['id'] ) . '][]" type="checkbox" data-opt-id="' . esc_attr( $data['id'] ) . '" data- addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( ! empty( $checked_results ) && in_array( $opt['value'], $checked_results, true ) ? 'checked' : '' ) . ' class="yayextra-option-button" style="display:none">';109 echo '<input id="' . esc_attr( $id_opt ) . '" name="option_field_data[' . esc_attr( $opt_set_id ) . '][' . esc_attr( $data['id'] ) . '][]" type="checkbox" data-opt-id="' . esc_attr( $data['id'] ) . '" data-option-org-cost="' . esc_attr( $addition_cost_original ) . '" data-addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( ! empty( $checked_results ) && in_array( $opt['value'], $checked_results, true ) ? 'checked' : '' ) . ' class="yayextra-option-button" style="display:none">'; 107 110 echo '<label class="yayextra-option-field-label yayextra-tooltip-wrap yayextra-option-button-label ' . esc_attr( $class_names ) . '">' . wp_kses_post( $opt['value'] ) . '</label>'; 108 111 echo '<span class="yayextra-tooltiptext ' . esc_attr( $tooltip_possition_class ) . '">' . wp_kses_post( $tooltip ) . '</span>'; -
yayextra/trunk/includes/Templates/checkbox_field.php
r3383835 r3481811 82 82 83 83 $addition_cost = 0; 84 $addition_cost_original = 0; 84 85 if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) { 85 86 $cost_type = $opt['additionalCost']['costType']['value']; 86 87 if ( 'fixed' === $cost_type ) { 87 88 $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) ); 89 $addition_cost_original = floatval( $opt['additionalCost']['value'] ); 88 90 } else { 89 91 if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) { 90 92 $addition_cost = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price'] ) / 100; 93 $addition_cost_original = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price_original'] ) / 100; 91 94 } 92 95 } … … 95 98 if ( ! empty( $general_settings['show_additional_price'] ) && ! empty( $addition_cost ) ) { 96 99 if ( isset($cost_type) && 'percentage' === $cost_type ) { 97 $label = '<span class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . $addition_cost . '" data-option-org-cost="' . floatval( $opt['additionalCost']['value'] ) . '">' . $opt['value'] . ' ( + ' . wc_price( $addition_cost) . ' ) </span>';100 $label = '<span class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . esc_attr($addition_cost) . '" data-option-org-val="' . floatval( esc_attr( $opt['additionalCost']['value'] ) ) . '">' . esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr($addition_cost) ) . ' ) </span>'; 98 101 } else { 99 $label = $opt['value'] . ' ( + ' . wc_price( $addition_cost) . ' )';102 $label = esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr( $addition_cost ) ) . ' )'; 100 103 } 101 104 } else { 102 $label = $opt['value'];105 $label = esc_attr( $opt['value'] ); 103 106 } 104 107 … … 109 112 110 113 echo '<div class="">'; 111 echo '<span class=""><input id="' . esc_attr( $id_opt ) . '" class="' . esc_attr( $class_names ) . '" type="checkbox" data- addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( ! empty( $checked_results ) && in_array( $opt['value'], $checked_results, true ) ? 'checked' : '' ) . ' name="option_field_data[' . esc_attr( $opt_set_id ) . '][' . esc_attr( $data['id'] ) . '][]"></span>';114 echo '<span class=""><input id="' . esc_attr( $id_opt ) . '" class="' . esc_attr( $class_names ) . '" type="checkbox" data-option-org-cost="' . esc_attr( $addition_cost_original ) . '" data-addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( ! empty( $checked_results ) && in_array( $opt['value'], $checked_results, true ) ? 'checked' : '' ) . ' name="option_field_data[' . esc_attr( $opt_set_id ) . '][' . esc_attr( $data['id'] ) . '][]"></span>'; 112 115 echo '<label class="yayextra-option-field-label" for="' . esc_attr( $id_opt ) . '">' . wp_kses_post( $label ) . '</label>'; 113 116 if ( ! empty( $addition_description ) ) { -
yayextra/trunk/includes/Templates/dropdown_field.php
r3383835 r3481811 37 37 38 38 if ( '' !== $placeholder_value ) { 39 echo '<option data-addition-cost="0" value="" >' . wp_kses_post( $placeholder_value ) . '</option>';39 echo '<option data-addition-cost="0" data-option-org-cost="0" value="" >' . wp_kses_post( $placeholder_value ) . '</option>'; 40 40 } else { 41 echo '<option data-addition-cost="0" value="" >' . esc_html__( 'Select your option', 'yayextra' ) . '</option>';41 echo '<option data-addition-cost="0" data-option-org-cost="0" value="" >' . esc_html__( 'Select your option', 'yayextra' ) . '</option>'; 42 42 } 43 43 … … 79 79 80 80 $addition_cost = 0; 81 $addition_cost_original = 0; 81 82 if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) { 82 83 $cost_type = $opt['additionalCost']['costType']['value']; 83 84 if ( 'fixed' === $cost_type ) { 84 85 $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) ); 86 $addition_cost_original = floatval( $opt['additionalCost']['value'] ); 85 87 } else { 86 88 if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) { 87 89 $addition_cost = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price'] ) / 100; 90 $addition_cost_original = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price_original'] ) / 100; 88 91 } 89 92 } … … 91 94 92 95 if ( ! empty( $general_settings['show_additional_price'] ) && ! empty( $addition_cost ) ) { 93 $label = $opt['value'] . ' ( + ' . wc_price( $addition_cost) . ' )';96 $label = $opt['value'] . ' ( + ' . wc_price( esc_attr( $addition_cost ) ) . ' )'; 94 97 95 98 if ( isset($cost_type) && 'percentage' === $cost_type ) { 96 echo '<option class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . esc_attr( $addition_cost ) . '" data-option-org- cost="' . floatval( $opt['additionalCost']['value']) . '" data-addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( $is_selected ? 'selected' : '' ) . '>' . wp_kses_post( $label ) . '</option>';99 echo '<option class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . esc_attr( $addition_cost ) . '" data-option-org-val="' . floatval( esc_attr( $opt['additionalCost']['value'] ) ) . '" data-option-org-cost="' . floatval( esc_attr( $addition_cost_original ) ) . '" data-addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( $is_selected ? 'selected' : '' ) . '>' . wp_kses_post( $label ) . '</option>'; 97 100 } else { 98 echo '<option data- addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( $is_selected ? 'selected' : '' ) . '>' . wp_kses_post( $label ) . '</option>';101 echo '<option data-option-org-cost="' . floatval( esc_attr( $addition_cost_original ) ) . '" data-addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( $is_selected ? 'selected' : '' ) . '>' . wp_kses_post( $label ) . '</option>'; 99 102 } 100 103 101 104 } else { 102 105 $label = $opt['value']; 103 echo '<option data- addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( $is_selected ? 'selected' : '' ) . '>' . wp_kses_post( $label ) . '</option>';106 echo '<option data-option-org-cost="' . floatval( esc_attr( $addition_cost_original ) ) . '" data-addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( $is_selected ? 'selected' : '' ) . '>' . wp_kses_post( $label ) . '</option>'; 104 107 } 105 108 } -
yayextra/trunk/includes/Templates/radio_field.php
r3383835 r3481811 40 40 41 41 $addition_cost = 0; 42 $addition_cost_original = 0; 42 43 if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) { 43 44 $cost_type = $opt['additionalCost']['costType']['value']; 44 45 if ( 'fixed' === $cost_type ) { 45 46 $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) ); 47 $addition_cost_original = floatval( $opt['additionalCost']['value'] ); 46 48 } else { 47 49 if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) { 48 50 $addition_cost = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price'] ) / 100; 51 $addition_cost_original = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price_original'] ) / 100; 49 52 } 50 53 } … … 53 56 if ( ! empty( $general_settings['show_additional_price'] ) && ! empty( $addition_cost ) ) { 54 57 if ( isset($cost_type) && 'percentage' === $cost_type ) { 55 $label = '<span class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . $addition_cost . '" data-option-org-cost="' . floatval( $opt['additionalCost']['value'] ) . '">' . $opt['value'] . ' ( + ' . wc_price( $addition_cost) . ' ) </span>';58 $label = '<span class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . esc_attr($addition_cost) . '" data-option-org-val="' . floatval( esc_attr( $opt['additionalCost']['value'] ) ) . '">' . esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr($addition_cost) ) . ' ) </span>'; 56 59 } else { 57 $label = $opt['value'] . ' ( + ' . wc_price( $addition_cost) . ' )';60 $label = esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr( $addition_cost ) ) . ' )'; 58 61 } 59 62 } else { 60 $label = $opt['value'];63 $label = esc_attr( $opt['value'] ); 61 64 } 62 65 … … 97 100 98 101 echo '<div class="">'; 99 echo '<span class=""><input id="' . esc_attr( $id_opt ) . '" name="option_field_data[' . esc_attr( $opt_set_id ) . '][' . esc_attr( $data['id'] ) . ']" class="' . esc_attr( $class_names ) . '" type="radio" data- addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( $is_checked ? 'checked' : '' ) . esc_attr( $is_required ? ' required ' : '' ) . '></span>';102 echo '<span class=""><input id="' . esc_attr( $id_opt ) . '" name="option_field_data[' . esc_attr( $opt_set_id ) . '][' . esc_attr( $data['id'] ) . ']" class="' . esc_attr( $class_names ) . '" type="radio" data-option-org-cost="' . esc_attr( $addition_cost_original ) . '" data-addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( $is_checked ? 'checked' : '' ) . esc_attr( $is_required ? ' required ' : '' ) . '></span>'; 100 103 echo '<label class="yayextra-option-field-label" for="' . esc_attr( $id_opt ) . '">' . wp_kses_post( $label ) . '</label>'; 101 104 if ( ! empty( $addition_description ) ) { -
yayextra/trunk/includes/Templates/swatches_field.php
r3383835 r3481811 102 102 $id_opt = $data['id'] . (string) $index; 103 103 $addition_cost = 0; 104 $addition_cost_original = 0; 104 105 if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) { 105 106 $cost_type = $opt['additionalCost']['costType']['value']; 106 107 if ( 'fixed' === $cost_type ) { 107 108 $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) ); 109 $addition_cost_original = floatval( $opt['additionalCost']['value'] ); 108 110 } else { 109 111 if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) { 110 112 $addition_cost = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price'] ) / 100; 113 $addition_cost_original = floatval( $opt['additionalCost']['value'] ) * floatval( $params['product_price_original'] ) / 100; 111 114 } 112 115 } … … 115 118 if ( ! empty( $general_settings['show_additional_price'] ) && ! empty( $addition_cost ) ) { 116 119 if ( isset($cost_type) && 'percentage' === $cost_type ) { 117 $tooltip = '<strong class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . $addition_cost . '" data-option-org-cost="' . floatval( $opt['additionalCost']['value'] ) . '">' . $opt['value'] . ' ( + ' . wc_price( $addition_cost) . ' )</strong>';120 $tooltip = '<strong class="option-addition-percentage-cost" data-opt-val-id="' . esc_attr( $id_opt ) . '" data-option-org-cost-token-replace="' . esc_attr( $addition_cost ) . '" data-option-org-val="' . floatval( esc_attr( $opt['additionalCost']['value'] ) ) . '">' . esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr( $addition_cost ) ) . ' )</strong>'; 118 121 } else { 119 $tooltip = '<strong>' . $opt['value'] . ' ( + ' . wc_price( $addition_cost) . ' )</strong>';122 $tooltip = '<strong>' . esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr( $addition_cost ) ) . ' )</strong>'; 120 123 } 121 124 } else { 122 $tooltip = '<strong>' . $opt['value']. '</strong>';125 $tooltip = '<strong>' . esc_attr( $opt['value'] ) . '</strong>'; 123 126 } 124 127 125 128 echo '<div class="yayextra-opt-swatches yayextra-tooltip">'; 126 echo '<input id="' . esc_attr( $id_opt ) . '" name="option_field_data[' . esc_attr( $opt_set_id ) . '][' . esc_attr( $data['id'] ) . '][]" type="checkbox" data-optset-id="' . esc_attr( $opt_set_id ) . '" data-opt-id="' . esc_attr( $data['id'] ) . '" data-opt-img="' . esc_attr( $opt['imageUrl'] ) . '" data-product-img="' . esc_attr( $product_image[0] ) . '" data-product-id="' . esc_attr( $product_id ) . '" data- addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( ! empty( $checked_results ) && in_array( $opt['value'], $checked_results, true ) ? 'checked' : '' ) . ' style="display:none">';129 echo '<input id="' . esc_attr( $id_opt ) . '" name="option_field_data[' . esc_attr( $opt_set_id ) . '][' . esc_attr( $data['id'] ) . '][]" type="checkbox" data-optset-id="' . esc_attr( $opt_set_id ) . '" data-opt-id="' . esc_attr( $data['id'] ) . '" data-opt-img="' . esc_attr( $opt['imageUrl'] ) . '" data-product-img="' . esc_attr( $product_image[0] ) . '" data-product-id="' . esc_attr( $product_id ) . '" data-option-org-cost="' . esc_attr( $addition_cost_original ) . '" data-addition-cost="' . esc_attr( $addition_cost ) . '" value="' . esc_attr( $opt['value'] ) . '"' . ( ! empty( $checked_results ) && in_array( $opt['value'], $checked_results, true ) ? 'checked' : '' ) . ' style="display:none">'; 127 130 if ( 'image' === $opt['swatchesType'] && ! empty( $opt['imageUrl'] ) ) { 128 131 echo '<div class="yayextra-option-field-swatches-label yayextra-tooltip-wrap yayextra-option-field-swatches-label-image ' . esc_attr( $class_swatches_shape ) . ' ' . esc_attr( $class_names ) . '" style="background-image: url(' . esc_attr( $opt['imageUrl'] ) . ')"></div>'; -
yayextra/trunk/includes/YayCommerceMenu/OtherPluginsMenu.php
r3383835 r3481811 164 164 165 165 public static function get_other_plugins() { 166 return array( 167 'filebird' => array( 168 'slug' => 'filebird', 169 'name' => 'FileBird - WordPress Media Library Folders & File Manager', 170 'short_description' => 'Organize thousands of WordPress media files in folders / categories at ease.', 171 'icon' => 'https://ps.w.org/filebird/assets/icon-128x128.gif?rev=2299145', 172 'download_link' => 'https://downloads.wordpress.org/plugin/filebird.zip', 173 'type' => array( 'featured' ), 174 'version' => 0, 175 ), 176 'yaymail' => array( 177 'slug' => 'yaymail', 178 'name' => 'YayMail - WooCommerce Email Customizer', 179 'short_description' => 'Customize WooCommerce email templates with live preview & drag and drop email builder.', 180 'icon' => 'https://ps.w.org/yaymail/assets/icon-256x256.gif?rev=2599198', 181 'download_link' => 'https://downloads.wordpress.org/plugin/yaymail.zip', 182 'type' => array( 'featured', 'woocommerce' ), 183 'version' => 0, 184 ), 185 'yaycurrency' => array( 186 'slug' => 'yaycurrency', 187 'name' => 'YayCurrency - WooCommerce Multi-Currency Switcher', 188 'short_description' => 'WooCommerce Multi-Currency made easy, powerful, and flexible.', 189 'icon' => 'https://ps.w.org/yaycurrency/assets/icon-256x256.png?rev=2550570', 190 'download_link' => 'https://downloads.wordpress.org/plugin/yaycurrency.zip', 191 'type' => array( 'featured', 'woocommerce' ), 192 'version' => 0, 193 ), 194 'yayswatches' => array( 195 'slug' => 'yayswatches', 196 'name' => 'YaySwatches - Variation Swatches for WooCommerce', 197 'short_description' => 'Optimize your variable product showcase with color swatches, image swatches, custom images, buttons, and more!', 198 'icon' => 'https://ps.w.org/yayswatches/assets/icon-256x256.png?rev=2757155', 199 'download_link' => 'https://downloads.wordpress.org/plugin/yayswatches.zip', 200 'type' => array( 'woocommerce' ), 201 'version' => 0, 202 ), 203 'yayextra' => array( 204 'slug' => 'yayextra', 205 'name' => 'YayExtra - WooCommerce Extra Product Options', 206 'short_description' => 'Add WooCommerce product options like personal engraving, print-on-demand items, gifts, custom canvas prints, and personalized products.', 207 'icon' => 'https://ps.w.org/yayextra/assets/icon-256x256.png?rev=2776349', 208 'download_link' => 'https://downloads.wordpress.org/plugin/yayextra.zip', 209 'type' => array( 'woocommerce' ), 210 'version' => 0, 211 ), 212 'yaypricing' => array( 213 'slug' => 'yaypricing', 214 'name' => 'YayPricing - WooCommerce Dynamic Pricing & Discounts', 215 'short_description' => 'Offer automatic pricing and discounts to design a powerful marketing strategy for your WooCommerce store.', 216 'icon' => 'https://yaycommerce.com/wp-content/uploads/2022/11/yaypricing-256x256-1.png', 217 'download_link' => 'https://yaycommerce.com/yaypricing-woocommerce-dynamic-pricing-and-discounts/', 218 'type' => array( 'woocommerce' ), 219 'version' => 0, 220 ), 221 'yaysmtp' => array( 222 'slug' => 'yaysmtp', 223 'name' => 'YaySMTP - Simple WP SMTP Mail', 224 'short_description' => 'Send WordPress emails successfully with WP Mail SMTP via your favorite Mailer.', 225 'icon' => 'https://ps.w.org/yaysmtp/assets/icon-256x256.png?rev=2437984', 226 'download_link' => 'https://downloads.wordpress.org/plugin/yaysmtp.zip', 227 'type' => array( 'featured', 'marketing' ), 228 'version' => 0, 229 ), 230 'wp-whatsapp' => array( 231 'slug' => 'wp-whatsapp', 232 'name' => 'WP Chat App', 233 'short_description' => 'Integrate WhatsApp experience directly into your WordPress website.', 234 'icon' => 'https://ps.w.org/wp-whatsapp/assets/icon-256x256.png?rev=2725670', 235 'download_link' => 'https://downloads.wordpress.org/plugin/wp-whatsapp.zip', 236 'type' => array( 'featured' ), 237 'version' => 0, 238 ), 239 'filester' => array( 240 'slug' => 'filester', 241 'name' => 'Filester - File Manager Pro', 242 'short_description' => 'Best WordPress file manager without FTP access. Clean design. No need to upgrade because this…', 243 'icon' => 'https://ps.w.org/filester/assets/icon-256x256.gif?rev=2305540', 244 'download_link' => 'https://downloads.wordpress.org/plugin/filester.zip', 245 'type' => array( 'management' ), 246 'version' => 0, 247 ), 248 'cf7-multi-step' => array( 249 'slug' => 'cf7-multi-step', 250 'name' => 'Multi Step for Contact Form 7', 251 'short_description' => 'Break your looooooong form into user-friendly steps.', 252 'icon' => 'https://ps.w.org/cf7-multi-step/assets/icon-256x256.png?rev=1994366', 253 'download_link' => 'https://downloads.wordpress.org/plugin/cf7-multi-step.zip', 254 'type' => array( 'management' ), 255 'version' => 0, 256 ), 257 'cf7-database' => array( 258 'slug' => 'cf7-database', 259 'name' => 'Database for Contact Form 7', 260 'short_description' => 'Automatically save all data submitted via Contact Form 7 to your database.', 261 'icon' => 'https://ps.w.org/cf7-database/assets/icon-128x128.png?rev=1614091', 262 'download_link' => 'https://downloads.wordpress.org/plugin/cf7-database.zip', 263 'type' => array( 'management' ), 264 'version' => 0, 265 ), 266 'wp-duplicate-page' => array( 267 'slug' => 'wp-duplicate-page', 268 'name' => 'WP Duplicate Page', 269 'short_description' => 'Clone WordPress page, post, custom post types.', 270 'icon' => 'https://ps.w.org/wp-duplicate-page/assets/icon-256x256.gif?rev=2432962', 271 'download_link' => 'https://downloads.wordpress.org/plugin/wp-duplicate-page.zip', 272 'type' => array( 'management' ), 273 'version' => 0, 274 ), 275 'notibar' => array( 276 'slug' => 'notibar', 277 'name' => 'Notibar - Notification Bar for WordPress', 278 'short_description' => 'Customizer for sticky header, notification bar, alert, promo code, marketing campaign, top banner.', 279 'icon' => 'https://ps.w.org/notibar/assets/icon-256x256.png?rev=2387855', 280 'download_link' => 'https://downloads.wordpress.org/plugin/notibar.zip', 281 'type' => array( 'marketing' ), 282 'version' => 0, 283 ), 284 'yayreviews' => [ 166 return [ 167 'filebird' => [ 168 'slug' => 'filebird', 169 'name' => 'FileBird - WordPress Media Library Folders & File Manager', 170 'short_description' => 'Organize thousands of WordPress media files in folders / categories at ease.', 171 'icon' => 'https://ps.w.org/filebird/assets/icon-128x128.gif', 172 'download_link' => 'https://downloads.wordpress.org/plugin/filebird.zip', 173 'type' => [ 'featured' ], 174 'version' => 0, 175 ], 176 'yaymail' => [ 177 'slug' => 'yaymail', 178 'name' => 'YayMail - WooCommerce Email Customizer', 179 'short_description' => 'Customize WooCommerce email templates with live preview & drag and drop email builder.', 180 'icon' => 'https://ps.w.org/yaymail/assets/icon-256x256.gif', 181 'download_link' => 'https://downloads.wordpress.org/plugin/yaymail.zip', 182 'type' => [ 'featured', 'woocommerce' ], 183 'version' => 0, 184 ], 185 'yaycurrency' => [ 186 'slug' => 'yaycurrency', 187 'name' => 'YayCurrency - WooCommerce Multi-Currency Switcher', 188 'short_description' => 'WooCommerce Multi-Currency made easy, powerful, and flexible.', 189 'icon' => 'https://ps.w.org/yaycurrency/assets/icon-256x256.png', 190 'download_link' => 'https://downloads.wordpress.org/plugin/yaycurrency.zip', 191 'type' => [ 'featured', 'woocommerce' ], 192 'version' => 0, 193 ], 194 'yayswatches' => [ 195 'slug' => 'yayswatches', 196 'name' => 'YaySwatches - Variation Swatches for WooCommerce', 197 'short_description' => 'Optimize your variable product showcase with color swatches, image swatches, custom images, buttons, and more!', 198 'icon' => 'https://ps.w.org/yayswatches/assets/icon-256x256.png', 199 'download_link' => 'https://downloads.wordpress.org/plugin/yayswatches.zip', 200 'type' => [ 'woocommerce' ], 201 'version' => 0, 202 ], 203 'yayextra' => [ 204 'slug' => 'yayextra', 205 'name' => 'YayExtra - WooCommerce Extra Product Options', 206 'short_description' => 'Add WooCommerce product options like personal engraving, print-on-demand items, gifts, custom canvas prints, and personalized products.', 207 'icon' => 'https://ps.w.org/yayextra/assets/icon-256x256.png', 208 'download_link' => 'https://downloads.wordpress.org/plugin/yayextra.zip', 209 'type' => [ 'woocommerce' ], 210 'version' => 0, 211 ], 212 'yaypricing' => [ 213 'slug' => 'yaypricing', 214 'name' => 'YayPricing - WooCommerce Dynamic Pricing & Discounts', 215 'short_description' => 'Offer automatic pricing and discounts to design a powerful marketing strategy for your WooCommerce store.', 216 'icon' => 'https://ps.w.org/yaypricing/assets/icon-256x256.png', 217 'download_link' => 'https://downloads.wordpress.org/plugin/yaypricing.zip', 218 'type' => [ 'woocommerce' ], 219 'version' => 0, 220 ], 221 'yaysmtp' => [ 222 'slug' => 'yaysmtp', 223 'name' => 'YaySMTP - Simple WP SMTP Mail', 224 'short_description' => 'Send WordPress emails successfully with WP Mail SMTP via your favorite Mailer.', 225 'icon' => 'https://ps.w.org/yaysmtp/assets/icon-256x256.png', 226 'download_link' => 'https://downloads.wordpress.org/plugin/yaysmtp.zip', 227 'type' => [ 'featured', 'marketing' ], 228 'version' => 0, 229 ], 230 'yayreviews' => [ 285 231 'slug' => 'yay-customer-reviews-woocommerce', 286 232 'name' => 'YayReviews – Advanced Customer Reviews for WooCommerce', 287 'short_description' => ' Collect more customer reviews through automated reminders and rewards.',288 'icon' => 'https://ps.w.org/yay-customer-reviews-woocommerce/assets/icon-256x256.png ?rev=3340109',233 'short_description' => 'YayReviews helps online stores collect, manage, and display authentic customer feedback.', 234 'icon' => 'https://ps.w.org/yay-customer-reviews-woocommerce/assets/icon-256x256.png', 289 235 'download_link' => 'https://downloads.wordpress.org/plugin/yay-customer-reviews-woocommerce.zip', 290 'type' => [ 'woocommerce' ], 291 'version' => 0, 292 ], 293 ); 294 } 236 'type' => [ 'featured', 'woocommerce' ], 237 'version' => 0, 238 ], 239 'yay-wholesale-b2b' => [ 240 'slug' => 'yay-wholesale-b2b', 241 'name' => 'Yay Wholesale B2B for WooCommerce', 242 'short_description' => 'Yay Wholesale & B2B for WooCommerce is a powerful plugin that allows you to sell your products to wholesale customers and businesses.', 243 'icon' => 'https://ps.w.org/yay-wholesale-b2b/assets/icon-256x256.png', 244 'download_link' => 'https://downloads.wordpress.org/plugin/yay-wholesale-b2b.zip', 245 'type' => [ 'featured', 'woocommerce' ], 246 'version' => 0, 247 ], 248 'yayboost-sales-booster-for-woocommerce' => [ 249 'slug' => 'yayboost-sales-booster-for-woocommerce', 250 'name' => 'YayBoost – Sales Booster for WooCommerce', 251 'short_description' => 'Boost conversions with smart sales triggers', 252 'icon' => 'https://ps.w.org/yayboost-sales-booster-for-woocommerce/assets/icon-256x256.png', 253 'download_link' => 'https://downloads.wordpress.org/plugin/yayboost-sales-booster-for-woocommerce.zip', 254 'type' => [ 'featured', 'woocommerce' ], 255 'version' => 0, 256 ], 257 'wp-whatsapp' => [ 258 'slug' => 'wp-whatsapp', 259 'name' => 'WP Chat App', 260 'short_description' => 'Integrate WhatsApp experience directly into your WordPress website.', 261 'icon' => 'https://ps.w.org/wp-whatsapp/assets/icon-256x256.png', 262 'download_link' => 'https://downloads.wordpress.org/plugin/wp-whatsapp.zip', 263 'type' => [ 'featured' ], 264 'version' => 0, 265 ], 266 'filebird-document-library' => [ 267 'slug' => 'filebird-document-library', 268 'name' => 'FileBird Document Library', 269 'short_description' => 'Create and publish document galleries using Gutenberg and FileBird folders.', 270 'icon' => 'https://ps.w.org/filebird-document-library/assets/icon-256x256.png', 271 'download_link' => 'https://downloads.wordpress.org/plugin/filebird-document-library.zip', 272 'url' => 'https://wordpress.org/plugins/filebird-document-library/', 273 'type' => [ 'management' ], 274 'version' => 0, 275 ], 276 'filester' => [ 277 'slug' => 'filester', 278 'name' => 'Filester - File Manager Pro', 279 'short_description' => 'Best WordPress file manager without FTP access. Clean design. No need to upgrade because this…', 280 'icon' => 'https://ps.w.org/filester/assets/icon-256x256.gif', 281 'download_link' => 'https://downloads.wordpress.org/plugin/filester.zip', 282 'type' => [ 'management' ], 283 'version' => 0, 284 ], 285 'cf7-multi-step' => [ 286 'slug' => 'cf7-multi-step', 287 'name' => 'Multi Step for Contact Form 7', 288 'short_description' => 'Break your looooooong form into user-friendly steps.', 289 'icon' => 'https://ps.w.org/cf7-multi-step/assets/icon-256x256.png', 290 'download_link' => 'https://downloads.wordpress.org/plugin/cf7-multi-step.zip', 291 'type' => [ 'management' ], 292 'version' => 0, 293 ], 294 'cf7-database' => [ 295 'slug' => 'cf7-database', 296 'name' => 'Database for Contact Form 7', 297 'short_description' => 'Automatically save all data submitted via Contact Form 7 to your database.', 298 'icon' => 'https://ps.w.org/cf7-database/assets/icon-256x256.png', 299 'download_link' => 'https://downloads.wordpress.org/plugin/cf7-database.zip', 300 'type' => [ 'management' ], 301 'version' => 0, 302 ], 303 'wp-duplicate-page' => [ 304 'slug' => 'wp-duplicate-page', 305 'name' => 'WP Duplicate Page', 306 'short_description' => 'Clone WordPress page, post, custom post types.', 307 'icon' => 'https://ps.w.org/wp-duplicate-page/assets/icon-256x256.gif', 308 'download_link' => 'https://downloads.wordpress.org/plugin/wp-duplicate-page.zip', 309 'type' => [ 'management' ], 310 'version' => 0, 311 ], 312 'notibar' => [ 313 'slug' => 'notibar', 314 'name' => 'Notibar - Notification Bar for WordPress', 315 'short_description' => 'Customizer for sticky header, notification bar, alert, promo code, marketing campaign, top banner.', 316 'icon' => 'https://ps.w.org/notibar/assets/icon-256x256.png', 317 'download_link' => 'https://downloads.wordpress.org/plugin/notibar.zip', 318 'type' => [ 'marketing' ], 319 'version' => 0, 320 ], 321 'fastdup' => [ 322 'slug' => 'fastdup', 323 'name' => 'FastDup – Fastest WordPress Migration & Duplicator', 324 'short_description' => 'Backup and migrate your WordPress sites.', 325 'icon' => 'https://ps.w.org/fastdup/assets/icon-256x256.png', 326 'download_link' => 'https://downloads.wordpress.org/plugin/fastdup.zip', 327 'url' => 'https://wordpress.org/plugins/fastdup/', 328 'version' => 0, 329 'type' => [ 'management' ], 330 ], 331 'ninja-gdpr-compliance' => [ 332 'slug' => 'ninja-gdpr-compliance', 333 'name' => 'GDPR CCPA Compliance & Cookie Consent Banner', 334 'short_description' => 'Protect personal user data and privacy of EU citizens.', 335 'icon' => 'https://ps.w.org/ninja-gdpr-compliance/assets/icon-128x128.png', 336 'download_link' => 'https://downloads.wordpress.org/plugin/ninja-gdpr-compliance.zip', 337 'url' => 'https://wordpress.org/plugins/ninja-gdpr-compliance/', 338 'type' => [ 'management' ], 339 'version' => 0, 340 ], 341 ]; 342 } 295 343 296 344 public function yay_recommended_get_plugin_data() { … … 499 547 public function check_pro_version_exists( $pluginDetail ) { 500 548 $existProVer = false; 501 $allPlugin = get_plugins();549 $allPlugins = get_plugins(); 502 550 if ( 'filebird' === $pluginDetail['slug'] ) { 503 $existProVer = array_key_exists( 'filebird-pro/filebird.php', $allPlugin ) === true ? 'filebird-pro/filebird.php' : false;551 $existProVer = array_key_exists( 'filebird-pro/filebird.php', $allPlugins ) === true ? 'filebird-pro/filebird.php' : false; 504 552 } 505 553 if ( 'yaymail' === $pluginDetail['slug'] ) { 506 if ( array_key_exists( 'yaymail-pro/yaymail.php', $allPlugin ) ) {554 if ( array_key_exists( 'yaymail-pro/yaymail.php', $allPlugins ) ) { 507 555 $existProVer = 'yaymail-pro/yaymail.php'; 508 } elseif ( array_key_exists( 'email-customizer-for-woocommerce/yaymail.php', $allPlugin ) ) {556 } elseif ( array_key_exists( 'email-customizer-for-woocommerce/yaymail.php', $allPlugins ) ) { 509 557 $existProVer = 'email-customizer-for-woocommerce/yaymail.php'; 510 558 } 511 559 } 512 560 if ( 'yaycurrency' === $pluginDetail['slug'] ) { 513 if ( array_key_exists( 'yaycurrency-pro/yay-currency.php', $allPlugin ) ) {561 if ( array_key_exists( 'yaycurrency-pro/yay-currency.php', $allPlugins ) ) { 514 562 $existProVer = 'yaycurrency-pro/yay-currency.php'; 515 } elseif ( array_key_exists( 'multi-currency-switcher/yay-currency.php', $allPlugin ) ) {563 } elseif ( array_key_exists( 'multi-currency-switcher/yay-currency.php', $allPlugins ) ) { 516 564 $existProVer = 'multi-currency-switcher/yay-currency.php'; 517 565 } 518 566 } 519 567 if ( 'yaysmtp' === $pluginDetail['slug'] ) { 520 $existProVer = array_key_exists( 'yaysmtp-pro/yay-smtp.php', $allPlugin ) === true ? 'yaysmtp-pro/yay-smtp.php' : false;568 $existProVer = array_key_exists( 'yaysmtp-pro/yay-smtp.php', $allPlugins ) === true ? 'yaysmtp-pro/yay-smtp.php' : false; 521 569 } 522 570 if ( 'yayswatches' === $pluginDetail['slug'] ) { 523 $existProVer = array_key_exists( 'yayswatches-pro/yay-swatches.php', $allPlugin ) === true ? 'yayswatches-pro/yay-swatches.php' : false;571 $existProVer = array_key_exists( 'yayswatches-pro/yay-swatches.php', $allPlugins ) === true ? 'yayswatches-pro/yay-swatches.php' : false; 524 572 } 525 573 if ( 'yayextra' === $pluginDetail['slug'] ) { 526 $existProVer = array_key_exists( 'yayextra-pro/yayextra.php', $allPlugin ) === true ? 'yayextra-pro/yayextra.php' : false;574 $existProVer = array_key_exists( 'yayextra-pro/yayextra.php', $allPlugins ) === true ? 'yayextra-pro/yayextra.php' : false; 527 575 } 528 576 if ( 'yaypricing' === $pluginDetail['slug'] ) { 529 $existProVer = array_key_exists( 'yaypricing-pro/yaypricing.php', $allPlugin ) === true ? 'yaypricing-pro/yaypricing.php' : false; 577 if ( array_key_exists( 'yaypricing-pro/yaypricing.php', $allPlugins ) ) { 578 $existProVer = 'yaypricing-pro/yaypricing.php'; 579 } elseif ( array_key_exists( 'dynamic-pricing-discounts/yaypricing.php', $allPlugins ) ) { 580 $existProVer = 'dynamic-pricing-discounts/yaypricing.php'; 581 } 582 } 583 if ( 'yay-customer-reviews-woocommerce' === $pluginDetail['slug'] ) { 584 if ( array_key_exists( 'yayreviews-pro/yay-customer-reviews-woocommerce.php', $allPlugins ) ) { 585 $existProVer = 'yayreviews-pro/yay-customer-reviews-woocommerce.php'; 586 } 587 } 588 if ( 'yay-wholesale-b2b' === $pluginDetail['slug'] ) { 589 if ( array_key_exists( 'yay-wholesale-b2b-pro/yay-wholesale-b2b.php', $allPlugins ) ) { 590 $existProVer = 'yay-wholesale-b2b-pro/yay-wholesale-b2b.php'; 591 } 530 592 } 531 593 if ( 'cf7-multi-step' === $pluginDetail['slug'] ) { 532 $existProVer = array_key_exists( 'contact-form-7-multi-step-pro/contact-form-7-multi-step.php', $allPlugin ) === true ? 'contact-form-7-multi-step-pro/contact-form-7-multi-step.php' : false;594 $existProVer = array_key_exists( 'contact-form-7-multi-step-pro/contact-form-7-multi-step.php', $allPlugins ) === true ? 'contact-form-7-multi-step-pro/contact-form-7-multi-step.php' : false; 533 595 } 534 596 if ( 'cf7-database' === $pluginDetail['slug'] ) { 535 $existProVer = array_key_exists( 'contact-form-7-database-pro/cf7-database.php', $allPlugin ) === true ? 'contact-form-7-database-pro/cf7-database.php' : false;597 $existProVer = array_key_exists( 'contact-form-7-database-pro/cf7-database.php', $allPlugins ) === true ? 'contact-form-7-database-pro/cf7-database.php' : false; 536 598 } 537 599 if ( 'wp-whatsapp' === $pluginDetail['slug'] ) { 538 $existProVer = array_key_exists( 'whatsapp-for-wordpress/whatsapp.php', $allPlugin ) === true ? 'whatsapp-for-wordpress/whatsapp.php' : false; 539 } 540 if ( 'yay-customer-reviews-woocommerce' === $pluginDetail['slug'] ) { 541 if ( array_key_exists( 'yayreviews-pro/yay-customer-reviews-woocommerce.php', $allPlugin ) ) { 542 $existProVer = 'yayreviews-pro/yay-customer-reviews-woocommerce.php'; 543 } elseif ( array_key_exists( 'yay-customer-reviews-woocommerce/yay-customer-reviews-woocommerce.php', $allPlugin ) ) { 544 $existProVer = 'yay-customer-reviews-woocommerce/yay-customer-reviews-woocommerce.php'; 545 } elseif ( array_key_exists( 'yayreviews/yay-customer-reviews-woocommerce.php', $allPlugin ) ) { 546 $existProVer = 'yayreviews/yay-customer-reviews-woocommerce.php'; 600 $existProVer = array_key_exists( 'whatsapp-for-wordpress/whatsapp.php', $allPlugins ) === true ? 'whatsapp-for-wordpress/whatsapp.php' : false; 601 } 602 if ( 'yayboost-sales-booster-for-woocommerce' === $pluginDetail['slug'] ) { 603 if ( array_key_exists( 'yayboost-pro/yayboost-sales-booster-for-woocommerce.php', $allPlugins ) ) { 604 $existProVer = 'yayboost-pro/yayboost-sales-booster-for-woocommerce.php'; 547 605 } 548 606 } -
yayextra/trunk/includes/YayCommerceMenu/RegisterMenu.php
r3383835 r3481811 74 74 75 75 public function get_submenus() { 76 $submenus['yaycommerce-help'] = array( 77 'parent' => 'yaycommerce', 78 'name' => __( 'Help', 'yaycommerce' ), 79 'capability' => 'manage_options', 80 'render_callback' => false, 81 'load_data_callback' => false, 82 ); 83 84 /** 85 * Temporarily until all Yay plugins has the same code 86 */ 87 if ( function_exists( 'YAYDP\\load_plugin' ) && class_exists( '\YAYDP\License\License_Handler' ) ) { 88 $licensing_plugins_yay_pricing = \YAYDP\License\License_Handler::get_licensing_plugins(); 89 } 90 91 if ( function_exists( 'YayMail\\plugin_init' ) && class_exists( '\YayMail\License\LicenseHandler' ) ) { 92 $licensing_plugins_yay_mail = \YayMail\License\LicenseHandler::get_licensing_plugins(); 93 } 94 95 if ( function_exists( 'Yay_Swatches\\init' ) && class_exists( '\Yay_Swatches\License\LicenseHandler' ) ) { 96 $licensing_plugins_yay_swatches = \Yay_Swatches\License\LicenseHandler::get_licensing_plugins(); 97 } 98 99 if ( function_exists( 'YaySMTP\\init' ) && class_exists( '\YaySMTP\License\LicenseHandler' ) ) { 100 $licensing_plugins_yay_smtp = \YaySMTP\License\LicenseHandler::get_licensing_plugins(); 101 } 102 103 if ( function_exists( 'Yay_Currency\\plugin_init' ) && class_exists( '\Yay_Currency\License\LicenseHandler' ) ) { 104 $licensing_plugins_yay_currency = \Yay_Currency\License\LicenseHandler::get_licensing_plugins(); 105 } 106 /** -------- */ 107 108 $yay_licensing_plugins = apply_filters( 'yaycommerce_licensing_plugins', [] ); 109 110 if ( ! empty( $licensing_plugins_yay_mail ) || ! empty( $licensing_plugins_yay_pricing ) || ! empty( $licensing_plugins_yay_swatches ) || ! empty( $licensing_plugins_yay_smtp ) || ! empty( $licensing_plugins_yay_currency ) || ! empty( $yay_licensing_plugins ) ) { 111 $submenus['yaycommerce-licenses'] = array( 76 return array( 77 // 'yaycommerce' => array( 78 // 'parent' => 'yaycommerce', 79 // 'name' => __( 'Dashboard', 'yaycommerce' ), 80 // 'capability' => 'manage_options', 81 // 'render_callback' => false, 82 // 'load_data_callback' => false, 83 // 'position' => 0, 84 // ), 85 'yaycommerce-help' => array( 86 'parent' => 'yaycommerce', 87 'name' => __( 'Help', 'yaycommerce' ), 88 'capability' => 'manage_options', 89 'render_callback' => false, 90 'load_data_callback' => false, 91 ), 92 'yaycommerce-licenses' => array( 112 93 'parent' => 'yaycommerce', 113 94 'name' => __( 'Licenses', 'yaycommerce' ), … … 115 96 'render_callback' => array( '\YayExtra\YayCommerceMenu\LicensesMenu', 'render' ), 116 97 'load_data_callback' => array( '\YayExtra\YayCommerceMenu\LicensesMenu', 'load_data' ), 117 ); 118 } 119 120 $submenus['yaycommerce-other-plugins'] = array( 121 'parent' => 'yaycommerce', 122 'name' => __( 'Other plugins', 'yaycommerce' ), 123 'capability' => 'manage_options', 124 'render_callback' => array( '\YayExtra\YayCommerceMenu\OtherPluginsMenu', 'render' ), 125 'load_data_callback' => array( '\YayExtra\YayCommerceMenu\OtherPluginsMenu', 'load_data' ), 98 ), 99 'yaycommerce-other-plugins' => array( 100 'parent' => 'yaycommerce', 101 'name' => __( 'Other plugins', 'yaycommerce' ), 102 'capability' => 'manage_options', 103 'render_callback' => array( '\YayExtra\YayCommerceMenu\OtherPluginsMenu', 'render' ), 104 'load_data_callback' => array( '\YayExtra\YayCommerceMenu\OtherPluginsMenu', 'load_data' ), 105 ), 126 106 ); 127 128 return $submenus;129 107 } 130 108 -
yayextra/trunk/includes/YayCommerceMenu/views/other-plugins-content.php
r2913533 r3481811 1 1 <?php 2 defined( 'ABSPATH' ) || exit; 2 3 3 4 $pluginsAllowedTags = array( … … 45 46 $pluginProVer = $this->check_pro_version_exists( $recommendedPlugin ); 46 47 if ( false === $pluginProVer ) { 47 if ( 'yaypricing' === $recommendedPlugin['slug'] ) { 48 $installStatus = array( 49 'status' => 'install', 50 'url' => $recommendedPlugin['download_link'], 51 'version' => '', 52 'file' => $pluginProVer, 53 ); 54 } else { 55 $installStatus = \install_plugin_install_status( $recommendedPlugin ); 56 } 48 $installStatus = \install_plugin_install_status( $recommendedPlugin ); 57 49 } else { 58 50 $installStatus = array( … … 68 60 if ( $installStatus['url'] ) { 69 61 if ( $compatible_php && $compatible_wp ) { 70 if ( 'yaypricing' === $recommendedPlugin['slug'] ) { 71 $actionLinks[] = sprintf( 72 '<a href="%s" target="_bank"><button class="button button-primary" data-install-url="%s" aria-label="%s">%s</button></a>', 73 esc_attr( $downloadLink ), 74 esc_attr( $downloadLink ), 75 /* translators: %s: Plugin name and version. */ 76 esc_attr( sprintf( _x( 'Install %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), 77 __( 'Install Now', 'ninjateam-whatsapp' ) 78 ); 79 } else { 80 $actionLinks[] = sprintf( 81 '<button class="install-now button button-primary" data-install-url="%s" aria-label="%s">%s</button>', 82 esc_attr( $downloadLink ), 83 /* translators: %s: Plugin name and version. */ 84 esc_attr( sprintf( _x( 'Install %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), 85 __( 'Install Now', 'ninjateam-whatsapp' ) 86 ); 87 } 62 $actionLinks[] = sprintf( 63 '<button class="install-now button button-primary" data-install-url="%s" aria-label="%s">%s</button>', 64 esc_attr( $downloadLink ), 65 /* translators: %s: Plugin name and version. */ 66 esc_attr( sprintf( _x( 'Install %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), 67 __( 'Install Now', 'ninjateam-whatsapp' ) 68 ); 88 69 } else { 89 70 $actionLinks[] = sprintf( … … 99 80 if ( $installStatus['url'] ) { 100 81 if ( $compatible_php && $compatible_wp ) { 101 if ( 'yaypricing' === $recommendedPlugin['slug'] ) { 102 $actionLinks[] = sprintf( 103 '<button class="button aria-button-if-js" data-plugin="%s" data-slug="%s" data-update-url="%s" aria-label="%s" data-name="%s">%s</button>', 104 esc_attr( $installStatus['file'] ), 105 esc_attr( $recommendedPlugin['slug'] ), 106 esc_url( $installStatus['url'] ), 107 /* translators: %s: Plugin name and version. */ 108 esc_attr( sprintf( _x( 'Update %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), 109 esc_attr( $name ), 110 __( 'Update Now', 'ninjateam-whatsapp' ) 111 ); 112 } else { 113 $actionLinks[] = sprintf( 114 '<button class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" data-update-url="%s" aria-label="%s" data-name="%s">%s</button>', 115 esc_attr( $installStatus['file'] ), 116 esc_attr( $recommendedPlugin['slug'] ), 117 esc_url( $installStatus['url'] ), 118 /* translators: %s: Plugin name and version. */ 119 esc_attr( sprintf( _x( 'Update %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), 120 esc_attr( $name ), 121 __( 'Update Now', 'ninjateam-whatsapp' ) 122 ); 123 } 82 $actionLinks[] = sprintf( 83 '<button class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" data-update-url="%s" aria-label="%s" data-name="%s">%s</button>', 84 esc_attr( $installStatus['file'] ), 85 esc_attr( $recommendedPlugin['slug'] ), 86 esc_url( $installStatus['url'] ), 87 /* translators: %s: Plugin name and version. */ 88 esc_attr( sprintf( _x( 'Update %s now', 'plugin', 'ninjateam-whatsapp' ), $name ) ), 89 esc_attr( $name ), 90 __( 'Update Now', 'ninjateam-whatsapp' ) 91 ); 124 92 } else { 125 93 $actionLinks[] = sprintf( -
yayextra/trunk/readme.txt
r3474610 r3481811 6 6 Requires PHP: 5.3 7 7 Tested up to: 6.9 8 Stable tag: 1.5.6.18 Stable tag: 2.0.0 9 9 License: GPL-2.0+ 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 25 25 - Improve product pages and increase order value 26 26 27 👉 Check it out: [**YayExtra Pro**](https://yaycommerce.com/yayextra-woocommerce-extra-product-options/) 👀27 👉 Check it out: [**YayExtra - Woo Product Options Pro**](https://yaycommerce.com/yayextra-woocommerce-extra-product-options/) 👀 28 28 29 29 **Works great for selling:** … … 38 38 Build better product pages. Offer more choices. Sell more with YayExtra. 39 39 40 📌 [Quick Demo](https://demo.yaycommerce.com/yayextra/product/t-shirt/) | [Admin Test Drive](https://demo.yaycommerce.com/try-yayextra) 41 40 42 [youtube https://youtu.be/qytEac2_Yr0] 41 43 42 [Free vs Pro](https://docs.yaycommerce.com/yayextra/why-upgrade) | [Quick Demo](https://demo.yaycommerce.com/yayextra/product/t-shirt/)44 Why Upgrade? Check it here: [Free vs Pro](https://docs.yaycommerce.com/yayextra/why-upgrade) 43 45 44 46 ###⚡️ FEATURES … … 125 127 126 128 == Changelog == 129 130 = Mar 13, 2026 - Version 2.0.0 = 131 - Updated: Admin UI/UX 132 - Added: Swatch and Button style settings in Customize [Pro version only] 133 - Added: Typography settings for Subtotal price in Customize 134 - Added: “All products” option for Product selection 135 - Added: Limit selections for Button (Multi) & Checkbox types [Pro version only] 136 - Added: Mime type selection for File Upload [Pro version only] 137 - Added: Description field for types without Option values [Pro version only] 138 - Added: hooks for total_price_text and subtotal_text 139 - Added: display link and stock status for Linked Product [Pro version only] 140 - Improved: WC tested up to 10.6.1 127 141 128 142 = Oct 24, 2025 - Version 1.5.6.1 = -
yayextra/trunk/yayextra.php
r3383835 r3481811 4 4 * Plugin URI: https://yaycommerce.com/yayextra-woocommerce-extra-product-options 5 5 * Description: Offer extra options like personal engraving, print-on-demand items, gifts, custom canvas prints, and personalized products. 6 * Version: 1.5.6.16 * Version: 2.0.0 7 7 * Author: YayCommerce 8 8 * Author URI: https://yaycommerce.com 9 9 * Text Domain: yayextra 10 10 * WC requires at least: 3.0.0 11 * WC tested up to: 10. 3.011 * WC tested up to: 10.6.1 12 12 * Domain Path: /i18n/languages/ 13 13 */ … … 16 16 17 17 use YayExtra\Init\Settings; 18 // use YayExtra\Integrations; 19 use YayExtra\Register\RegisterFacade; 18 20 19 21 defined( 'ABSPATH' ) || exit; … … 48 50 49 51 if ( ! defined( 'YAYE_VERSION' ) ) { 50 define( 'YAYE_VERSION', ' 1.5.6.1' );52 define( 'YAYE_VERSION', '2.0.0' ); 51 53 } 52 54 … … 54 56 define( 'YAYE_SITE_URL', site_url() ); 55 57 } 58 56 59 57 60 require __DIR__ . '/autoloader.php'; … … 67 70 I18n::getInstance(); 68 71 Settings::get_instance(); 72 // Integrations::get_instance(); 73 // Register Facade 74 RegisterFacade::get_instance(); 75 69 76 add_action( 'admin_notices', 'YayExtra\\required_woocommerce_notice' ); 70 77 }
Note: See TracChangeset
for help on using the changeset viewer.