Plugin Directory

Changeset 3481811


Ignore:
Timestamp:
03/13/2026 09:42:18 AM (2 weeks ago)
Author:
yaycommerce
Message:

Version 2.0.0

Location:
yayextra/trunk
Files:
20 added
2 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • yayextra/trunk/assets/css/yayextra.css

    r3317357 r3481811  
    9696  color: #fff;
    9797  text-align: center;
    98   padding: 8px 21px;
    99   border-radius: 3px;
     98  padding: 6px 10px;
     99  border-radius: 4px;
    100100  z-index: 10;
    101101  opacity: 0;
     
    103103  max-width: 250px;
    104104  box-sizing: border-box;
    105   font-size: 15px;
    106   line-height: 20px;
     105  font-size: 14px;
     106  line-height: 1.4;
    107107}
    108108
     
    119119  transform: translateX(-50%);
    120120  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;
    121128}
    122129
  • yayextra/trunk/assets/js/yayextra.js

    r3383835 r3481811  
    11(function ($) {
    2   'use strict';
     2  "use strict";
    33  const optionSetList = YAYE_CLIENT_DATA.OPTION_SET_LIST;
    44  const yayeSettings = YAYE_CLIENT_DATA.settings;
    55  $(document).ready(function ($) {
    6 
    76    // 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        }
    1113      }
    12         } );
     14    );
    1315
    1416    $.each(optionSetList, function (_, optionSet) {
    15       if( 1 === parseInt(optionSet.status) ) {
     17      if (1 === parseInt(optionSet.status)) {
    1618        const optionSetId = optionSet.id;
    1719        let referenceObject = {};
    1820        $.each(optionSet.options, function (_, option) {
    1921          $.each(option.logics, function (_, logic) {
    20             if(logic.option && logic.option.id) {
     22            if (logic.option && logic.option.id) {
    2123              if (logic.option.id in referenceObject) {
    2224                referenceObject[logic.option.id].push(option);
     
    3234            return;
    3335          }
    34  
     36
    3537          if (checkLogic(optionSetId, option)) {
    3638            showOption(option);
     
    3941            hideReferenceOption(optionSetId, option, referenceObject);
    4042          }
    41  
     43
    4244          $.each(option.logics, function (_, logic) {
    4345            createEvent(optionSetId, option, logic, referenceObject);
     
    4850
    4951    // Show/hide adition description of Select option field.
    50     const selectOptionFields = $('.yayextra-option-field-wrap select');
     52    const selectOptionFields = $(".yayextra-option-field-wrap select");
    5153    if (selectOptionFields.length > 0) {
    5254      $.each(selectOptionFields, function (idx, el) {
    5355        showHideAdditionDescSelectOpt(el);
    5456
    55         $(el).on('change', function () {
     57        $(el).on("change", function () {
    5658          showHideAdditionDescSelectOpt(this);
    5759          getTotalCost();
     
    6163
    6264    // Catch option swatched Event
    63     const swatchOptionFields = $('.yayextra-option-field-swatches-label');
     65    const swatchOptionFields = $(".yayextra-option-field-swatches-label");
    6466    if (swatchOptionFields.length > 0) {
    6567      $.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");
    7173
    7274        let isMultiSelectable = false;
    73         const optionFieldWraps = $(el).parents('.yayextra-option-field-wrap');
     75        const optionFieldWraps = $(el).parents(".yayextra-option-field-wrap");
    7476        if (optionFieldWraps.length > 0) {
    7577          const optFieldWrap = optionFieldWraps[0];
    7678          isMultiSelectable =
    77             $(optFieldWrap).attr('data-multi-selectable') == 1 ? true : false;
     79            $(optFieldWrap).attr("data-multi-selectable") == 1 ? true : false;
    7880        }
    7981
    8082        // Check input is checked init ?
    81         if ($(inputEl).is(':checked')) {
    82           $(el).addClass('checked');
     83        if ($(inputEl).is(":checked")) {
     84          $(el).addClass("checked");
    8385
    8486          showHideAdditionDescSwatchesButtonOpt(inputEl);
     
    9193            $.each(optionValues, function (idx, optVal) {
    9294              if (
    93                 'image' === optVal.swatchesType &&
     95                "image" === optVal.swatchesType &&
    9496                optionValChecked === optVal.value &&
    9597                optId === optionData.id
     
    103105
    104106        // 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);
    109111
    110112            showHideAdditionDescSwatchesButtonOpt(inputEl);
     
    117119              $.each(optionValues, function (idx, optVal) {
    118120                if (
    119                   'image' === optVal.swatchesType &&
     121                  "image" === optVal.swatchesType &&
    120122                  optionValChecked === optVal.value &&
    121123                  optId === optionData.id
     
    129131            }
    130132          } else {
    131             $(el).removeClass('checked');
    132             $(inputEl).prop('checked', false);
     133            $(el).removeClass("checked");
     134            $(inputEl).prop("checked", false);
     135            showHideAdditionDescSwatchesButtonOpt(inputEl);
    133136          }
    134137
     
    136139          if (!isMultiSelectable) {
    137140            const optSwatchesSiblings = $(el)
    138               .closest('.yayextra-opt-swatches')
     141              .closest(".yayextra-opt-swatches")
    139142              .siblings();
    140143            if (optSwatchesSiblings.length > 0) {
    141144              $.each(optSwatchesSiblings, function (idx, el1) {
    142145                $(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);
    153150                }
    154151              });
     
    156153          }
    157154
    158           inputEl.trigger('change');
     155          inputEl.trigger("change");
    159156        });
    160157      });
     
    162159
    163160    // Catch option button type Event
    164     const buttonOptions = $('.yayextra-option-button-label');
     161    const buttonOptions = $(".yayextra-option-button-label");
    165162    if (buttonOptions.length > 0) {
    166163      $.each(buttonOptions, function (idx, el) {
    167164        // const labelEl = $(el).siblings('.yayextra-option-button-label');
    168         const inputEl = $(el).siblings('input');
     165        const inputEl = $(el).siblings("input");
    169166
    170167        let isMultiSelectable = false;
    171         const optionFieldWraps = $(el).parents('.yayextra-option-field-wrap');
     168        const optionFieldWraps = $(el).parents(".yayextra-option-field-wrap");
    172169        if (optionFieldWraps.length > 0) {
    173170          const optFieldWrap = optionFieldWraps[0];
    174171          isMultiSelectable =
    175             $(optFieldWrap).attr('data-multi-selectable') == 1 ? true : false;
     172            $(optFieldWrap).attr("data-multi-selectable") == 1 ? true : false;
    176173        }
    177174
    178175        // Check input is checked init ?
    179         if ($(inputEl).is(':checked')) {
    180           $(el).addClass('checked');
     176        if ($(inputEl).is(":checked")) {
     177          $(el).addClass("checked");
    181178
    182179          showHideAdditionDescSwatchesButtonOpt(inputEl);
     
    184181
    185182        // 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);
    190187
    191188            showHideAdditionDescSwatchesButtonOpt(inputEl);
    192189          } else {
    193             $(el).removeClass('checked');
    194             $(inputEl).prop('checked', false);
     190            $(el).removeClass("checked");
     191            $(inputEl).prop("checked", false);
     192            showHideAdditionDescSwatchesButtonOpt(inputEl);
    195193          }
    196194
     
    198196          if (!isMultiSelectable) {
    199197            const optButtonSiblings = $(el)
    200               .closest('.yayextra-opt-button')
     198              .closest(".yayextra-opt-button")
    201199              .siblings();
    202200            if (optButtonSiblings.length > 0) {
    203201              $.each(optButtonSiblings, function (idx, el1) {
    204202                $(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);
    215207                }
    216208              });
     
    218210          }
    219211
    220           inputEl.trigger('change');
     212          inputEl.trigger("change");
    221213        });
    222214      });
    223215    }
    224216
    225     const datePickerFields = $('.yayextra-date-picker');
     217    const datePickerFields = $(".yayextra-date-picker");
    226218    if (datePickerFields.length > 0) {
    227219      $.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");
    234226    if (timePickerInputFields.length > 0) {
    235227      $.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;
    239231          $(timePickerDivClass).show();
    240232          $(timePickerDivClass).datetimepicker({
    241             baseCls: 'yayextra-datetimepicker',
     233            baseCls: "yayextra-datetimepicker",
    242234            date: new Date(),
    243             viewMode: 'HM',
     235            viewMode: "HM",
    244236            onDateChange: function () {
    245237              const datetime = new Date(this.getValue()).toLocaleTimeString(
    246238                [],
    247239                {
    248                   hour: '2-digit',
    249                   minute: '2-digit',
     240                  hour: "2-digit",
     241                  minute: "2-digit",
    250242                }
    251243              );
    252               $('#' + timePickerFieldInputId).val(datetime);
    253               $('#' + timePickerFieldInputId).trigger('change');
     244              $("#" + timePickerFieldInputId).val(datetime);
     245              $("#" + timePickerFieldInputId).trigger("change");
    254246            },
    255247            onOk: function () {
     
    259251
    260252          // 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"
    263255          );
    264256          if (timePickerIconI.length > 0) {
    265257            $.each(timePickerIconI, function (idx, el) {
    266               $(el)
    267                 .parent('td')
    268                 .hide();
     258              $(el).parent("td").hide();
    269259            });
    270260          }
     
    274264
    275265    $(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();
    278268      }
    279269    });
     
    406396
    407397    // 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    );
    409401    if (optionTextFields.length > 0) {
    410402      $.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");
    413405          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) {
    417409              validateUrl($(this).val(), elMessage);
    418             } else if ('email' === textFormat) {
     410            } else if ("email" === textFormat) {
    419411              validateEmail($(this).val(), elMessage);
    420412            }
     
    432424    if (optionCheckboxRadioFields.length > 0) {
    433425      $.each(optionCheckboxRadioFields, function (_, el) {
    434         $(el).on('click', function () {
     426        $(el).on("click", function () {
    435427          getTotalCost();
    436428        });
     
    440432    // Event swatches change
    441433    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"
    443435    );
    444436    if (optionSwatchesButtonFields.length > 0) {
    445437      $.each(optionSwatchesButtonFields, function (_, el) {
    446         $(el).on('change', function () {
     438        $(el).on("change", function () {
    447439          getTotalCost();
    448440        });
     
    451443
    452444    // Event Textarea click
    453     const optionTextareaFields = $('.yayextra-option-field-wrap textarea');
     445    const optionTextareaFields = $(".yayextra-option-field-wrap textarea");
    454446    if (optionTextareaFields.length > 0) {
    455447      $.each(optionTextareaFields, function (_, el) {
    456         $(el).on('keyup', function () {
     448        $(el).on("keyup", function () {
    457449          getTotalCost();
    458450        });
     
    461453
    462454    // 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    );
    464458    if (optionNumberFields.length > 0) {
    465459      $.each(optionNumberFields, function (_, el) {
    466         $(el).on('input change', function () {
     460        $(el).on("input change", function () {
    467461          getTotalCost();
    468462        });
     
    472466    // Event input yayextra-date-picker/yayextra-time-picker-input change
    473467    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"
    475469    );
    476470    if (optionDateTimeFields.length > 0) {
    477471      $.each(optionDateTimeFields, function (_, el) {
    478         $(el).on('change', function () {
     472        $(el).on("change", function () {
    479473          getTotalCost();
    480474        });
     
    483477
    484478    // Event product quantity input
    485     $('.quantity input.qty').on('change', function () {
     479    $(".quantity input.qty").on("change", function () {
    486480      getTotalCost();
    487481    });
     
    490484    getTotalCost();
    491485
    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");
    495491      let variationProductsMeta = getVariationProductsMeta();
    496492      // 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 type
    512               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);
    517513            } else {
    518               changeAdditionCostByVariationProduct(0)
    519               $('.yayextra-total-price .total-price').attr('data-total-price', 0);
     514              changeAdditionCostByVariationProduct(0);
    520515            }
    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();
    524526        });
    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;
    536546          }
    537547        }
    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();
    549563      // }
    550564    }
     
    552566    // Init set Visibility option id into hidden field
    553567    getVisibilityOption();
    554 
    555568  });
    556569
     
    559572      const optionWrapper = $("[data-option-field-id='" + option.id + "']");
    560573
    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");
    566579      }
    567  
     580
    568581      if (optionWrapper.length) {
    569582        optionWrapper.show();
    570583        for (const fieldDataObj of fieldDataObjs) {
    571           $(fieldDataObj).prop('disabled', false);
     584          $(fieldDataObj).prop("disabled", false);
    572585        }
    573586      }
    574  
     587
    575588      getTotalCost();
    576589      getVisibilityOption();
     
    587600
    588601  function hideOption(option) {
    589     if( option && option.id ) {
     602    if (option && option.id) {
    590603      const optionWrapper = $("[data-option-field-id='" + option.id + "']");
    591604
    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");
    597610      }
    598  
     611
    599612      if (optionWrapper.length) {
    600613        optionWrapper.hide();
    601614        for (const fieldDataObj of fieldDataObjs) {
    602           $(fieldDataObj).prop('disabled', true);
     615          $(fieldDataObj).prop("disabled", true);
    603616        }
    604617      }
    605618      resetElement(option);
    606  
     619
    607620      getTotalCost();
    608621      getVisibilityOption();
     
    619632  function resetElement(option) {
    620633    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");
    622635    if (
    623       'text' === currentFieldType ||
    624       'number' === currentFieldType ||
    625       'date_picker' === currentFieldType ||
    626       'time_picker' === currentFieldType
     636      "text" === currentFieldType ||
     637      "number" === currentFieldType ||
     638      "date_picker" === currentFieldType ||
     639      "time_picker" === currentFieldType
    627640    ) {
    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");
    635657      $.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        ) {
    637662          element.checked = option.optionValues[index].isDefault;
    638663        }
    639664      });
    640     } else if ('dropdown' === currentFieldType) {
    641       const element = currentField.find('select');
     665    } else if ("dropdown" === currentFieldType) {
     666      const element = currentField.find("select");
    642667      const findingDefault = option.optionValues.find(
    643668        (option) => option.isDefault
     
    648673  function checkTextLogic(optionSetId, logic) {
    649674    const optionId =
    650       typeof logic.option !== 'undefined'
     675      typeof logic.option !== "undefined"
    651676        ? logic.option.value
    652677        : logic.optionId.value;
    653678
    654679    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    ) {
    656684      logicVal = "";
    657685    }
    658686
    659687    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;
    664692
    665693    const fieldLogicVal = fieldLogic.val();
    666694
    667     if ('match' === logic.comparation.value) {
     695    if ("match" === logic.comparation.value) {
    668696      if (fieldLogicVal === logicVal) return true;
    669697    }
    670     if ('not_match' === logic.comparation.value) {
     698    if ("not_match" === logic.comparation.value) {
    671699      if (fieldLogicVal !== logicVal) return true;
    672700    }
    673     if ('contains' === logic.comparation.value && fieldLogicVal) {
     701    if ("contains" === logic.comparation.value && fieldLogicVal) {
    674702      if (fieldLogicVal.includes(logicVal)) return true;
    675703    }
     
    678706  function checkTextareaLogic(optionSetId, logic) {
    679707    const optionId =
    680       typeof logic.option !== 'undefined'
     708      typeof logic.option !== "undefined"
    681709        ? logic.option.value
    682710        : logic.optionId.value;
    683711
    684712    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    ) {
    686717      logicVal = "";
    687718    }
    688719
    689720    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;
    694729
    695730    const fieldLogicVal = fieldLogic.val();
    696731
    697     if ('match' === logic.comparation.value) {
     732    if ("match" === logic.comparation.value) {
    698733      if (fieldLogicVal === logicVal) return true;
    699734    }
    700     if ('not_match' === logic.comparation.value) {
     735    if ("not_match" === logic.comparation.value) {
    701736      if (fieldLogicVal !== logicVal) return true;
    702737    }
    703     if ('contains' === logic.comparation.value && fieldLogicVal) {
     738    if ("contains" === logic.comparation.value && fieldLogicVal) {
    704739      if (fieldLogicVal.includes(logicVal)) return true;
    705740    }
     
    708743  function checkNumberLogic(optionSetId, logic) {
    709744    const optionId =
    710       typeof logic.option !== 'undefined'
     745      typeof logic.option !== "undefined"
    711746        ? logic.option.value
    712747        : logic.optionId.value;
    713748
    714749    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;
    719754
    720755    const fieldLogicVal = parseFloat(fieldLogic.val());
    721756
    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) {
    725760      if (fieldLogicVal == parseFloat(logic.value)) return true;
    726     } else if ('less_than' === logic.comparation.value) {
     761    } else if ("less_than" === logic.comparation.value) {
    727762      if (fieldLogicVal < parseFloat(logic.value)) return true;
    728     } else if ('greater_than' === logic.comparation.value) {
     763    } else if ("greater_than" === logic.comparation.value) {
    729764      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) {
    731766      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) {
    733768      if (fieldLogicVal >= parseFloat(logic.value)) return true;
    734769    }
     
    737772  function checkCheckboxLogic(optionSetId, logic) {
    738773    const optionId =
    739       typeof logic.option !== 'undefined'
     774      typeof logic.option !== "undefined"
    740775        ? logic.option.value
    741776        : logic.optionId.value;
     
    743778    const checkboxes = $(
    744779      "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;
    751786
    752787    let values = [];
    753788    if (Array.isArray(logic.value)) {
    754789      values = logic.value.map((v) => v.value);
    755     } else if ( logic.value ) {
     790    } else if (logic.value) {
    756791      values.push(logic.value.value);
    757792    }
     
    759794      values.includes($(checkbox).val())
    760795    );
    761     if (logic.comparation.value === 'is_one_of') {
     796    if (logic.comparation.value === "is_one_of") {
    762797      if (findingResult === undefined) return false;
    763798      return true;
     
    769804  function checkRadioLogic(optionSetId, logic) {
    770805    const optionId =
    771       typeof logic.option !== 'undefined'
     806      typeof logic.option !== "undefined"
    772807        ? logic.option.value
    773808        : logic.optionId.value;
     
    775810    const radio = $(
    776811      "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") {
    786823      return logicValue === radio.val();
    787824    }
     
    790827  function checkButtonLogic(optionSetId, logic) {
    791828    const optionId =
    792       typeof logic.option !== 'undefined'
     829      typeof logic.option !== "undefined"
    793830        ? logic.option.value
    794831        : logic.optionId.value;
     
    796833    const buttons = $(
    797834      "input[name='option_field_data[" +
    798       optionSetId +
    799       '][' +
    800       optionId +
    801       "][]']:checked"
     835        optionSetId +
     836        "][" +
     837        optionId +
     838        "][]']:checked"
    802839    );
    803840
     
    807844    });
    808845
    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;
    812851    const findingResult = buttonVals.includes(logicValue);
    813852
    814     if (logic.comparation.value === 'is') {
     853    if (logic.comparation.value === "is") {
    815854      if (findingResult) return true;
    816855      return false;
     
    821860  function checkButtonMultiLogic(optionSetId, logic) {
    822861    const optionId =
    823       typeof logic.option !== 'undefined'
     862      typeof logic.option !== "undefined"
    824863        ? logic.option.value
    825864        : logic.optionId.value;
     
    827866    const buttones = $(
    828867      "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;
    835874
    836875    let values = [];
    837876    if (Array.isArray(logic.value)) {
    838877      values = logic.value.map((v) => v.value);
    839     } else if ( logic.value ) {
     878    } else if (logic.value) {
    840879      values.push(logic.value.value);
    841880    }
     
    843882      values.includes($(button).val())
    844883    );
    845     if (logic.comparation.value === 'is_one_of') {
     884    if (logic.comparation.value === "is_one_of") {
    846885      if (findingResult === undefined) return false;
    847886      return true;
     
    853892  function checkSelectLogic(optionSetId, logic) {
    854893    const optionId =
    855       typeof logic.option !== 'undefined'
     894      typeof logic.option !== "undefined"
    856895        ? logic.option.value
    857896        : logic.optionId.value;
    858897
    859898    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;
    864903
    865904    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) {
    868909      if (fieldLogicVal == String(logicValue)) return true;
    869     } else if ('is_not' === logic.comparation.value) {
     910    } else if ("is_not" === logic.comparation.value) {
    870911      if (fieldLogicVal != String(logicValue)) return true;
    871912    }
     
    874915  function checkSwatchesLogic(optionSetId, logic) {
    875916    const optionId =
    876       typeof logic.option !== 'undefined'
     917      typeof logic.option !== "undefined"
    877918        ? logic.option.value
    878919        : logic.optionId.value;
     
    880921    const swatches = $(
    881922      "input[name='option_field_data[" +
    882       optionSetId +
    883       '][' +
    884       optionId +
    885       "][]']:checked"
     923        optionSetId +
     924        "][" +
     925        optionId +
     926        "][]']:checked"
    886927    );
    887928
     
    891932    });
    892933
    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;
    896939    const findingResult = swatchesVals.includes(logicValue);
    897940
    898     if (logic.comparation.value === 'is') {
     941    if (logic.comparation.value === "is") {
    899942      if (findingResult) return true;
    900943      return false;
     
    905948  function checkSwatchesMultiLogic(optionSetId, logic) {
    906949    const optionId =
    907       typeof logic.option !== 'undefined'
     950      typeof logic.option !== "undefined"
    908951        ? logic.option.value
    909952        : logic.optionId.value;
     
    911954    const swatches = $(
    912955      "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;
    919962
    920963    let values = [];
    921964    if (Array.isArray(logic.value)) {
    922965      values = logic.value.map((v) => v.value);
    923     } else if ( logic.value ) {
     966    } else if (logic.value) {
    924967      values.push(logic.value.value);
    925968    }
     
    927970      values.includes($(swatch).val())
    928971    );
    929     if (logic.comparation.value === 'is_one_of') {
     972    if (logic.comparation.value === "is_one_of") {
    930973      if (findingResult === undefined) return false;
    931974      return true;
     
    937980  function checkDatePickerLogic(optionSetId, logic) {
    938981    const optionId =
    939       typeof logic.option !== 'undefined'
     982      typeof logic.option !== "undefined"
    940983        ? logic.option.value
    941984        : logic.optionId.value;
    942985
    943986    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;
    948991
    949992    const fieldLogicVal = fieldLogic.val();
     
    953996    const currentDate = new Date(fieldLogicVal).toLocaleDateString();
    954997
    955     if ('between' === logic.comparation.value) {
     998    if ("between" === logic.comparation.value) {
    956999      if (startDate <= currentDate && currentDate <= endDate) return true;
    9571000    }
    958     if ('not_between' === logic.comparation.value) {
     1001    if ("not_between" === logic.comparation.value) {
    9591002      if (startDate > currentDate || currentDate > endDate) return true;
    9601003    }
     
    9631006  function checkTimePickerLogic(optionSetId, logic) {
    9641007    const optionId =
    965       typeof logic.option !== 'undefined'
     1008      typeof logic.option !== "undefined"
    9661009        ? logic.option.value
    9671010        : logic.optionId.value;
    9681011
    9691012    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;
    9741017
    9751018    const startTime = convertTimeAMPM(
    9761019      new Date(logic.value.from_time).toLocaleTimeString([], {
    977         hour: '2-digit',
    978         minute: '2-digit',
     1020        hour: "2-digit",
     1021        minute: "2-digit",
    9791022      })
    9801023    );
    9811024    const endTime = convertTimeAMPM(
    9821025      new Date(logic.value.to_time).toLocaleTimeString([], {
    983         hour: '2-digit',
    984         minute: '2-digit',
     1026        hour: "2-digit",
     1027        minute: "2-digit",
    9851028      })
    9861029    );
     
    9891032    if (null === currentTime) return false;
    9901033
    991     if ('between' === logic.comparation.value) {
     1034    if ("between" === logic.comparation.value) {
    9921035      if (startTime <= currentTime && currentTime <= endTime) return true;
    9931036    }
    994     if ('not_between' === logic.comparation.value) {
     1037    if ("not_between" === logic.comparation.value) {
    9951038      if (startTime > currentTime || currentTime > endTime) return true;
    9961039    }
     
    9991042
    10001043  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")
    10041048      return checkTextLogic(optionSetId, logic);
    1005     if (logic.option.type.value === 'textarea')
     1049    if (logic.option.type.value === "textarea")
    10061050      return checkTextareaLogic(optionSetId, logic);
    1007     if (logic.option.type.value === 'number')
     1051    if (logic.option.type.value === "number")
    10081052      return checkNumberLogic(optionSetId, logic);
    1009     if (logic.option.type.value === 'checkbox')
     1053    if (logic.option.type.value === "checkbox")
    10101054      return checkCheckboxLogic(optionSetId, logic);
    1011     if (logic.option.type.value === 'radio')
     1055    if (logic.option.type.value === "radio")
    10121056      return checkRadioLogic(optionSetId, logic);
    1013     if (logic.option.type.value === 'button')
     1057    if (logic.option.type.value === "button")
    10141058      return checkButtonLogic(optionSetId, logic);
    1015     if (logic.option.type.value === 'button_multi')
     1059    if (logic.option.type.value === "button_multi")
    10161060      return checkButtonMultiLogic(optionSetId, logic);
    1017     if (logic.option.type.value === 'dropdown')
     1061    if (logic.option.type.value === "dropdown")
    10181062      return checkSelectLogic(optionSetId, logic);
    1019     if (logic.option.type.value === 'swatches')
     1063    if (logic.option.type.value === "swatches")
    10201064      return checkSwatchesLogic(optionSetId, logic);
    1021     if (logic.option.type.value === 'swatches_multi')
     1065    if (logic.option.type.value === "swatches_multi")
    10221066      return checkSwatchesMultiLogic(optionSetId, logic);
    1023     if (logic.option.type.value === 'date_picker')
     1067    if (logic.option.type.value === "date_picker")
    10241068      return checkDatePickerLogic(optionSetId, logic);
    1025     if (logic.option.type.value === 'time_picker')
     1069    if (logic.option.type.value === "time_picker")
    10261070      return checkTimePickerLogic(optionSetId, logic);
    10271071  }
     
    10291073    const { matchType, displayType } = option;
    10301074    let result = false;
    1031     if (matchType.value === 'any') {
     1075    if (matchType.value === "any") {
    10321076      const check = option.logics.find((logic) => {
    10331077        return getLogicResult(optionSetId, logic);
     
    10401084      if (check === undefined) result = true;
    10411085    }
    1042     if (displayType.value === 'display') return result;
     1086    if (displayType.value === "display") return result;
    10431087
    10441088    return !result;
     
    10471091    const checkboxes = $(
    10481092      "input[name='option_field_data[" +
    1049       optionSetId +
    1050       '][' +
    1051       logic.option.value +
    1052       "][]']"
     1093        optionSetId +
     1094        "][" +
     1095        logic.option.value +
     1096        "][]']"
    10531097    );
    10541098
    10551099    $.each(checkboxes, function (_, checkbox) {
    1056       $(checkbox).on('change', function () {
     1100      $(checkbox).on("change", function () {
    10571101        if (checkLogic(optionSetId, option)) {
    10581102          showOption(option);
     
    10681112    const radios = $(
    10691113      "input[name='option_field_data[" +
    1070       optionSetId +
    1071       '][' +
    1072       logic.option.value +
    1073       "]']"
     1114        optionSetId +
     1115        "][" +
     1116        logic.option.value +
     1117        "]']"
    10741118    );
    10751119    $.each(radios, function (_, radio) {
    1076       $(radio).on('change', function () {
     1120      $(radio).on("change", function () {
    10771121        if (checkLogic(optionSetId, option)) {
    10781122          showOption(option);
     
    10881132    const radios = $(
    10891133      "input[name='option_field_data[" +
    1090       optionSetId +
    1091       '][' +
    1092       logic.option.value +
    1093       "][]']"
     1134        optionSetId +
     1135        "][" +
     1136        logic.option.value +
     1137        "][]']"
    10941138    );
    10951139    $.each(radios, function (_, radio) {
    1096       $(radio).on('change', function () {
     1140      $(radio).on("change", function () {
    10971141        if (checkLogic(optionSetId, option)) {
    10981142          showOption(option);
     
    11081152    const texts = $(
    11091153      "input[name='option_field_data[" +
    1110       optionSetId +
    1111       '][' +
    1112       logic.option.value +
    1113       "]']"
     1154        optionSetId +
     1155        "][" +
     1156        logic.option.value +
     1157        "]']"
    11141158    );
    11151159
    11161160    $.each(texts, function (_, text) {
    1117       $(text).on('change', function () {
     1161      $(text).on("change", function () {
    11181162        if (checkLogic(optionSetId, option)) {
    11191163          showOption(option);
     
    11291173    const textareas = $(
    11301174      "textarea[name='option_field_data[" +
    1131       optionSetId +
    1132       '][' +
    1133       logic.option.value +
    1134       "]']"
     1175        optionSetId +
     1176        "][" +
     1177        logic.option.value +
     1178        "]']"
    11351179    );
    11361180
    11371181    $.each(textareas, function (_, textarea) {
    1138       $(textarea).on('change', function () {
     1182      $(textarea).on("change", function () {
    11391183        if (checkLogic(optionSetId, option)) {
    11401184          showOption(option);
     
    11501194    const numbers = $(
    11511195      "input[name='option_field_data[" +
    1152       optionSetId +
    1153       '][' +
    1154       logic.option.value +
    1155       "]']"
     1196        optionSetId +
     1197        "][" +
     1198        logic.option.value +
     1199        "]']"
    11561200    );
    11571201
    11581202    $.each(numbers, function (_, number) {
    1159       $(number).on('change', function () {
     1203      $(number).on("change", function () {
    11601204        if (checkLogic(optionSetId, option)) {
    11611205          showOption(option);
     
    11711215    const selects = $(
    11721216      "select[name='option_field_data[" +
    1173       optionSetId +
    1174       '][' +
    1175       logic.option.value +
    1176       "]']"
     1217        optionSetId +
     1218        "][" +
     1219        logic.option.value +
     1220        "]']"
    11771221    );
    11781222
    11791223    $.each(selects, function (_, select) {
    1180       $(select).on('change', function () {
     1224      $(select).on("change", function () {
    11811225        if (checkLogic(optionSetId, option)) {
    11821226          showOption(option);
     
    11921236    const swatches = $(
    11931237      "input[name='option_field_data[" +
    1194       optionSetId +
    1195       '][' +
    1196       logic.option.value +
    1197       "][]']"
     1238        optionSetId +
     1239        "][" +
     1240        logic.option.value +
     1241        "][]']"
    11981242    );
    11991243    $.each(swatches, function (_, swatch) {
    1200       $(swatch).on('change', function () {
     1244      $(swatch).on("change", function () {
    12011245        if (checkLogic(optionSetId, option)) {
    12021246          showOption(option);
     
    12121256    const datepickers = $(
    12131257      "input[name='option_field_data[" +
    1214       optionSetId +
    1215       '][' +
    1216       logic.option.value +
    1217       "]']"
     1258        optionSetId +
     1259        "][" +
     1260        logic.option.value +
     1261        "]']"
    12181262    );
    12191263
    12201264    $.each(datepickers, function (_, text) {
    1221       $(text).on('change', function () {
     1265      $(text).on("change", function () {
    12221266        if (checkLogic(optionSetId, option)) {
    12231267          showOption(option);
     
    12331277    const timepickers = $(
    12341278      "input[name='option_field_data[" +
    1235       optionSetId +
    1236       '][' +
    1237       logic.option.value +
    1238       "]']"
     1279        optionSetId +
     1280        "][" +
     1281        logic.option.value +
     1282        "]']"
    12391283    );
    12401284
    12411285    $.each(timepickers, function (_, text) {
    1242       $(text).on('change', function () {
     1286      $(text).on("change", function () {
    12431287        if (checkLogic(optionSetId, option)) {
    12441288          showOption(option);
     
    12531297  function createEvent(optionSetId, option, logic, referenceObject) {
    12541298    const optionType = logic?.option?.type?.value;
    1255     if (optionType === 'checkbox')
     1299    if (optionType === "checkbox")
    12561300      createCheckboxEvent(optionSetId, option, logic, referenceObject);
    1257     if (optionType === 'radio')
     1301    if (optionType === "radio")
    12581302      createRadioEvent(optionSetId, option, logic, referenceObject);
    1259     if (optionType === 'button' || optionType === 'button_multi')
     1303    if (optionType === "button" || optionType === "button_multi")
    12601304      createButtonEvent(optionSetId, option, logic, referenceObject);
    1261     if (optionType === 'text')
     1305    if (optionType === "text")
    12621306      createTextEvent(optionSetId, option, logic, referenceObject);
    1263     if (optionType === 'textarea')
     1307    if (optionType === "textarea")
    12641308      createTextareaEvent(optionSetId, option, logic, referenceObject);
    1265     if (optionType === 'number')
     1309    if (optionType === "number")
    12661310      createNumberEvent(optionSetId, option, logic, referenceObject);
    1267     if (optionType === 'dropdown')
     1311    if (optionType === "dropdown")
    12681312      createSelectEvent(optionSetId, option, logic, referenceObject);
    1269     if (optionType === 'swatches' || optionType === 'swatches_multi')
     1313    if (optionType === "swatches" || optionType === "swatches_multi")
    12701314      createSwatchesEvent(optionSetId, option, logic, referenceObject);
    1271     if (optionType === 'date_picker')
     1315    if (optionType === "date_picker")
    12721316      createDatePickerEvent(optionSetId, option, logic, referenceObject);
    1273     if (optionType === 'time_picker')
     1317    if (optionType === "time_picker")
    12741318      createTimePickerEvent(optionSetId, option, logic, referenceObject);
    12751319  }
    12761320  function showHideAdditionDescSelectOpt(el) {
    1277     const optionId = $(el).attr('id');
     1321    const optionId = $(el).attr("id");
    12781322    const value = el.value.replaceAll('"', '\\"');
    12791323    const optionDes = $("[data-option-field-id='" + optionId + "']").find(
    12801324      '.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        '"]'
    12851329    );
    12861330
    12871331    if (optionDes.length > 0) {
    12881332      optionDes.show();
    1289       optionDes.siblings('p.yayextra-addition-des-dropdown').hide();
     1333      optionDes.siblings("p.yayextra-addition-des-dropdown").hide();
    12901334    } else {
    12911335      $("[data-option-field-id='" + optionId + "']")
    1292         .find('.yayextra-addition-des-dropdown')
     1336        .find(".yayextra-addition-des-dropdown")
    12931337        .hide();
    12941338    }
     
    12961340
    12971341  function showHideAdditionDescSwatchesButtonOpt(el) {
    1298     const optionId = $(el).attr('data-opt-id');
     1342    const optionId = $(el).attr("data-opt-id");
    12991343    const value = $(el).val().replaceAll('"', '\\"');
    13001344
    13011345    const optionDes = $("[data-option-field-id='" + optionId + "']").find(
    13021346      '.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        '"]'
    13071351    );
    13081352
    13091353    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();
    13121360    } else {
    13131361      $("[data-option-field-id='" + optionId + "']")
    1314         .find('.yayextra-addition-des-swatches-button')
     1362        .find(".yayextra-addition-des-swatches-button")
    13151363        .hide();
    13161364    }
     
    13221370      var minutes = Number(time.match(/:(\d+)/)[1]);
    13231371      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;
    13261374      var sHours = hours.toString();
    13271375      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;
    13311379    }
    13321380    return null;
     
    13371385      '<div class="yayextra-notification"><div class="yayextra-notification-content">' +
    13381386      messages +
    1339       '</div></div>';
    1340 
    1341     $('.' + containerClass).after(notifyHtml);
     1387      "</div></div>";
     1388
     1389    $("." + containerClass).after(notifyHtml);
    13421390    setTimeout(function () {
    1343       $('.yayextra-notification').addClass('NslideDown');
    1344       $('.yayextra-notification').remove();
     1391      $(".yayextra-notification").addClass("NslideDown");
     1392      $(".yayextra-notification").remove();
    13451393    }, 1500);
    13461394  }
     
    13521400    spinnerHtml +=
    13531401      '<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>";
    13561404    if (isShow) {
    1357       if (typeof containerClass === 'string') {
    1358         $('.' + containerClass).append(spinnerHtml);
     1405      if (typeof containerClass === "string") {
     1406        $("." + containerClass).append(spinnerHtml);
    13591407      } else {
    13601408        $(containerClass).append(spinnerHtml);
    13611409      }
    13621410    } else {
    1363       $('.yayextra-spinner').remove();
     1411      $(".yayextra-spinner").remove();
    13641412    }
    13651413  }
     
    13691417    if (optionSetList.length > 0) {
    13701418      $.each(optionSetList, function (_, optionSet) {
    1371         if( optSetId == optionSet.id ) {
     1419        if (optSetId == optionSet.id) {
    13721420          const optionList = optionSet.options;
    13731421          if (optionList.length > 0) {
     
    13781426              }
    13791427            });
    1380             if ( result ) return false;
     1428            if (result) return false;
    13811429          }
    1382         } 
     1430        }
    13831431      });
    13841432    }
     
    13861434  }
    13871435
    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"
    13911444    );
    13921445
    13931446    if (productGalleryImgList.length > 0) {
    13941447      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);
    13991450
    14001451      let productGalleryImgEl = $(productGalleryImgFirst).find(
    1401         'img.wp-post-image'
     1452        "img.wp-post-image"
    14021453      );
    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);
    14071458
    14081459      if (true === setTimeOut) {
    14091460        setTimeout(function () {
    14101461          let productGalleryImgZoomEl = $(productGalleryImgFirst).find(
    1411             'img.zoomImg'
     1462            "img.zoomImg"
    14121463          );
    14131464          if (productGalleryImgZoomEl.length > 0) {
    1414             $(productGalleryImgZoomEl).attr('src', imageUrl);
     1465            $(productGalleryImgZoomEl).attr("src", imageUrl);
    14151466          }
    14161467        }, 1000);
    14171468      } else {
    14181469        let productGalleryImgZoomEl = $(productGalleryImgFirst).find(
    1419           'img.zoomImg'
     1470          "img.zoomImg"
    14201471        );
    14211472        if (productGalleryImgZoomEl.length > 0) {
    1422           $(productGalleryImgZoomEl).attr('src', imageUrl);
     1473          $(productGalleryImgZoomEl).attr("src", imageUrl);
    14231474        }
    14241475      }
    14251476    }
    14261477
    1427     let productGalleryThumbList = $('.woocommerce-product-gallery').find(
    1428       '.flex-control-thumbs li'
     1478    let productGalleryThumbList = $(".woocommerce-product-gallery").find(
     1479      ".flex-control-thumbs li"
    14291480    );
    14301481
    14311482    if (productGalleryThumbList.length > 0) {
    14321483      let productGalleryThumbFirst = productGalleryThumbList[0];
    1433       $(productGalleryThumbFirst)
    1434         .find('img')
    1435         .attr('src', imageUrl);
     1484      $(productGalleryThumbFirst).find("img").attr("src", imageUrl);
    14361485    }
    14371486  }
     
    14431492      )
    14441493    ) {
    1445       elMessage.html('').hide();
     1494      elMessage.html("").hide();
    14461495      return true;
    14471496    }
    1448     elMessage.html('You have entered an invalid email address!').show();
     1497    elMessage.html("You have entered an invalid email address!").show();
    14491498    return false;
    14501499  }
     
    14521501  function validateUrl(url, elMessage) {
    14531502    let pattern = new RegExp(
    1454       '^(https?:\\/\\/)?' + // protocol
    1455       '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
    1456       '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
    1457       '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
    1458       '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
    1459       '(\\#[-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"
    14611510    ); // fragment locator
    14621511    if (pattern.test(url)) {
    1463       elMessage.html('').hide();
     1512      elMessage.html("").hide();
    14641513      return true;
    14651514    }
    1466     elMessage.html('You have entered an invalid URL!').show();
     1515    elMessage.html("You have entered an invalid URL!").show();
    14671516    return false;
    14681517  }
    14691518
    14701519  function checkLogicAction(optionSetId, action) {
    1471     if( !action || !action.conditions || !action.matchType.value ) return false;
     1520    if (!action || !action.conditions || !action.matchType.value) return false;
    14721521
    14731522    let conditions = action.conditions;
     
    14781527    }
    14791528
    1480     if ('any' === matchType) {
     1529    if ("any" === matchType) {
    14811530      let result = false;
    14821531      $.each(conditions, function (_, condition) {
     
    15041553
    15051554  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
    15101566    const optionType = condition.type.value;
    15111567
    1512     if (optionType === 'text') {
     1568    if (optionType === "text") {
    15131569      return checkTextLogic(optionSetId, condition);
    15141570    }
    1515     if (optionType === 'textarea') {
     1571    if (optionType === "textarea") {
    15161572      return checkTextareaLogic(optionSetId, condition);
    15171573    }
    1518     if (optionType === 'number') {
     1574    if (optionType === "number") {
    15191575      return checkNumberLogic(optionSetId, condition);
    15201576    }
    1521     if (optionType === 'checkbox') {
     1577    if (optionType === "checkbox") {
    15221578      return checkCheckboxLogic(optionSetId, condition);
    15231579    }
    1524     if (optionType === 'radio') {
     1580    if (optionType === "radio") {
    15251581      return checkRadioLogic(optionSetId, condition);
    15261582    }
    1527     if (optionType === 'button') {
     1583    if (optionType === "button") {
    15281584      return checkButtonLogic(optionSetId, condition);
    15291585    }
    1530     if (optionType === 'button_multi') {
     1586    if (optionType === "button_multi") {
    15311587      return checkButtonMultiLogic(optionSetId, condition);
    15321588    }
    1533     if (optionType === 'dropdown') {
     1589    if (optionType === "dropdown") {
    15341590      return checkSelectLogic(optionSetId, condition);
    15351591    }
    1536     if (optionType === 'swatches') {
     1592    if (optionType === "swatches") {
    15371593      return checkSwatchesLogic(optionSetId, condition);
    15381594    }
    1539     if (optionType === 'swatches_multi') {
     1595    if (optionType === "swatches_multi") {
    15401596      return checkSwatchesMultiLogic(optionSetId, condition);
    15411597    }
    1542     if (optionType === 'date_picker') {
     1598    if (optionType === "date_picker") {
    15431599      return checkDatePickerLogic(optionSetId, condition);
    15441600    }
    1545     if (optionType === 'time_picker') {
     1601    if (optionType === "time_picker") {
    15461602      return checkTimePickerLogic(optionSetId, condition);
    15471603    }
    15481604  }
    15491605
    1550   function getFeeDiscountFromAction(optionSets) {
     1606  function getFeeDiscountFromAction(optionSets, isOriginal) {
    15511607    let feeDiscountArray = [];
    15521608    $.each(optionSets, function (_, optionSet) {
    1553       if( 1 == parseInt(optionSet.status) ){
     1609      if (1 == parseInt(optionSet.status)) {
    15541610        const optionSetId = optionSet.id;
    15551611        $.each(optionSet.actions, function (_, action) {
    15561612          if (checkLogicAction(optionSetId, action)) {
    15571613            const subActions = action.subActions;
    1558  
     1614
    15591615            if (subActions.length > 0) {
    15601616              $.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
    15621630                feeDiscountArray.push({
    15631631                  type: subAction.subActionType.value,
    15641632                  name: subAction.subActionName,
    1565                   value: actionVal
     1633                  value: actionVal,
    15661634                });
    15671635              });
     
    15761644    $.each(feeDiscountArray, function (_, feeDiscount) {
    15771645      let price =
    1578         'add_fee' === feeDiscount.type
     1646        "add_fee" === feeDiscount.type
    15791647          ? parseFloat(feeDiscount.value)
    15801648          : parseFloat(-feeDiscount.value);
     
    15871655
    15881656  function yayeNumberFormat(number, decimals, decPoint, thousandsSep) {
    1589     number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
     1657    number = (number + "").replace(/[^0-9+\-Ee.]/g, "");
    15901658    var n = !isFinite(+number) ? 0 : +number;
    15911659    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 = "";
    15951663
    15961664    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);
    15991667      } else {
    1600         var arr = ('' + n).split('e');
    1601         var sig = '';
     1668        var arr = ("" + n).split("e");
     1669        var sig = "";
    16021670        if (+arr[1] + prec > 0) {
    1603           sig = '+';
     1671          sig = "+";
    16041672        }
    16051673        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-" +
    16081676          prec
    16091677        )).toFixed(prec);
     
    16121680
    16131681    // @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(".");
    16151683    if (s[0].length > 3) {
    16161684      s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
    16171685    }
    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");
    16211689    }
    16221690
     
    16261694  function getTotalCost() {
    16271695    let additionCostSum = 0;
     1696    let additionCostSumOriginal = 0;
    16281697    let feeDiscounts = 0;
     1698    let feeDiscountsOriginal = 0;
    16291699
    16301700    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();
    16351705    }
    16361706
    16371707    if (
    1638       $('.yayextra-total-price').length > 0 ||
    1639       $('.yayextra-extra-subtotal-price').length > 0
     1708      $(".yayextra-total-price").length > 0 ||
     1709      $(".yayextra-extra-subtotal-price").length > 0
    16401710    ) {
    1641       const optionFields = $('body').find('.yayextra-option-field-wrap');
     1711      const optionFields = $("body").find(".yayextra-option-field-wrap");
    16421712      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",
    16501720      ];
    16511721
    16521722      if (optionFields.length > 0) {
    16531723        $.each(optionFields, function (idx, el) {
    1654           if ($(el).is(':visible')) {
     1724          if ($(el).is(":visible")) {
    16551725            // Sum value of value option field
    1656             const optType = $(el).attr('data-option-field-type');
     1726            const optType = $(el).attr("data-option-field-type");
    16571727            if (optHasVals.includes(optType)) {
    1658               if ('dropdown' === optType) {
    1659                 let valEls = $(el).find('select');
     1728              if ("dropdown" === optType) {
     1729                let valEls = $(el).find("select");
    16601730                if (valEls.length > 0) {
    16611731                  $.each(valEls, function (_, valEl) {
    1662                     let selectedOption = $(valEl).find('option:selected');
     1732                    let selectedOption = $(valEl).find("option:selected");
    16631733                    if (selectedOption.length > 0) {
    16641734                      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")
    16661739                      );
    16671740                    }
     
    16691742                }
    16701743              } else {
    1671                 let valEls = $(el).find('input');
     1744                let valEls = $(el).find("input");
    16721745                if (valEls.length > 0) {
    16731746                  $.each(valEls, function (_, valEl) {
    1674                     if ($(valEl).is(':checked')) {
     1747                    if ($(valEl).is(":checked")) {
    16751748                      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")
    16771753                      );
    16781754                    }
     
    16851761      }
    16861762
    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      );
    16881775    }
    16891776
    16901777    // Total price - start
    1691     if ($('.yayextra-total-price').length > 0) {
     1778    if ($(".yayextra-total-price").length > 0) {
    16921779      totalPriceHtml(
    1693         'yayextra-total-price',
     1780        "yayextra-total-price",
    16941781        additionCostSum,
    16951782        feeDiscounts,
     
    17001787
    17011788    // Extra subtotal price - start
    1702     if ($('.yayextra-extra-subtotal-price').length > 0) {
     1789    if ($(".yayextra-extra-subtotal-price").length > 0) {
    17031790      totalPriceHtml(
    1704         'yayextra-extra-subtotal-price',
     1791        "yayextra-extra-subtotal-price",
    17051792        additionCostSum,
    17061793        feeDiscounts,
     
    17171804    quantityProduct
    17181805  ) {
    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);
    17271816    let totalPrice =
    1728       (additionCostSum + parseFloat(currentPrice)) * parseInt(quantityProduct) + parseFloat(feeDiscounts.feeDiscountTotal);
     1817      (additionCostSum + parseFloat(currentPrice)) * parseInt(quantityProduct);
    17291818
    17301819    let totalPriceFormat = yayeNumberFormat(
     
    17351824    );
    17361825
    1737     let priceString = $('.' + elementWrap + ' .total-price').html();
     1826    let priceString = $("." + elementWrap + " .total-price").html();
    17381827    let stringReplace = yayeNumberFormat(
    17391828      parseFloat(dataTokenReplace),
     
    17441833
    17451834    // Update data-token-replace for later
    1746     $('.' + elementWrap + ' .total-price').attr(
    1747       'data-token-replace',
     1835    $("." + elementWrap + " .total-price").attr(
     1836      "data-token-replace",
    17481837      totalPrice
    17491838    );
     
    17511840    let priceStringFinal = priceString.replace(stringReplace, totalPriceFormat);
    17521841
    1753     if ( 'yayextra-total-price' === elementWrap ) {
     1842    if ("yayextra-total-price" === elementWrap) {
    17541843      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());
    17591856      }
    17601857      // 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);
    17621866    } 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      );
    17701876      return JSON.parse(variationsMeta);
    17711877    }
     
    17741880
    17751881  // 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
    17821910          // 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      }
    17861919    }
    17871920    return null;
    17881921  }
    17891922
    1790   // Find variation product 
     1923  // Find variation product
    17911924  function findVariationProduct(variationProduct, prodVariationData) {
    17921925    let result = true;
    17931926    let attrs = variationProduct.attributes;
    17941927    for (const attr in attrs) {
    1795       if( ! prodVariationData[attr] ) {
    1796         result = false
     1928      if (!prodVariationData[attr]) {
     1929        result = false;
    17971930        break;
    17981931      } else {
    1799         if( attrs[attr] && attrs[attr] !== prodVariationData[attr] ) {
    1800           result = false
     1932        if (attrs[attr] && attrs[attr] !== prodVariationData[attr]) {
     1933          result = false;
    18011934          break;
    18021935        }
     
    18061939    return result;
    18071940  }
    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) {
    18121945      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
    18171951        // 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);
    18251960          }
    18261961        }
     
    18351970
    18361971        let dataTokenReplace = $(valOptLabel).attr(
    1837           'data-option-org-cost-token-replace'
     1972          "data-option-org-cost-token-replace"
    18381973        );
    18391974
     
    18471982
    18481983        // 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
    18521989        );
    18531990
    1854         let priceStringFinal = priceString.replace(stringReplace, additionCostFormat);
    1855 
    18561991        $(valOptLabel).html(priceStringFinal);
    1857 
    18581992      }
    18591993    }
     
    18611995
    18621996  function getVisibilityOption() {
    1863     let optionFieldList = $('form').find('.yayextra-option-field-wrap:visible');
     1997    let optionFieldList = $("form").find(".yayextra-option-field-wrap:visible");
    18641998    let optionIdList = [];
    18651999    $.each(optionFieldList, function (_, optField) {
    1866       const optId = $(optField).attr('data-option-field-id');
     2000      const optId = $(optField).attr("data-option-field-id");
    18672001      optionIdList.push(optId);
    1868     })
     2002    });
    18692003
    18702004    // Set option id to hidden field to php handle
     
    18722006  }
    18732007
     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  }
    18742025})(jQuery);
  • yayextra/trunk/includes/Classes/ProductPage.php

    r3383835 r3481811  
    121121                                $opt_field['type']['value'] . '_field',
    122122                                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,
    128129                                )
    129130                            );
     
    137138
    138139            if ( isset( $settings['general'] ) && true === $settings['general']['show_extra_subtotal'] ) {
     140                $subtotal_text = apply_filters( 'yaye_subtotal_text', esc_html__( 'Extra subtotal:', 'yayextra' ) );
    139141                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>';
    141143                echo '<span class="total-price" data-token-replace="0" data-total-price="0">' . wp_kses_post( Utils::get_formatted_price_from_yaycurrency( 0 ) ) . '</span>';
    142144                echo '</div>';
     
    144146
    145147            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' ) );
    146149                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>';
    148151                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>';
    149152                echo '</div>';
     
    162165            // For YayExtra pro version.
    163166        }
     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' ) ) . '"/>';
    164172    }
    165173
     
    634642        foreach ( $cart_object->cart_contents as $cart_value ) {
    635643            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);
    638647               
    639648                if ( ! empty( $cart_value['yaye_custom_option'] ) ) {
     
    660669                );
    661670   
    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                }
    664679
    665680                $cart_value['data']->set_price( $cost_total );
     
    744759
    745760        // 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() ) {
    747762            $current_prod_id = $_product->get_parent_id();
    748763            if ( empty( $current_prod_id ) ) {
     
    760775                );
    761776
     777                $edit_option_text = apply_filters( 'yaye_edit_option_text', esc_html__( 'Edit option field', 'yayextra' ) );
    762778                $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>',
    764780                    'value' => '',
    765781                );
     
    11471163                $opt_val_temp = array();
    11481164                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']) );
    11501166                }
    11511167                $option_value = $opt_val_temp;
    11521168            } 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']);
    11541170                $option_value = $opt_val_temp;
    11551171            }
     
    12181234                        if ( 'is_one_of' === $comparation ) {
    12191235                            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 ) ) {
    12211237                                    return true;
    12221238                                };
     
    12251241                        } elseif ( 'is_not_one_of' === $comparation ) {
    12261242                            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 ) ) {
    12281244                                    return false;
    12291245                                };
     
    13611377     */
    13621378    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;
    13641380       
    13651381        $_product          = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
     
    13841400                    $product_permalink
    13851401                );
    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>';
    13871405            }
    13881406        }
     
    15871605                $css .= '}';
    15881606
    1589                 $css .= '.yayextra-total-price .total-price, .yayextra-extra-subtotal-price .total-price {';
     1607                $css .= '.yayextra-total-price .total-price {';
    15901608                if ( ! empty( $general_setts['total_price_font_size'] ) && '0px' !== $general_setts['total_price_font_size'] ) {
    15911609                    $css .= 'font-size: ' . $general_setts['total_price_font_size'] . 'px !important;';
     
    15931611                if ( ! empty( $general_setts['total_price_font_weight'] ) ) {
    15941612                    $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;';
    15951623                }
    15961624
     
    17061734                }
    17071735            }
     1736        } elseif ( 3 === $prod_filter_type ) { // Choose all products.
     1737            $prod_apply_list = 'all';
    17081738        }
    17091739
     
    20352065
    20362066                    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.
    20382074                            if ( isset( $settings['general'] ) && 'first_applicable' === $settings['general']['applied_option_sets']['value'] ) {
    20392075                                return array( $opt_set_data );
  • yayextra/trunk/includes/Helper/Database.php

    r3326588 r3481811  
    11<?php
    22namespace YayExtra\Helper;
     3
     4defined( 'ABSPATH' ) || exit;
    35
    46/**
     
    402404        global $wpdb;
    403405
     406        $filters = $this->expand_category_conditions( $filters );
     407
    404408        $this->filters = $filters;
    405409        $this->apply   = $apply;
     
    412416        return $result_query_all;
    413417    }
     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    }
    414469}
  • yayextra/trunk/includes/Helper/Utils.php

    r3383835 r3481811  
    433433            return x_currency_exchange( $price );
    434434        }
    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
    454440        return $price;
    455441    }
     
    504490             method_exists( 'Yay_Currency\Helpers\YayCurrencyHelper', 'detect_current_currency' )
    505491        ) {
     492            $original_price = $product_price;
    506493            $apply_currency = YayCurrencyHelper::detect_current_currency();
    507494            if ( ! empty( $apply_currency ) ) {
     
    517504                         YayCurrencyHelper::disable_fallback_option_in_checkout_page( $apply_currency ) )
    518505                    {
    519                         return wc_get_product( $product_id )->get_price( 'original' );
     506                        // return wc_get_product( $product_id )->get_price( 'original' );
     507                        return $original_price;
    520508                    }
    521509                    return self::get_reverse_price_from_yaycurrency( $product_price );
     
    531519            }
    532520            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 );
    533528        }
    534529
     
    742737    public static function gen_uuid() {
    743738        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 )
    749744        );
    750745    }
  • yayextra/trunk/includes/Init/Ajax.php

    r3262042 r3481811  
    55use YayExtra\Init\CustomPostType;
    66use YayExtra\Classes\ProductPage;
     7defined( 'ABSPATH' ) || exit;
    78/**
    89 * Ajax class
     
    5556            'get_settings',
    5657            'update_option_set_products_one_by_one',
     58            'update_reviewed_flag',
    5759        );
    5860    }
     
    116118
    117119    /**
     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 */
     164private 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    /**
    118347     * Ajax get option set by id.
    119348     *
     
    130359            $id         = sanitize_text_field( wp_unslash( isset( $_POST['id'] ) ? $_POST['id'] : null ) );
    131360            $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
    133379            $filters = get_post_meta( $id, '_yaye_products', true );
    134380
     
    271517                }
    272518
     519                $data = array_reverse( $data );
    273520                foreach ( $data as $option_set ) {
    274521                    /**
     
    591838        }
    592839    }
     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    }
    593852}
  • yayextra/trunk/includes/Init/CustomPostType.php

    r3383835 r3481811  
    5555
    5656    /**
    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.
    58134     *
    59135     * @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.
    61137     *
    62138     * @return array
    63139     */
    64140    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;
    86145
    87146        // 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
    92150        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
    103157        $option_set_list = array();
    104         if ( ! empty( $query_result ) ) {
    105             foreach ( $query_result as $post ) {
     158        if ( ! empty( $option_sets_paginated ) ) {
     159            foreach ( $option_sets_paginated as $post ) {
    106160                $option_set_list[] = self::build_option_set_data( $post->ID );
    107161            }
     
    151205     */
    152206    public static function get_option_set( $option_set_id ) {
     207
    153208        return self::build_option_set_data( $option_set_id, true );
     209       
    154210    }
    155211
     
    233289            update_post_meta( $insert_id, '_yaye_name', 'Sample Option Set' );
    234290            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 );
    236292            update_post_meta( $insert_id, '_yaye_options', array() );
    237293            update_post_meta( $insert_id, '_yaye_actions', array() );
     
    240296                '_yaye_products',
    241297                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,
    243299                    'product_filter_one_by_one'    => array(),
    244300                    'product_filter_by_conditions' => array(
     
    318374            }
    319375
    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 );
    321378            update_post_meta( $insert_id, '_yaye_description', $option_set_org['description'] );
    322379            update_post_meta( $insert_id, '_yaye_status', $option_set_org['status'] );
  • yayextra/trunk/includes/Init/Settings.php

    r3317357 r3481811  
    77use YayExtra\Classes\ProductPage;
    88use YayExtra\Helper\Utils;
    9 
     9use YayExtra\Utils\SingletonTrait;
     10use YayExtra\Register\ScriptName;
    1011defined( 'ABSPATH' ) || exit;
    1112/**
     
    1617class Settings {
    1718
    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
    4221    private function __construct() {
    4322        if ( ! function_exists( 'WC' ) ) {
     
    4827        add_action(
    4928            'before_woocommerce_init',
    50             function() {
     29            function () {
    5130                if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
    5231                    \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', YAYE_PLUGIN_FILE, true );
     
    5433            }
    5534        );
    56 
     35        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
    5736        add_action( 'admin_menu', array( $this, 'admin_menu' ), YAYE_MENU_PRIORITY );
    5837        add_filter( 'plugin_action_links_' . YAYE_BASENAME, array( $this, 'plugin_action_links' ) );
     
    6847    }
    6948
     49    public function admin_body_class( $classes ) {
     50        if ( strpos( $classes, 'yay-ui' ) === false ) {
     51            $classes .= ' yay-ui';
     52        }
     53        return $classes;
     54    }
    7055    /**
    7156     * Call back for admin_menu action
     
    115100        $current_screen = get_current_screen();
    116101        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 
    122102            // Enqueue script for wp.media .
    123103            wp_enqueue_media();
     
    139119            $option_set_id_list = $this->get_option_set_id_list();
    140120
     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
    141125            // Localize script for react.
    142126            wp_localize_script(
    143                 YAYE_PREFIX,
     127                ScriptName::PAGE_SETTINGS, //YAYE_PREFIX,
    144128                'yaye_data',
    145129                array(
     
    148132                    'ajax_url'          => admin_url( 'admin-ajax.php' ),
    149133                    'nonce'             => wp_create_nonce( 'yaye_nonce' ),
    150                     'image_url'         => YAYE_URL . '/assets/dist/images/',
     134                    'plugin_url'        => YAYE_URL,
    151135                    'site_url'          => YAYE_SITE_URL,
    152136                    'default_image_url' => \wc_placeholder_img_src(),
     
    156140                    'mine_types'        => Utils::get_mime_types(),
    157141                    '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() ),
    158148                )
    159149            );
     150
    160151        }
    161152    }
     
    264255                        'value' => 400,
    265256                    ),
     257                    'subtotal_price_font_size'   => '16',
     258                    'subtotal_price_font_weight' => array(
     259                        'label' => '400',
     260                        'value' => 400,
     261                    ),
    266262                    // 'total_price_color'       => '#6d6d6d',
    267263                ),
     
    326322                    'width'                    => '38',
    327323                    'height'                   => '38',
    328                     'border_width'             => '0',
    329                     'border_color'             => '#43454b',
     324                    'border_width'             => '2',
     325                    'border_color'             => '#f5f5f5',
    330326                    'border_style'             => array(
    331327                        'label' => 'Solid',
     
    333329                    ),
    334330                    'selected_border_width'    => '2',
    335                     'selected_border_color'    => '#43454b',
     331                    'selected_border_color'    => '#333333',
    336332                    'selected_border_style'    => array(
    337333                        'label' => 'Solid',
     
    342338                        'value' => 'bottom',
    343339                    ),
    344                     'tooltip_background_color' => '#555',
     340                    'tooltip_background_color' => '##333333',
    345341                    'tooltip_text_color'       => '#fff',
     342                    'corner_radius'            => '3',
    346343                ),
    347344                'button'   => array(
     
    352349                        'value' => 'solid',
    353350                    ),
    354                     'border_color'              => '#bcbcbc',
     351                    'border_color'              => '#e4e4e7',
    355352                    'background_color'          => '#fff',
    356                     'text_color'                => '#6d6d6d',
     353                    'text_color'                => '##333333',
    357354                    // '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',
    361358                    'selected_border_color'     => '#333333',
    362359                    'selected_background_color' => '#333333',
     
    366363                        'value' => 'bottom',
    367364                    ),
    368                     'tooltip_background_color'  => '#555',
     365                    'tooltip_background_color'  => '#333333',
    369366                    'tooltip_text_color'        => '#fff',
    370367                ),
     
    397394
    398395    }
    399 
    400396}
  • yayextra/trunk/includes/Templates/button_field.php

    r3383835 r3481811  
    8282        $id_opt        = $data['id'] . (string) $index;
    8383        $addition_cost = 0;
     84        $addition_cost_original = 0;
    8485        if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) {
    8586            $cost_type = $opt['additionalCost']['costType']['value'];
    8687            if ( 'fixed' === $cost_type ) {
    8788                $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) );
     89                $addition_cost_original = floatval( $opt['additionalCost']['value'] );
    8890            } else {
    8991                if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) {
    9092                    $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;
    9194                }
    9295            }
     
    9598        if ( ! empty( $general_settings['show_additional_price'] ) && ! empty( $addition_cost ) ) {
    9699            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>';
    98101            } 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>';
    100103            }
    101104        } else {
    102             $tooltip = '<strong>' . $opt['value'] . '</strong>';
     105            $tooltip = '<strong>' . esc_attr( $opt['value'] ) . '</strong>';
    103106        }
    104107
    105108        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">';
    107110        echo '<label class="yayextra-option-field-label yayextra-tooltip-wrap yayextra-option-button-label ' . esc_attr( $class_names ) . '">' . wp_kses_post( $opt['value'] ) . '</label>';
    108111        echo '<span class="yayextra-tooltiptext ' . esc_attr( $tooltip_possition_class ) . '">' . wp_kses_post( $tooltip ) . '</span>';
  • yayextra/trunk/includes/Templates/checkbox_field.php

    r3383835 r3481811  
    8282
    8383        $addition_cost = 0;
     84        $addition_cost_original = 0;
    8485        if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) {
    8586            $cost_type = $opt['additionalCost']['costType']['value'];
    8687            if ( 'fixed' === $cost_type ) {
    8788                $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) );
     89                $addition_cost_original = floatval( $opt['additionalCost']['value'] );
    8890            } else {
    8991                if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) {
    9092                    $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;
    9194                }
    9295            }
     
    9598        if ( ! empty( $general_settings['show_additional_price'] ) && ! empty( $addition_cost ) ) {
    9699            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>';
    98101            } else {
    99                 $label = $opt['value'] . ' ( + ' . wc_price( $addition_cost ) . ' )';
     102                $label = esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr( $addition_cost ) ) . ' )';
    100103            }
    101104        } else {
    102             $label = $opt['value'];
     105            $label = esc_attr( $opt['value'] );
    103106        }
    104107
     
    109112
    110113        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>';
    112115        echo '<label class="yayextra-option-field-label" for="' . esc_attr( $id_opt ) . '">' . wp_kses_post( $label ) . '</label>';
    113116        if ( ! empty( $addition_description ) ) {
  • yayextra/trunk/includes/Templates/dropdown_field.php

    r3383835 r3481811  
    3737
    3838    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>';
    4040    } 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>';
    4242    }
    4343
     
    7979
    8080        $addition_cost = 0;
     81        $addition_cost_original = 0;
    8182        if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) {
    8283            $cost_type = $opt['additionalCost']['costType']['value'];
    8384            if ( 'fixed' === $cost_type ) {
    8485                $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) );
     86                $addition_cost_original = floatval( $opt['additionalCost']['value'] );
    8587            } else {
    8688                if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) {
    8789                    $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;
    8891                }
    8992            }
     
    9194
    9295        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 ) ) . ' )';
    9497
    9598            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>';
    97100            } 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>';
    99102            }
    100103           
    101104        } else {
    102105            $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>';
    104107        }
    105108    }
  • yayextra/trunk/includes/Templates/radio_field.php

    r3383835 r3481811  
    4040
    4141        $addition_cost = 0;
     42        $addition_cost_original = 0;
    4243        if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) {
    4344            $cost_type = $opt['additionalCost']['costType']['value'];
    4445            if ( 'fixed' === $cost_type ) {
    4546                $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) );
     47                $addition_cost_original = floatval( $opt['additionalCost']['value'] );
    4648            } else {
    4749                if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) {
    4850                    $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;
    4952                }
    5053            }
     
    5356        if ( ! empty( $general_settings['show_additional_price'] ) && ! empty( $addition_cost ) ) {
    5457            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>';
    5659            } else {
    57                 $label = $opt['value'] . ' ( + ' . wc_price( $addition_cost ) . ' )';
     60                $label = esc_attr( $opt['value'] ) . ' ( + ' . wc_price( esc_attr( $addition_cost ) ) . ' )';
    5861            }
    5962        } else {
    60             $label = $opt['value'];
     63            $label = esc_attr( $opt['value'] );
    6164        }
    6265
     
    97100
    98101        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>';
    100103        echo '<label class="yayextra-option-field-label" for="' . esc_attr( $id_opt ) . '">' . wp_kses_post( $label ) . '</label>';
    101104        if ( ! empty( $addition_description ) ) {
  • yayextra/trunk/includes/Templates/swatches_field.php

    r3383835 r3481811  
    102102        $id_opt        = $data['id'] . (string) $index;
    103103        $addition_cost = 0;
     104        $addition_cost_original = 0;
    104105        if ( ! empty( $opt['additionalCost'] ) && ! empty( $opt['additionalCost']['isEnabled'] ) ) {
    105106            $cost_type = $opt['additionalCost']['costType']['value'];
    106107            if ( 'fixed' === $cost_type ) {
    107108                $addition_cost = Utils::get_price_from_currency_plugin( floatval( $opt['additionalCost']['value'] ) );
     109                $addition_cost_original = floatval( $opt['additionalCost']['value'] );
    108110            } else {
    109111                if ( isset( $params['product_price'] ) && is_numeric( $params['product_price'] ) ) {
    110112                    $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;
    111114                }
    112115            }
     
    115118        if ( ! empty( $general_settings['show_additional_price'] ) && ! empty( $addition_cost ) ) {
    116119            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>';
    118121            } 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>';
    120123            }
    121124        } else {
    122             $tooltip = '<strong>' . $opt['value'] . '</strong>';
     125            $tooltip = '<strong>' . esc_attr( $opt['value'] ) . '</strong>';
    123126        }
    124127
    125128        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">';
    127130        if ( 'image' === $opt['swatchesType'] && ! empty( $opt['imageUrl'] ) ) {
    128131            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  
    164164
    165165    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'                => [
    285231                'slug'              => 'yay-customer-reviews-woocommerce',
    286232                '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',
    289235                '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    }
    295343
    296344    public function yay_recommended_get_plugin_data() {
     
    499547    public function check_pro_version_exists( $pluginDetail ) {
    500548        $existProVer = false;
    501         $allPlugin   = get_plugins();
     549        $allPlugins   = get_plugins();
    502550        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;
    504552        }
    505553        if ( 'yaymail' === $pluginDetail['slug'] ) {
    506             if ( array_key_exists( 'yaymail-pro/yaymail.php', $allPlugin ) ) {
     554            if ( array_key_exists( 'yaymail-pro/yaymail.php', $allPlugins ) ) {
    507555                $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 ) ) {
    509557                $existProVer = 'email-customizer-for-woocommerce/yaymail.php';
    510558            }
    511559        }
    512560        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 ) ) {
    514562                $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 ) ) {
    516564                $existProVer = 'multi-currency-switcher/yay-currency.php';
    517565            }
    518566        }
    519567        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;
    521569        }
    522570        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;
    524572        }
    525573        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;
    527575        }
    528576        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            }
    530592        }
    531593        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;
    533595        }
    534596        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;
    536598        }
    537599        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';
    547605            }
    548606        }
  • yayextra/trunk/includes/YayCommerceMenu/RegisterMenu.php

    r3383835 r3481811  
    7474
    7575    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(
    11293                'parent'             => 'yaycommerce',
    11394                'name'               => __( 'Licenses', 'yaycommerce' ),
     
    11596                'render_callback'    => array( '\YayExtra\YayCommerceMenu\LicensesMenu', 'render' ),
    11697                '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            ),
    126106        );
    127 
    128         return $submenus;
    129107    }
    130108
  • yayextra/trunk/includes/YayCommerceMenu/views/other-plugins-content.php

    r2913533 r3481811  
    11<?php
     2defined( 'ABSPATH' ) || exit;
    23
    34$pluginsAllowedTags = array(
     
    4546        $pluginProVer = $this->check_pro_version_exists( $recommendedPlugin );
    4647        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 );
    5749        } else {
    5850            $installStatus = array(
     
    6860                if ( $installStatus['url'] ) {
    6961                    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                        );
    8869                    } else {
    8970                        $actionLinks[] = sprintf(
     
    9980                if ( $installStatus['url'] ) {
    10081                    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                        );
    12492                    } else {
    12593                        $actionLinks[] = sprintf(
  • yayextra/trunk/readme.txt

    r3474610 r3481811  
    66Requires PHP: 5.3
    77Tested up to: 6.9
    8 Stable tag: 1.5.6.1
     8Stable tag: 2.0.0
    99License: GPL-2.0+
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    2525- Improve product pages and increase order value
    2626
    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/) 👀
    2828
    2929**Works great for selling:**
     
    3838Build better product pages. Offer more choices. Sell more with YayExtra.
    3939
     40📌 [Quick Demo](https://demo.yaycommerce.com/yayextra/product/t-shirt/) | [Admin Test Drive](https://demo.yaycommerce.com/try-yayextra)
     41
    4042[youtube https://youtu.be/qytEac2_Yr0]
    4143
    42 [Free vs Pro](https://docs.yaycommerce.com/yayextra/why-upgrade) | [Quick Demo](https://demo.yaycommerce.com/yayextra/product/t-shirt/)
     44Why Upgrade? Check it here: [Free vs Pro](https://docs.yaycommerce.com/yayextra/why-upgrade)
    4345
    4446###⚡️ FEATURES
     
    125127
    126128== 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
    127141
    128142= Oct 24, 2025 - Version 1.5.6.1 =
  • yayextra/trunk/yayextra.php

    r3383835 r3481811  
    44 * Plugin URI: https://yaycommerce.com/yayextra-woocommerce-extra-product-options
    55 * Description: Offer extra options like personal engraving, print-on-demand items, gifts, custom canvas prints, and personalized products.
    6  * Version: 1.5.6.1
     6 * Version: 2.0.0
    77 * Author: YayCommerce
    88 * Author URI: https://yaycommerce.com
    99 * Text Domain: yayextra
    1010 * WC requires at least: 3.0.0
    11  * WC tested up to: 10.3.0
     11 * WC tested up to: 10.6.1
    1212 * Domain Path: /i18n/languages/
    1313 */
     
    1616
    1717use YayExtra\Init\Settings;
     18// use YayExtra\Integrations;
     19use YayExtra\Register\RegisterFacade;
    1820
    1921defined( 'ABSPATH' ) || exit;
     
    4850
    4951if ( ! defined( 'YAYE_VERSION' ) ) {
    50     define( 'YAYE_VERSION', '1.5.6.1' );
     52    define( 'YAYE_VERSION', '2.0.0' );
    5153}
    5254
     
    5456    define( 'YAYE_SITE_URL', site_url() );
    5557}
     58
    5659
    5760require __DIR__ . '/autoloader.php';
     
    6770        I18n::getInstance();
    6871        Settings::get_instance();
     72        // Integrations::get_instance();
     73        // Register Facade
     74        RegisterFacade::get_instance();
     75
    6976        add_action( 'admin_notices', 'YayExtra\\required_woocommerce_notice' );
    7077    }
Note: See TracChangeset for help on using the changeset viewer.