Plugin Directory

Changeset 3311224


Ignore:
Timestamp:
06/13/2025 07:18:07 PM (8 months ago)
Author:
biggidroid
Message:

Added support for the latest woocommerce version

Location:
ade-custom-shipping/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ade-custom-shipping/trunk/README.md

    r3310856 r3311224  
    77Requires PHP: 7.0
    88Tested up to: 6.8
    9 Stable tag: 4.2.0
     9Stable tag: 4.2.1
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5353
    5454== Changelog ==
     55
     56= 4.2.1 =
     57
     58- Fixed bug with state and city selection on woocommerce block checkout.
    5559
    5660= 4.2.0 =
  • ade-custom-shipping/trunk/ade-custom-shipping.php

    r3310856 r3311224  
    77 * Author URI: https://adeleyeayodeji.com
    88 * Description: Add shipping zones 3 levels deep for ecommerce.
    9  * Version: 4.2.0
     9 * Version: 4.2.1
    1010 * License: GPL2
    1111 * License URL: http://www.gnu.org/licenses/gpl-2.0.txt
  • ade-custom-shipping/trunk/assets/js/wc-custom-checkout.js

    r3084675 r3311224  
    6767}
    6868
     69/**
     70 * Ade Custom Shipping | adesetValueBlock
     71 * @param {element} elem
     72 * @param {string} state
     73 * @package Ade Custom Shipping
     74 */
     75window.adesetValueBlock = (elem) => {
     76  jQuery(document).ready(function ($) {
     77    //get state
     78    var ade_state_block = $(".ade-custom-shipping-state").val();
     79    var lga = $(elem).val();
     80    var finaltext = lga + ", " + ade_state_block;
     81    //set value to city input
     82    $("input#shipping-city").val(finaltext);
     83    //find select[name='billing_state'] option with value and set it to selected
     84    $("select#shipping-state")
     85      .find("option")
     86      .each(function (index, element) {
     87        if ($(element).val() == finaltext) {
     88          //set selected
     89          $(element).attr("selected", "selected");
     90          let element2 = document.querySelector("select#shipping-state");
     91          element2.value = finaltext;
     92          element2.dispatchEvent(new Event("change", { bubbles: true }));
     93        } else {
     94          $(element).removeAttr("selected");
     95        }
     96      });
     97    //recalculate
     98    $("select#shipping-state").trigger("change");
     99    //recalculate
     100    $(document.body).trigger("update_checkout");
     101  });
     102};
     103
    69104jQuery(document).ready(function ($) {
    70   var data_options = {
    71     state: ["Select State"],
    72     city: []
     105  /**
     106   * Capture State Options
     107   * @param {element} elem
     108   * @param {string} selected_state
     109   *
     110   * @returns {mixed}
     111   */
     112  let captureStateOptions = (elem, selected_state = "") => {
     113    //initialize data_options
     114    var data_options = {
     115      state: ["Select State"],
     116      city: []
     117    };
     118
     119    //check if selected_state is not empty
     120    if (selected_state != "") {
     121      //split selected_state
     122      var selected_state_split = selected_state.split(", ");
     123      var selected_state_name = selected_state_split[1];
     124    } else {
     125      var selected_state_name = "";
     126    }
     127
     128    //get state options
     129    var wc_state_options = elem.find("option");
     130    wc_state_options.each(function (index, element) {
     131      var state_value = $(element).val();
     132      //split ", "
     133      var state_name = state_value.split(", ")[1];
     134      var state_lga = state_value.split(", ")[0];
     135      //if state_name is undefined skip
     136      if (state_name === undefined) {
     137        return;
     138      }
     139      //push to data_options
     140      data_options.state.push(state_name);
     141      data_options.city.push({
     142        state: state_name,
     143        lga: state_lga
     144      });
     145    });
     146    //array unique
     147    var unique_state = [...new Set(data_options.state)];
     148    var state_options = "";
     149    $.each(unique_state, function (indexInArray, valueOfElement) {
     150      state_options += `<option value="${valueOfElement}" ${
     151        selected_state_name == valueOfElement ? `selected` : ""
     152      }>${valueOfElement}</option>`;
     153    });
     154    //return state_options
     155    return {
     156      state: state_options,
     157      city: data_options.city
     158    };
    73159  };
    74   var wc_state_options = $("select[name='billing_state']").find("option");
    75   wc_state_options.each(function (index, element) {
    76     var state_value = $(element).val();
    77     //split ", "
    78     var state_name = state_value.split(", ")[1];
    79     var state_lga = state_value.split(", ")[0];
    80     //if state_name is undefined skip
    81     if (state_name === undefined) {
    82       return;
    83     }
    84     //push to data_options
    85     data_options.state.push(state_name);
    86     data_options.city.push({
    87       state: state_name,
    88       lga: state_lga
    89     });
    90   });
    91   //array unique
    92   var unique_state = [...new Set(data_options.state)];
    93   var state_options = "";
    94   $.each(unique_state, function (indexInArray, valueOfElement) {
    95     state_options += `<option value="${valueOfElement}">${valueOfElement}</option>`;
    96   });
     160
     161  //capture state options
     162  var default_state_options = captureStateOptions(
     163    $("select[name='billing_state']")
     164  );
     165
    97166  $("#billing_country_field").after(`
    98167        <p class="form-row address-field validate-required validate-state form-row-wide woocommerce-validated" id="ade_custom_shipping_state2">
     
    100169          <span class="woocommerce-input-wrapper">
    101170            <select name="ade_custom_shipping_state2" class="state_select">
    102                 ${state_options}
     171                ${default_state_options.state}
    103172            </select>
    104173          </span>
     
    108177  let do_ade_calculation = (state, lga) => {
    109178    //set placeholder for lga
    110     lga = `<option value="">Select Town / City</option>`;
     179    lga = `<option value="0">Select Town / City</option>`;
    111180    //loop through data_options.city
    112     $.each(data_options.city, function (indexInArray, valueOfElement) {
     181    $.each(default_state_options.city, function (indexInArray, valueOfElement) {
    113182      if (valueOfElement.state === state) {
    114183        lga += `<option value="${valueOfElement.lga}">${valueOfElement.lga}</option>`;
     
    198267    adesetWooInputValues();
    199268  }, 1000);
     269
     270  /**
     271   * WooCommerce City Select Block Element
     272   * @param {string} state
     273   * @param {string} lga
     274   * @returns {void}
     275   * @description Update the city select block element
     276   */
     277  window.updateCitySelectBlockElement = (state, lga) => {
     278    //check if element is not a string
     279    if (typeof state !== "string" || state == "" || state == null) {
     280      //return
     281      return;
     282    }
     283
     284    var blockShippingCity = $(
     285      ".wc-block-components-text-input.wc-block-components-address-form__city"
     286    );
     287    //check if blockShippingCity exists
     288    if (blockShippingCity.length > 0) {
     289      //hide blockShippingCity
     290      blockShippingCity.hide();
     291
     292      //set placeholder for lga
     293      lga_block = `<option value="0">Select Town / City</option>`;
     294      //loop through data_options.city
     295      $.each(
     296        window.default_state_options_2.city,
     297        function (indexInArray, valueOfElement) {
     298          if (valueOfElement.state === state) {
     299            lga_block += `<option value="${valueOfElement.lga}">${valueOfElement.lga}</option>`;
     300          }
     301        }
     302      );
     303
     304      //check if .ade-custom-shipping-city
     305      if ($(".ade-custom-shipping-city").length > 0) {
     306        $(".ade-custom-shipping-city").html(lga_block);
     307        //return
     308        return;
     309      }
     310
     311      //add new select after blockShippingCity
     312      blockShippingCity.after(`
     313              <div class="wc-block-components-address-form__country wc-block-components-country-input ade-custom-shipping-city-container"><div class="wc-blocks-components-select"><div class="wc-blocks-components-select__container"><label for="shipping-country" class="wc-blocks-components-select__label">Town / City</label>
     314              <select size="1" class="wc-blocks-components-select__select ade-custom-shipping-city" id="ade-custom-shipping-city" aria-invalid="false" autocomplete="address-level2" onchange="window.adesetValueBlock(this, '${state}')">
     315                ${lga_block}
     316              </select>
     317              <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" class="wc-blocks-components-select__expand" aria-hidden="true" focusable="false"><path d="M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"></path></svg></div></div></div>
     318            `);
     319    }
     320  };
     321
     322  /**
     323   * WooCommerce Block Checkout Filter
     324   *
     325   */
     326  let moveAddressFormCity = () => {
     327    var addressFormCity = $(
     328      ".wc-block-components-text-input.wc-block-components-address-form__city"
     329    );
     330    //get address form state
     331    var addressFormState = $(
     332      ".wc-block-components-address-form__state.wc-block-components-state-input"
     333    );
     334    //get selected shipping-country
     335    var shippingCountry = $("select#shipping-country")
     336      .find("option:selected")
     337      .val();
     338
     339    //check if addressFormCity and addressFormState exist
     340    if (
     341      addressFormCity.length > 0 &&
     342      addressFormState.length > 0 &&
     343      shippingCountry == "NG"
     344    ) {
     345      //also check if addressFormCity is after addressFormState
     346      if (addressFormCity.index() < addressFormState.index()) {
     347        //switch node position, move addressFormCity after addressFormState
     348        addressFormCity.insertAfter(addressFormState);
     349        // //get select id shipping-state
     350        var shippingState = $("select#shipping-state");
     351        //get selected shipping-state
     352        var shippingStateValue = shippingState.find("option:selected").val();
     353
     354        //capture state options
     355        window.default_state_options_2 = captureStateOptions(shippingState, "");
     356        //hide shippingState
     357        shippingState.hide();
     358
     359        //check if element exists with .ade-custom-shipping-state
     360        if ($(".ade-custom-shipping-state").length > 0) {
     361          //return false
     362          return false;
     363        }
     364
     365        //add new select after shippingState
     366        shippingState.after(`
     367         <select size="1" class="wc-blocks-components-select__select ade-custom-shipping-state" id="ade-custom-shipping-state" onchange="updateCitySelectBlockElement(this.value, '')" aria-invalid="false" autocomplete="address-level1">
     368              ${default_state_options_2.state}
     369          </select>
     370        `);
     371      }
     372    } else {
     373      //revert all changes
     374      $(".ade-custom-shipping-city-container").remove();
     375      $(".ade-custom-shipping-state").remove();
     376      //show shippingState
     377      $("select#shipping-state").show();
     378      //show shippingCity
     379      $(
     380        ".wc-block-components-text-input.wc-block-components-address-form__city"
     381      ).show();
     382    }
     383  };
     384
     385  //set timeout to move addressFormCity
     386  setInterval(() => {
     387    moveAddressFormCity();
     388  }, 500);
    200389});
  • ade-custom-shipping/trunk/build/ade-core.asset.php

    r3310856 r3311224  
    1 <?php return array('dependencies' => array('react', 'wp-components', 'wp-html-entities'), 'version' => 'c7c23441aa21b1034bba');
     1<?php return array('dependencies' => array('react', 'wp-components', 'wp-html-entities'), 'version' => 'e0b10770f9c83bf5a0c3');
  • ade-custom-shipping/trunk/build/ade-core.js

    r3310856 r3311224  
    1 (()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React;var o=e.n(t);const n=window.wp.components;class l extends o().Component{constructor(e){super(e),this.state={popup:!1,woocommerce_states:{},formatted:[]}}componentWillMount(){const e=ade_custom_params.woocommerce_states;this.setState({woocommerce_states:e})}componentDidMount(){this.update_wc_states()}componentDidUpdate(){this.state.popup&&this.initSelect2()}update_wc_states=()=>{const e=this.state.woocommerce_states;let t=[];for(let n in e){let e=n.split(","),l=e[e.length-1];var o=l.split(" ");l=o.slice(1).join(" "),t.push(l)}t=[...new Set(t)],this.setState({formatted:t})};loadpopup=e=>{e.preventDefault(),this.setState({popup:!0})};initSelect2=()=>{void 0!==jQuery.fn.select2&&(jQuery("#ade_custom_shipping_selections").hasClass("select2-hidden-accessible")||jQuery("#ade_custom_shipping_selections").select2())};selectGroupRegions=e=>{e.preventDefault();let t=jQuery("#ade_custom_shipping_selections").val(),o=jQuery("#ade_custom_shipping_action_type").val();jQuery("select[name='zone_locations']").length&&(jQuery("select[name='zone_locations'] option").each((function(){jQuery(this).text().includes(t)&&jQuery(this).text().includes("Nigeria")&&jQuery(this).prop("selected","add"===o)})),jQuery("select[name='zone_locations']").trigger("change")),jQuery("select[data-placeholder='Select locations']").length&&(jQuery("select[data-placeholder='Select locations'] option").each((function(){jQuery(this).text().includes(t)&&jQuery(this).text().includes("Nigeria")&&jQuery(this).prop("selected","add"===o)})),jQuery("select[data-placeholder='Select locations']").trigger("change")),jQuery("#woocommerce-tree-select-control-0__control-input").length&&(jQuery("#woocommerce-tree-select-control-0__control-input").trigger("focus"),jQuery("#woocommerce-tree-select-control-0__control-input").val("Nigeria"),jQuery("#woocommerce-tree-select-control-0__control-input").trigger("change")),jQuery(".components-base-control.woocommerce-tree-select-control__option").length?jQuery(".components-base-control.woocommerce-tree-select-control__option").each((function(){console.log("get all elements");let e=$(this).find("label").text();console.log(e)})):console.log("no elements found");try{jQuery(".components-snackbar-list__notice-container").each((function(e,t){0!==e&&jquery(t).remove()})),wp.data.dispatch("core/notices").createNotice("success","Group Regions Updated",{type:"snackbar",isDismissible:!0,timeout:100})}catch(e){}};render(){const{popup:e,formatted:o}=this.state;return(0,t.createElement)(t.Fragment,null,e&&(0,t.createElement)(n.Modal,{title:"Select Group Regions",onRequestClose:()=>this.setState({popup:!1}),className:"ade-custom-shipping-selections"},(0,t.createElement)("div",{className:"ade-custom-shipping-select-container"},(0,t.createElement)("select",{name:"ade_custom_shipping_selections",id:"ade_custom_shipping_selections"},o.map(((e,o)=>(0,t.createElement)("option",{key:o,value:e},e)))),(0,t.createElement)("div",{className:"ade-custom-shipping-action-type"},(0,t.createElement)("label",null,"Action Type:"),(0,t.createElement)("select",{name:"ade_custom_shipping_action_type",id:"ade_custom_shipping_action_type"},(0,t.createElement)("option",{value:"add"},"Add"),(0,t.createElement)("option",{value:"remove"},"Remove"))),(0,t.createElement)("button",{onClick:this.selectGroupRegions,className:"button button-primary"},"Set Group Regions"),(0,t.createElement)("p",{style:{textAlign:"center"}},(0,t.createElement)("small",null,(0,t.createElement)("strong",null,"Note:")," This will group the selected regions to Nigeria",(0,t.createElement)("br",null),(0,t.createElement)("a",{href:"https://www.adeleyeayodeji.com",target:"_blank"},"Learn More"))))),(0,t.createElement)("button",{onClick:this.loadpopup,className:"button button-primary"},"Select Group Regions"))}}const c=l,a=window.wp.htmlEntities;function s(){const[e,o]=(0,t.useState)(!1),[l,c]=(0,t.useState)([]),[s,i]=(0,t.useState)(!1),[r,p]=(0,t.useState)("replace");var u=Object.keys(ade_custom_params.woocommerce_formatted_states).map((e=>({label:e,value:e})));const m=(e,t)=>Array.isArray(e)?e.map((e=>m(e,t))):(e.label&&(e.label=t(e.label)),e.children&&(e.children=m(e.children,t)),e);return(0,t.useEffect)((()=>{jQuery("#ade-custom-shipping-woocommerce-selections").select2({width:"resolve",placeholder:"Select a state or action",allowClear:!0}),jQuery("#ade-custom-shipping-woocommerce-selections").on("change",(e=>{(e=>{var t;const n=e.target.value,l=null!==(t=m(window.shippingZoneMethodsLocalizeScript?.region_options,a.decodeEntities))&&void 0!==t?t:[];if("remove-all"===n)return c([]),void o(!0);const s=l.find((e=>"Africa"===e.label)).children.find((e=>"Nigeria"===e.label)).children.filter((e=>e.value.includes(n))).map((e=>e.value));c(s),o(!0)})(e)}))}),[]),(0,t.createElement)("div",{className:"ade-custom-shipping-woocommerce-selections-wrapper"},e&&(0,t.createElement)(n.Modal,{title:"Page Reload Required",onRequestClose:()=>{o(!1)}},(0,t.createElement)("p",{style:{marginTop:0}},"A page reload is required to apply the changes.",(0,t.createElement)("br",null),"Please select an action to proceed."),l.length>0&&(0,t.createElement)("select",{value:r,style:{width:"100%",marginBottom:"20px"},onChange:e=>{p(e.target.value)}},(0,t.createElement)("option",{value:"append"},"Append to existing cities"),(0,t.createElement)("option",{value:"replace"},"Replace existing cities")),s?(0,t.createElement)(n.Spinner,null):(0,t.createElement)(n.Button,{onClick:()=>{var e;i(!0);let t=null!==(e=window.shippingZoneMethodsLocalizeScript?.locations)&&void 0!==e?e:[];"append"===r?t.push(...l):t=l,document.body.dispatchEvent(new CustomEvent("wc_region_picker_update",{detail:t}));const o=document.querySelector("button.wc-shipping-zone-method-save");o&&o.click(),setTimeout((()=>{window.location.reload()}),2e3)},isPrimary:!0},"Reload Page")),(0,t.createElement)("select",{id:"ade-custom-shipping-woocommerce-selections",style:{width:"100%",maxWidth:"600px"}},(0,t.createElement)("option",{value:""},"Select a state or action"),(0,t.createElement)("option",{value:"remove-all"},"Remove all cities - action"),u.map((e=>(0,t.createElement)("option",{value:e.value},e.label)))),(0,t.createElement)("small",{className:"wc-shipping-zone-help-text"},"Select all cities within the state.",(0,t.createElement)("br",null),(0,t.createElement)("strong",null,"Note:")," this will replace any previously selected default cities."))}jQuery(document).ready((function(e){setInterval((()=>{(()=>{if(e("#ade-custom-shipping-selections").length){let e=document.getElementById("ade-custom-shipping-selections");if(!e.hasChildNodes())return;ReactDOM.render((0,t.createElement)(c,null),e)}})(),(()=>{if(e("#ade-custom-shipping-wc-selections").length){let e=document.getElementById("ade-custom-shipping-wc-selections");if(!e.hasChildNodes())return;ReactDOM.render((0,t.createElement)(s,null),e)}})()}),1e3)}))})();
     1(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React;var o=e.n(t);const n=window.wp.components;class l extends o().Component{constructor(e){super(e),this.state={popup:!1,woocommerce_states:{},formatted:[]}}componentWillMount(){const e=ade_custom_params.woocommerce_states;this.setState({woocommerce_states:e})}componentDidMount(){this.update_wc_states()}componentDidUpdate(){this.state.popup&&this.initSelect2()}update_wc_states=()=>{const e=this.state.woocommerce_states;let t=[];for(let n in e){let e=n.split(","),l=e[e.length-1];var o=l.split(" ");l=o.slice(1).join(" "),t.push(l)}t=[...new Set(t)],this.setState({formatted:t})};loadpopup=e=>{e.preventDefault(),this.setState({popup:!0})};initSelect2=()=>{void 0!==jQuery.fn.select2&&(jQuery("#ade_custom_shipping_selections").hasClass("select2-hidden-accessible")||jQuery("#ade_custom_shipping_selections").select2())};selectGroupRegions=e=>{e.preventDefault();let t=jQuery("#ade_custom_shipping_selections").val(),o=jQuery("#ade_custom_shipping_action_type").val();jQuery("select[name='zone_locations']").length&&(jQuery("select[name='zone_locations'] option").each((function(){jQuery(this).text().includes(t)&&jQuery(this).text().includes("Nigeria")&&jQuery(this).prop("selected","add"===o)})),jQuery("select[name='zone_locations']").trigger("change")),jQuery("select[data-placeholder='Select locations']").length&&(jQuery("select[data-placeholder='Select locations'] option").each((function(){jQuery(this).text().includes(t)&&jQuery(this).text().includes("Nigeria")&&jQuery(this).prop("selected","add"===o)})),jQuery("select[data-placeholder='Select locations']").trigger("change")),jQuery("#woocommerce-tree-select-control-0__control-input").length&&(jQuery("#woocommerce-tree-select-control-0__control-input").trigger("focus"),jQuery("#woocommerce-tree-select-control-0__control-input").val("Nigeria"),jQuery("#woocommerce-tree-select-control-0__control-input").trigger("change")),jQuery(".components-base-control.woocommerce-tree-select-control__option").length?jQuery(".components-base-control.woocommerce-tree-select-control__option").each((function(){console.log("get all elements");let e=$(this).find("label").text();console.log(e)})):console.log("no elements found");try{jQuery(".components-snackbar-list__notice-container").each((function(e,t){0!==e&&jquery(t).remove()})),wp.data.dispatch("core/notices").createNotice("success","Group Regions Updated",{type:"snackbar",isDismissible:!0,timeout:100})}catch(e){}};render(){const{popup:e,formatted:o}=this.state;return(0,t.createElement)(t.Fragment,null,e&&(0,t.createElement)(n.Modal,{title:"Select Group Regions",onRequestClose:()=>this.setState({popup:!1}),className:"ade-custom-shipping-selections"},(0,t.createElement)("div",{className:"ade-custom-shipping-select-container"},(0,t.createElement)("select",{name:"ade_custom_shipping_selections",id:"ade_custom_shipping_selections"},o.map(((e,o)=>(0,t.createElement)("option",{key:o,value:e},e)))),(0,t.createElement)("div",{className:"ade-custom-shipping-action-type"},(0,t.createElement)("label",null,"Action Type:"),(0,t.createElement)("select",{name:"ade_custom_shipping_action_type",id:"ade_custom_shipping_action_type"},(0,t.createElement)("option",{value:"add"},"Add"),(0,t.createElement)("option",{value:"remove"},"Remove"))),(0,t.createElement)("button",{onClick:this.selectGroupRegions,className:"button button-primary"},"Set Group Regions"),(0,t.createElement)("p",{style:{textAlign:"center"}},(0,t.createElement)("small",null,(0,t.createElement)("strong",null,"Note:")," This will group the selected regions to Nigeria",(0,t.createElement)("br",null),(0,t.createElement)("a",{href:"https://www.adeleyeayodeji.com",target:"_blank"},"Learn More"))))),(0,t.createElement)("button",{onClick:this.loadpopup,className:"button button-primary"},"Select Group Regions"))}}const c=l,a=window.wp.htmlEntities;function s(){const[e,o]=(0,t.useState)(!1),[l,c]=(0,t.useState)([]),[s,i]=(0,t.useState)(!1),[r,p]=(0,t.useState)("replace");var u=Object.keys(ade_custom_params.woocommerce_formatted_states).map((e=>({label:e,value:e})));const m=(e,t)=>Array.isArray(e)?e.map((e=>m(e,t))):(e.label&&(e.label=t(e.label)),e.children&&(e.children=m(e.children,t)),e);return(0,t.useEffect)((()=>{jQuery("#ade-custom-shipping-woocommerce-selections").select2({width:"resolve",placeholder:"Select a state or action",allowClear:!0}),jQuery("#ade-custom-shipping-woocommerce-selections").on("change",(e=>{(e=>{var t;const n=e.target.value,l=null!==(t=m(window.shippingZoneMethodsLocalizeScript?.region_options,a.decodeEntities))&&void 0!==t?t:[];if("remove-all"===n)return c([]),void o(!0);const s=l.find((e=>"Africa"===e.label)).children.find((e=>"Nigeria"===e.label)).children.filter((e=>e.value.includes(n))).map((e=>e.value));c(s),o(!0)})(e)}))}),[]),(0,t.createElement)("div",{className:"ade-custom-shipping-woocommerce-selections-wrapper"},e&&(0,t.createElement)(n.Modal,{title:"Page Reload Required",onRequestClose:()=>{o(!1)}},(0,t.createElement)("p",{style:{marginTop:0}},"A page reload is required to apply the changes.",(0,t.createElement)("br",null),"Please select an action to proceed."),l.length>0&&(0,t.createElement)("select",{value:r,style:{width:"100%",marginBottom:"20px"},onChange:e=>{p(e.target.value)}},(0,t.createElement)("option",{value:"append"},"Append to existing cities"),(0,t.createElement)("option",{value:"replace"},"Replace existing cities")),s?(0,t.createElement)(n.Spinner,null):(0,t.createElement)(n.Button,{onClick:()=>{var e;i(!0);let t=null!==(e=window.shippingZoneMethodsLocalizeScript?.locations)&&void 0!==e?e:[];"append"===r?t.push(...l):t=l,document.body.dispatchEvent(new CustomEvent("wc_region_picker_update",{detail:t}));const o=document.querySelector("button.wc-shipping-zone-method-save");o&&o.click(),setTimeout((()=>{window.location.reload()}),2e3)},isPrimary:!0},"Reload Page")),(0,t.createElement)("select",{id:"ade-custom-shipping-woocommerce-selections",style:{width:"100%",maxWidth:"600px"}},(0,t.createElement)("option",{value:""},"Select a state or action"),(0,t.createElement)("option",{value:"remove-all"},"Remove all cities - action"),u.map((e=>(0,t.createElement)("option",{value:e.value},e.label)))),(0,t.createElement)("small",{className:"wc-shipping-zone-help-text"},"Select all cities within the state.",(0,t.createElement)("br",null),(0,t.createElement)("strong",null,"Note:")," You can always leave this field empty"))}jQuery(document).ready((function(e){setInterval((()=>{(()=>{if(e("#ade-custom-shipping-selections").length){let e=document.getElementById("ade-custom-shipping-selections");if(!e.hasChildNodes())return;ReactDOM.render((0,t.createElement)(c,null),e)}})(),(()=>{if(e("#ade-custom-shipping-wc-selections").length){let e=document.getElementById("ade-custom-shipping-wc-selections");if(!e.hasChildNodes())return;ReactDOM.render((0,t.createElement)(s,null),e)}})()}),1e3)}))})();
  • ade-custom-shipping/trunk/package.json

    r3208496 r3311224  
    11{
    22  "name": "ade-custom-shipping",
    3   "version": "4.1.8",
     3  "version": "4.2.1",
    44  "description": "Ade Custom Shipping is a powerful plugin that allows you to create custom shipping zones for your WooCommerce store. With the ability to add up to three levels of shipping zones, you can easily set shipping rates based on regions, offer free shipping on orders over a certain amount, set up tiered shipping rates, and restrict shipping to specific countries or regions.",
    55  "author": "Ade Custom Shipping",
Note: See TracChangeset for help on using the changeset viewer.