Version Description
- New Feature: Support fulfillment according to order items
Download this release
Release Info
Developer | aftership |
Plugin | AfterShip – WooCommerce Tracking |
Version | 1.14.0 |
Comparing to | |
See all releases |
Code changes from version 1.13.10 to 1.14.0
- .huskyrc +5 -0
- aftership-woocommerce-tracking.php +7 -2
- assets/meta-box/dist/index.js +1 -0
- assets/meta-box/dist/style.css +1 -0
- includes/api/v4/class-aftership-api-orders.php +5 -20
- includes/class-aftership-actions.php +193 -161
- readme.txt +4 -1
.huskyrc
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"hooks": {
|
3 |
+
"pre-commit": "./vendor/bin/phpcbf ./"
|
4 |
+
}
|
5 |
+
}
|
aftership-woocommerce-tracking.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: AfterShip Tracking - All-In-One WooCommerce Order Tracking (Free plan available)
|
4 |
* Plugin URI: http://aftership.com/
|
5 |
* Description: Track orders in one place. shipment tracking, automated notifications, order lookup, branded tracking page, delivery day prediction
|
6 |
-
* Version: 1.
|
7 |
* Author: AfterShip
|
8 |
* Author URI: http://aftership.com
|
9 |
*
|
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
20 |
|
21 |
require_once( 'woo-includes/woo-functions.php' );
|
22 |
|
23 |
-
define( 'AFTERSHIP_VERSION', '1.
|
24 |
define( 'AFTERSHIP_PATH', dirname( __FILE__ ) );
|
25 |
define( 'AFTERSHIP_ASSETS_URL', plugins_url() . '/' . basename( AFTERSHIP_PATH ) );
|
26 |
|
@@ -161,6 +161,11 @@ if ( is_woocommerce_active() ) {
|
|
161 |
add_action( 'wp_ajax_aftership_save_form', array( $this->actions, 'save_meta_box_ajax' ) );
|
162 |
add_action( 'wp_ajax_aftership_get_items', array( $this->actions, 'get_meta_box_items_ajax' ) );
|
163 |
|
|
|
|
|
|
|
|
|
|
|
164 |
$subs_version = class_exists( 'WC_Subscriptions' ) && ! empty( WC_Subscriptions::$version ) ? WC_Subscriptions::$version : null;
|
165 |
|
166 |
// Prevent data being copied to subscriptions.
|
3 |
* Plugin Name: AfterShip Tracking - All-In-One WooCommerce Order Tracking (Free plan available)
|
4 |
* Plugin URI: http://aftership.com/
|
5 |
* Description: Track orders in one place. shipment tracking, automated notifications, order lookup, branded tracking page, delivery day prediction
|
6 |
+
* Version: 1.14.0
|
7 |
* Author: AfterShip
|
8 |
* Author URI: http://aftership.com
|
9 |
*
|
20 |
|
21 |
require_once( 'woo-includes/woo-functions.php' );
|
22 |
|
23 |
+
define( 'AFTERSHIP_VERSION', '1.14.0' );
|
24 |
define( 'AFTERSHIP_PATH', dirname( __FILE__ ) );
|
25 |
define( 'AFTERSHIP_ASSETS_URL', plugins_url() . '/' . basename( AFTERSHIP_PATH ) );
|
26 |
|
161 |
add_action( 'wp_ajax_aftership_save_form', array( $this->actions, 'save_meta_box_ajax' ) );
|
162 |
add_action( 'wp_ajax_aftership_get_items', array( $this->actions, 'get_meta_box_items_ajax' ) );
|
163 |
|
164 |
+
add_action( 'wp_ajax_aftership_delete_order_tracking', array( $this->actions, 'delete_order_tracking' ) );
|
165 |
+
add_action( 'wp_ajax_aftership_save_order_tracking', array( $this->actions, 'save_order_tracking' ) );
|
166 |
+
add_action( 'wp_ajax_aftership_get_order_trackings', array( $this->actions, 'get_order_detail' ) );
|
167 |
+
add_action( 'wp_ajax_aftership_get_settings', array( $this->actions, 'get_settings' ) );
|
168 |
+
|
169 |
$subs_version = class_exists( 'WC_Subscriptions' ) && ! empty( WC_Subscriptions::$version ) ? WC_Subscriptions::$version : null;
|
170 |
|
171 |
// Prevent data being copied to subscriptions.
|
assets/meta-box/dist/index.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
var _i=Object.defineProperty,vi=Object.defineProperties;var mi=Object.getOwnPropertyDescriptors;var $t=Object.getOwnPropertySymbols;var yi=Object.prototype.hasOwnProperty,bi=Object.prototype.propertyIsEnumerable;var Fe=(H,E,j)=>E in H?_i(H,E,{enumerable:!0,configurable:!0,writable:!0,value:j}):H[E]=j,R=(H,E)=>{for(var j in E||(E={}))yi.call(E,j)&&Fe(H,j,E[j]);if($t)for(var j of $t(E))bi.call(E,j)&&Fe(H,j,E[j]);return H},z=(H,E)=>vi(H,mi(E));var wt=(H,E,j)=>(Fe(H,typeof E!="symbol"?E+"":E,j),j);var te=(H,E,j)=>new Promise((_e,Q)=>{var J=I=>{try{ie(j.next(I))}catch(G){Q(G)}},le=I=>{try{ie(j.throw(I))}catch(G){Q(G)}},ie=I=>I.done?_e(I.value):Promise.resolve(I.value).then(J,le);ie((j=j.apply(H,E)).next())});(function(){"use strict";const H=(e,n)=>e===n,E=Symbol("solid-proxy"),j={equals:H};let _e=Ge;const Q={},J=1,le=2,ie={owned:null,cleanups:null,context:null,owner:null};var I=null;let G=null,D=null,ae=null,Y=null,K=null,Ie=0;function ve(e,n){n&&(I=n);const t=D,i=I,r=e.length===0?ie:{owned:null,cleanups:null,context:null,owner:i};I=r,D=null;let s;try{Ee(()=>s=e(()=>Le(r)),!0)}finally{D=t,I=i}return s}function X(e,n){n=n?Object.assign({},j,n):j;const t={value:e,observers:null,observerSlots:null,pending:Q,comparator:n.equals||void 0};return[Ve.bind(t),i=>(typeof i=="function"&&(G&&G.running&&G.sources.has(t)?i=i(t.pending!==Q?t.pending:t.tValue):i=i(t.pending!==Q?t.pending:t.value)),je(t,i))]}function q(e,n,t){const i=Me(e,n,!1,J);me(i)}function Te(e,n,t){_e=It;const i=Me(e,n,!1,J);i.user=!0,K&&K.push(i)}function F(e,n,t){t=t?Object.assign({},j,t):j;const i=Me(e,n,!0,0);return i.pending=Q,i.observers=null,i.observerSlots=null,i.comparator=t.equals||void 0,me(i),Ve.bind(i)}function xt(e){if(ae)return e();let n;const t=ae=[];try{n=e()}finally{ae=null}return Ee(()=>{for(let i=0;i<t.length;i+=1){const r=t[i];if(r.pending!==Q){const s=r.pending;r.pending=Q,je(r,s)}}},!1),n}function re(e){let n,t=D;return D=null,n=e(),D=t,n}function St(e){Te(()=>re(e))}function kt(e){return I===null||(I.cleanups===null?I.cleanups=[e]:I.cleanups.push(e)),e}function Ct(e){const n=F(e);return F(()=>Oe(n()))}function Ve(){const e=G;if(this.sources&&(this.state||e)){const n=Y;Y=null,this.state===J||e?me(this):De(this),Y=n}if(D){const n=this.observers?this.observers.length:0;D.sources?(D.sources.push(this),D.sourceSlots.push(n)):(D.sources=[this],D.sourceSlots=[n]),this.observers?(this.observers.push(D),this.observerSlots.push(D.sources.length-1)):(this.observers=[D],this.observerSlots=[D.sources.length-1])}return this.value}function je(e,n,t){if(e.comparator&&e.comparator(e.value,n))return n;if(ae)return e.pending===Q&&ae.push(e),e.pending=n,n;let i=!1;return e.value=n,e.observers&&e.observers.length&&Ee(()=>{for(let r=0;r<e.observers.length;r+=1){const s=e.observers[r];i&&G.disposed.has(s),s.pure?Y.push(s):K.push(s),s.observers&&(i&&!s.tState||!i&&!s.state)&&We(s),i||(s.state=J)}if(Y.length>1e6)throw Y=[],new Error},!1),n}function me(e){if(!e.fn)return;Le(e);const n=I,t=D,i=Ie;D=I=e,Nt(e,e.value,i),D=t,I=n}function Nt(e,n,t){let i;try{i=e.fn(n)}catch(r){Qe(r)}(!e.updatedAt||e.updatedAt<=t)&&(e.observers&&e.observers.length?je(e,i):e.value=i,e.updatedAt=t)}function Me(e,n,t,i=J,r){const s={fn:e,state:i,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:n,owner:I,context:null,pure:t};return I===null||I!==ie&&(I.owned?I.owned.push(s):I.owned=[s]),s}function ce(e){const n=G;if(e.state!==J)return e.state=0;if(e.suspense&&re(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Ie);)(e.state||n)&&t.push(e);for(let i=t.length-1;i>=0;i--)if(e=t[i],e.state===J||n)me(e);else if(e.state===le||n){const r=Y;Y=null,De(e),Y=r}}function Ee(e,n){if(Y)return e();let t=!1;n||(Y=[]),K?t=!0:K=[],Ie++;try{e()}catch(i){Qe(i)}finally{At(t)}}function At(e){Y&&(Ge(Y),Y=null),!e&&(K.length?xt(()=>{_e(K),K=null}):K=null)}function Ge(e){for(let n=0;n<e.length;n++)ce(e[n])}function It(e){let n,t=0;for(n=0;n<e.length;n++){const r=e[n];r.user?e[t++]=r:ce(r)}const i=e.length;for(n=0;n<t;n++)ce(e[n]);for(n=i;n<e.length;n++)ce(e[n])}function De(e){e.state=0;const n=G;for(let t=0;t<e.sources.length;t+=1){const i=e.sources[t];i.sources&&(i.state===J||n?ce(i):(i.state===le||n)&&De(i))}}function We(e){const n=G;for(let t=0;t<e.observers.length;t+=1){const i=e.observers[t];(!i.state||n)&&(i.state=le,i.pure?Y.push(i):K.push(i),i.observers&&We(i))}}function Le(e){let n;if(e.sources)for(;e.sources.length;){const t=e.sources.pop(),i=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){const s=r.pop(),d=t.observerSlots.pop();i<r.length&&(s.sourceSlots[d]=i,r[i]=s,t.observerSlots[i]=d)}}if(e.owned){for(n=0;n<e.owned.length;n++)Le(e.owned[n]);e.owned=null}if(e.cleanups){for(n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}e.state=0,e.context=null}function Qe(e){throw e}function Oe(e){if(typeof e=="function"&&!e.length)return Oe(e());if(Array.isArray(e)){const n=[];for(let t=0;t<e.length;t++){const i=Oe(e[t]);Array.isArray(i)?n.push.apply(n,i):n.push(i)}return n}return e}const Tt=Symbol("fallback");function Je(e){for(let n=0;n<e.length;n++)e[n]()}function jt(e,n,t={}){let i=[],r=[],s=[],d=0,l=n.length>1?[]:null;return kt(()=>Je(s)),()=>{let p=e()||[],a,u;return re(()=>{let w=p.length,A,b,m,f,C,o,c,y,$;if(w===0)d!==0&&(Je(s),s=[],i=[],r=[],d=0,l&&(l=[])),t.fallback&&(i=[Tt],r[0]=ve(k=>(s[0]=k,t.fallback())),d=1);else if(d===0){for(r=new Array(w),u=0;u<w;u++)i[u]=p[u],r[u]=ve(S);d=w}else{for(m=new Array(w),f=new Array(w),l&&(C=new Array(w)),o=0,c=Math.min(d,w);o<c&&i[o]===p[o];o++);for(c=d-1,y=w-1;c>=o&&y>=o&&i[c]===p[y];c--,y--)m[y]=r[c],f[y]=s[c],l&&(C[y]=l[c]);for(A=new Map,b=new Array(y+1),u=y;u>=o;u--)$=p[u],a=A.get($),b[u]=a===void 0?-1:a,A.set($,u);for(a=o;a<=c;a++)$=i[a],u=A.get($),u!==void 0&&u!==-1?(m[u]=r[a],f[u]=s[a],l&&(C[u]=l[a]),u=b[u],A.set($,u)):s[a]();for(u=o;u<w;u++)u in m?(r[u]=m[u],s[u]=f[u],l&&(l[u]=C[u],l[u](u))):r[u]=ve(S);r=r.slice(0,d=w),i=p.slice(0)}return r});function S(w){if(s[u]=w,l){const[A,b]=X(u);return l[u]=b,n(p[u],A)}return n(p[u])}}}function U(e,n){return re(()=>e(n))}function ye(){return!0}const Mt={get(e,n,t){return n===E?t:e.get(n)},has(e,n){return e.has(n)},set:ye,deleteProperty:ye,getOwnPropertyDescriptor(e,n){return{configurable:!0,enumerable:!0,get(){return e.get(n)},set:ye,deleteProperty:ye}},ownKeys(e){return e.keys()}};function Be(e){return typeof e=="function"?e():e}function Et(...e){return new Proxy({get(n){for(let t=e.length-1;t>=0;t--){const i=Be(e[t])[n];if(i!==void 0)return i}},has(n){for(let t=e.length-1;t>=0;t--)if(n in Be(e[t]))return!0;return!1},keys(){const n=[];for(let t=0;t<e.length;t++)n.push(...Object.keys(Be(e[t])));return[...new Set(n)]}},Mt)}function be(e){const n="fallback"in e&&{fallback:()=>e.fallback};return F(jt(()=>e.each,e.children,n||void 0))}function Pe(e){let n=!1;const t=F(()=>e.when,void 0,{equals:(i,r)=>n?i===r:!i==!r});return F(()=>{const i=t();if(i){const r=e.children;return(n=typeof r=="function"&&r.length>0)?re(()=>r(i)):r}return e.fallback})}function Dt(e){let n=!1;const t=Ct(()=>e.children),i=F(()=>{let r=t();Array.isArray(r)||(r=[r]);for(let s=0;s<r.length;s++){const d=r[s].when;if(d)return[s,d,r[s]]}return[-1]},void 0,{equals:(r,s)=>r&&r[0]===s[0]&&(n?r[1]===s[1]:!r[1]==!s[1])&&r[2]===s[2]});return F(()=>{const[r,s,d]=i();if(r<0)return e.fallback;const l=d.children;return(n=typeof l=="function"&&l.length>0)?re(()=>l(s)):l})}function Lt(e){return e}function Ke(e,n,t){let i=t.length,r=n.length,s=i,d=0,l=0,p=n[r-1].nextSibling,a=null;for(;d<r||l<s;){if(n[d]===t[l]){d++,l++;continue}for(;n[r-1]===t[s-1];)r--,s--;if(r===d){const u=s<i?l?t[l-1].nextSibling:t[s-l]:p;for(;l<s;)e.insertBefore(t[l++],u)}else if(s===l)for(;d<r;)(!a||!a.has(n[d]))&&e.removeChild(n[d]),d++;else if(n[d]===t[s-1]&&t[l]===n[r-1]){const u=n[--r].nextSibling;e.insertBefore(t[l++],n[d++].nextSibling),e.insertBefore(t[--s],u),n[r]=t[s]}else{if(!a){a=new Map;let S=l;for(;S<s;)a.set(t[S],S++)}const u=a.get(n[d]);if(u!=null)if(l<u&&u<s){let S=d,w=1,A;for(;++S<r&&S<s&&!((A=a.get(n[S]))==null||A!==u+w);)w++;if(w>u-l){const b=n[d];for(;l<u;)e.insertBefore(t[l++],b)}else e.replaceChild(t[l++],n[d++])}else d++;else e.removeChild(n[d++])}}}const Xe="_$DX_DELEGATE";function Ot(e,n,t){let i;return ve(r=>{i=r,M(n,e(),n.firstChild?null:void 0,t)}),()=>{i(),n.textContent=""}}function V(e,n,t){const i=document.createElement("template");i.innerHTML=e;let r=i.content.firstChild;return t&&(r=r.firstChild),r}function ue(e,n=window.document){const t=n[Xe]||(n[Xe]=new Set);for(let i=0,r=e.length;i<r;i++){const s=e[i];t.has(s)||(t.add(s),n.addEventListener(s,Rt))}}function ne(e,n,t){t==null?e.removeAttribute(n):e.setAttribute(n,t)}function Re(e,n,t,i){i?Array.isArray(t)?(e[`$$${n}`]=t[0],e[`$$${n}Data`]=t[1]):e[`$$${n}`]=t:Array.isArray(t)?e.addEventListener(n,r=>t[0](t[1],r)):e.addEventListener(n,t)}function Bt(e,n,t={}){const i=Object.keys(n||{}),r=Object.keys(t);let s,d;for(s=0,d=r.length;s<d;s++){const l=r[s];!l||l==="undefined"||n[l]||(et(e,l,!1),delete t[l])}for(s=0,d=i.length;s<d;s++){const l=i[s],p=!!n[l];!l||l==="undefined"||t[l]===p||!p||(et(e,l,!0),t[l]=p)}return t}function Pt(e,n,t={}){const i=e.style;if(n==null||typeof n=="string")return i.cssText=n;typeof t=="string"&&(t={});let r,s;for(s in t)n[s]==null&&i.removeProperty(s),delete t[s];for(s in n)r=n[s],r!==t[s]&&(i.setProperty(s,r),t[s]=r);return t}function M(e,n,t,i){if(t!==void 0&&!i&&(i=[]),typeof n!="function")return pe(e,n,i,t);q(r=>pe(e,n(),r,t),i)}function et(e,n,t){const i=n.trim().split(/\s+/);for(let r=0,s=i.length;r<s;r++)e.classList.toggle(i[r],t)}function Rt(e){const n=`$$${e.type}`;let t=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==t&&Object.defineProperty(e,"target",{configurable:!0,value:t}),Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t}});t!==null;){const i=t[n];if(i&&!t.disabled){const r=t[`${n}Data`];if(r!==void 0?i(r,e):i(e),e.cancelBubble)return}t=t.host&&t.host!==t&&t.host instanceof Node?t.host:t.parentNode}}function pe(e,n,t,i,r){for(;typeof t=="function";)t=t();if(n===t)return t;const s=typeof n,d=i!==void 0;if(e=d&&t[0]&&t[0].parentNode||e,s==="string"||s==="number")if(s==="number"&&(n=n.toString()),d){let l=t[0];l&&l.nodeType===3?l.data=n:l=document.createTextNode(n),t=fe(e,t,i,l)}else t!==""&&typeof t=="string"?t=e.firstChild.data=n:t=e.textContent=n;else if(n==null||s==="boolean")t=fe(e,t,i);else{if(s==="function")return q(()=>{let l=n();for(;typeof l=="function";)l=l();t=pe(e,l,t,i)}),()=>t;if(Array.isArray(n)){const l=[];if(ze(l,n,r))return q(()=>t=pe(e,l,t,i,!0)),()=>t;if(l.length===0){if(t=fe(e,t,i),d)return t}else Array.isArray(t)?t.length===0?tt(e,l,i):Ke(e,t,l):t==null||t===""?tt(e,l):Ke(e,d&&t||[e.firstChild],l);t=l}else if(n instanceof Node){if(Array.isArray(t)){if(d)return t=fe(e,t,i,n);fe(e,t,null,n)}else t==null||t===""||!e.firstChild?e.appendChild(n):e.replaceChild(n,e.firstChild);t=n}}return t}function ze(e,n,t){let i=!1;for(let r=0,s=n.length;r<s;r++){let d=n[r],l;if(d instanceof Node)e.push(d);else if(!(d==null||d===!0||d===!1))if(Array.isArray(d))i=ze(e,d)||i;else if((l=typeof d)==="string")e.push(document.createTextNode(d));else if(l==="function")if(t){for(;typeof d=="function";)d=d();i=ze(e,Array.isArray(d)?d:[d])||i}else e.push(d),i=!0;else e.push(document.createTextNode(d.toString()))}return i}function tt(e,n,t){for(let i=0,r=n.length;i<r;i++)e.insertBefore(n[i],t)}function fe(e,n,t,i){if(t===void 0)return e.textContent="";const r=i||document.createTextNode("");if(n.length){let s=!1;for(let d=n.length-1;d>=0;d--){const l=n[d];if(r!==l){const p=l.parentNode===e;!s&&!d?p?e.replaceChild(r,l):e.insertBefore(r,t):p&&e.removeChild(l)}else s=!0}}else e.insertBefore(r,t);return[r]}var nt={button:"_button_1dv9o_1",primary:"_primary_1dv9o_18"};const zt=V("<button></button>"),it=e=>(()=>{const n=zt.cloneNode(!0);return Re(n,"click",e.onClick,!0),M(n,()=>e.children),q(t=>{const i={[nt.button]:!0,[nt.primary]:e.type==="primary"},r=e.disabled,s=e.style;return t._v$=Bt(n,i,t._v$),r!==t._v$2&&(n.disabled=t._v$2=r),t._v$3=Pt(n,s,t._v$3),t},{_v$:void 0,_v$2:void 0,_v$3:void 0}),n})();ue(["click"]);var $e={root:"_root_1nuhb_1",loading:"_loading_1nuhb_5",tracking:"_tracking_1nuhb_19",title:"_title_1nuhb_23",content:"_content_1nuhb_37"},de=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ht(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var rt={exports:{}},st={exports:{}};(function(e,n){(function(t,i){e.exports=i()})(de,function(){var t=t||function(i,r){var s;if(typeof window!="undefined"&&window.crypto&&(s=window.crypto),typeof self!="undefined"&&self.crypto&&(s=self.crypto),typeof globalThis!="undefined"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window!="undefined"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof de!="undefined"&&de.crypto&&(s=de.crypto),!s&&typeof Ht=="function")try{s=require("crypto")}catch(o){}var d=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch(o){}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch(o){}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function o(){}return function(c){var y;return o.prototype=c,y=new o,o.prototype=null,y}}(),p={},a=p.lib={},u=a.Base=function(){return{extend:function(o){var c=l(this);return o&&c.mixIn(o),(!c.hasOwnProperty("init")||this.init===c.init)&&(c.init=function(){c.$super.init.apply(this,arguments)}),c.init.prototype=c,c.$super=this,c},create:function(){var o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(o){for(var c in o)o.hasOwnProperty(c)&&(this[c]=o[c]);o.hasOwnProperty("toString")&&(this.toString=o.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),S=a.WordArray=u.extend({init:function(o,c){o=this.words=o||[],c!=r?this.sigBytes=c:this.sigBytes=o.length*4},toString:function(o){return(o||A).stringify(this)},concat:function(o){var c=this.words,y=o.words,$=this.sigBytes,k=o.sigBytes;if(this.clamp(),$%4)for(var N=0;N<k;N++){var L=y[N>>>2]>>>24-N%4*8&255;c[$+N>>>2]|=L<<24-($+N)%4*8}else for(var x=0;x<k;x+=4)c[$+x>>>2]=y[x>>>2];return this.sigBytes+=k,this},clamp:function(){var o=this.words,c=this.sigBytes;o[c>>>2]&=4294967295<<32-c%4*8,o.length=i.ceil(c/4)},clone:function(){var o=u.clone.call(this);return o.words=this.words.slice(0),o},random:function(o){for(var c=[],y=0;y<o;y+=4)c.push(d());return new S.init(c,o)}}),w=p.enc={},A=w.Hex={stringify:function(o){for(var c=o.words,y=o.sigBytes,$=[],k=0;k<y;k++){var N=c[k>>>2]>>>24-k%4*8&255;$.push((N>>>4).toString(16)),$.push((N&15).toString(16))}return $.join("")},parse:function(o){for(var c=o.length,y=[],$=0;$<c;$+=2)y[$>>>3]|=parseInt(o.substr($,2),16)<<24-$%8*4;return new S.init(y,c/2)}},b=w.Latin1={stringify:function(o){for(var c=o.words,y=o.sigBytes,$=[],k=0;k<y;k++){var N=c[k>>>2]>>>24-k%4*8&255;$.push(String.fromCharCode(N))}return $.join("")},parse:function(o){for(var c=o.length,y=[],$=0;$<c;$++)y[$>>>2]|=(o.charCodeAt($)&255)<<24-$%4*8;return new S.init(y,c)}},m=w.Utf8={stringify:function(o){try{return decodeURIComponent(escape(b.stringify(o)))}catch(c){throw new Error("Malformed UTF-8 data")}},parse:function(o){return b.parse(unescape(encodeURIComponent(o)))}},f=a.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new S.init,this._nDataBytes=0},_append:function(o){typeof o=="string"&&(o=m.parse(o)),this._data.concat(o),this._nDataBytes+=o.sigBytes},_process:function(o){var c,y=this._data,$=y.words,k=y.sigBytes,N=this.blockSize,L=N*4,x=k/L;o?x=i.ceil(x):x=i.max((x|0)-this._minBufferSize,0);var T=x*N,B=i.min(T*4,k);if(T){for(var O=0;O<T;O+=N)this._doProcessBlock($,O);c=$.splice(0,T),y.sigBytes-=B}return new S.init(c,B)},clone:function(){var o=u.clone.call(this);return o._data=this._data.clone(),o},_minBufferSize:0});a.Hasher=f.extend({cfg:u.extend(),init:function(o){this.cfg=this.cfg.extend(o),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(o){return this._append(o),this._process(),this},finalize:function(o){o&&this._append(o);var c=this._doFinalize();return c},blockSize:512/32,_createHelper:function(o){return function(c,y){return new o.init(y).finalize(c)}},_createHmacHelper:function(o){return function(c,y){return new C.HMAC.init(o,y).finalize(c)}}});var C=p.algo={};return p}(Math);return t})})(st),function(e,n){(function(t,i){e.exports=i(st.exports)})(de,function(t){return function(i){var r=t,s=r.lib,d=s.WordArray,l=s.Hasher,p=r.algo,a=[];(function(){for(var m=0;m<64;m++)a[m]=i.abs(i.sin(m+1))*4294967296|0})();var u=p.MD5=l.extend({_doReset:function(){this._hash=new d.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(m,f){for(var C=0;C<16;C++){var o=f+C,c=m[o];m[o]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360}var y=this._hash.words,$=m[f+0],k=m[f+1],N=m[f+2],L=m[f+3],x=m[f+4],T=m[f+5],B=m[f+6],O=m[f+7],Z=m[f+8],P=m[f+9],ee=m[f+10],W=m[f+11],ke=m[f+12],Ce=m[f+13],Ne=m[f+14],Ae=m[f+15],g=y[0],h=y[1],_=y[2],v=y[3];g=S(g,h,_,v,$,7,a[0]),v=S(v,g,h,_,k,12,a[1]),_=S(_,v,g,h,N,17,a[2]),h=S(h,_,v,g,L,22,a[3]),g=S(g,h,_,v,x,7,a[4]),v=S(v,g,h,_,T,12,a[5]),_=S(_,v,g,h,B,17,a[6]),h=S(h,_,v,g,O,22,a[7]),g=S(g,h,_,v,Z,7,a[8]),v=S(v,g,h,_,P,12,a[9]),_=S(_,v,g,h,ee,17,a[10]),h=S(h,_,v,g,W,22,a[11]),g=S(g,h,_,v,ke,7,a[12]),v=S(v,g,h,_,Ce,12,a[13]),_=S(_,v,g,h,Ne,17,a[14]),h=S(h,_,v,g,Ae,22,a[15]),g=w(g,h,_,v,k,5,a[16]),v=w(v,g,h,_,B,9,a[17]),_=w(_,v,g,h,W,14,a[18]),h=w(h,_,v,g,$,20,a[19]),g=w(g,h,_,v,T,5,a[20]),v=w(v,g,h,_,ee,9,a[21]),_=w(_,v,g,h,Ae,14,a[22]),h=w(h,_,v,g,x,20,a[23]),g=w(g,h,_,v,P,5,a[24]),v=w(v,g,h,_,Ne,9,a[25]),_=w(_,v,g,h,L,14,a[26]),h=w(h,_,v,g,Z,20,a[27]),g=w(g,h,_,v,Ce,5,a[28]),v=w(v,g,h,_,N,9,a[29]),_=w(_,v,g,h,O,14,a[30]),h=w(h,_,v,g,ke,20,a[31]),g=A(g,h,_,v,T,4,a[32]),v=A(v,g,h,_,Z,11,a[33]),_=A(_,v,g,h,W,16,a[34]),h=A(h,_,v,g,Ne,23,a[35]),g=A(g,h,_,v,k,4,a[36]),v=A(v,g,h,_,x,11,a[37]),_=A(_,v,g,h,O,16,a[38]),h=A(h,_,v,g,ee,23,a[39]),g=A(g,h,_,v,Ce,4,a[40]),v=A(v,g,h,_,$,11,a[41]),_=A(_,v,g,h,L,16,a[42]),h=A(h,_,v,g,B,23,a[43]),g=A(g,h,_,v,P,4,a[44]),v=A(v,g,h,_,ke,11,a[45]),_=A(_,v,g,h,Ae,16,a[46]),h=A(h,_,v,g,N,23,a[47]),g=b(g,h,_,v,$,6,a[48]),v=b(v,g,h,_,O,10,a[49]),_=b(_,v,g,h,Ne,15,a[50]),h=b(h,_,v,g,T,21,a[51]),g=b(g,h,_,v,ke,6,a[52]),v=b(v,g,h,_,L,10,a[53]),_=b(_,v,g,h,ee,15,a[54]),h=b(h,_,v,g,k,21,a[55]),g=b(g,h,_,v,Z,6,a[56]),v=b(v,g,h,_,Ae,10,a[57]),_=b(_,v,g,h,B,15,a[58]),h=b(h,_,v,g,Ce,21,a[59]),g=b(g,h,_,v,x,6,a[60]),v=b(v,g,h,_,W,10,a[61]),_=b(_,v,g,h,N,15,a[62]),h=b(h,_,v,g,P,21,a[63]),y[0]=y[0]+g|0,y[1]=y[1]+h|0,y[2]=y[2]+_|0,y[3]=y[3]+v|0},_doFinalize:function(){var m=this._data,f=m.words,C=this._nDataBytes*8,o=m.sigBytes*8;f[o>>>5]|=128<<24-o%32;var c=i.floor(C/4294967296),y=C;f[(o+64>>>9<<4)+15]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360,f[(o+64>>>9<<4)+14]=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360,m.sigBytes=(f.length+1)*4,this._process();for(var $=this._hash,k=$.words,N=0;N<4;N++){var L=k[N];k[N]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360}return $},clone:function(){var m=l.clone.call(this);return m._hash=this._hash.clone(),m}});function S(m,f,C,o,c,y,$){var k=m+(f&C|~f&o)+c+$;return(k<<y|k>>>32-y)+f}function w(m,f,C,o,c,y,$){var k=m+(f&o|C&~o)+c+$;return(k<<y|k>>>32-y)+f}function A(m,f,C,o,c,y,$){var k=m+(f^C^o)+c+$;return(k<<y|k>>>32-y)+f}function b(m,f,C,o,c,y,$){var k=m+(C^(f|~o))+c+$;return(k<<y|k>>>32-y)+f}r.MD5=l._createHelper(u),r.HmacMD5=l._createHmacHelper(u)}(Math),t.MD5})}(rt);var Yt=rt.exports;const[se,Ut]=X([]),[ot,qt]=X([]),[He,lt]=X(new Map),[Zt,Ft]=X([]),[Ye,Vt]=X("");function ge(){return te(this,null,function*(){var n;const e=((n=document.querySelector("#aftership_get_nonce"))==null?void 0:n.value)||"";yield fetch(`/wp-admin/admin-ajax.php?action=aftership_get_order_trackings&security=${e}&order_id=${window.woocommerce_admin_meta_boxes.post_id}`).then(t=>t.json()).then(t=>{const i=t.data,r=window.get_aftership_couriers(),s=new Map;i.trackings.forEach(d=>{if(s.has(d.slug))return;const l=r.find(p=>p.slug===d.slug);l&&s.set(d.slug,l)}),lt(d=>new Map([...d,...s])),Ut(i.trackings),Ft(i.line_items)})})}function Gt(e){return te(this,null,function*(){var l;const n=se().find(p=>p.tracking_id===e.tracking_id),t=se().findIndex(p=>p.tracking_id===e.tracking_id),i=new Date().toISOString().replace(/\.\d+(?=Z$)/,""),r=e.slug!==(n==null?void 0:n.slug)||e.tracking_number!==(n==null?void 0:n.tracking_number);let s=[...se()];n&&!r?s.splice(t,1,z(R({},e),{metrics:{created_at:n.metrics.created_at||i,updated_at:i}})):s=[...s.filter(p=>p.tracking_id!==e.tracking_id),z(R({},e),{tracking_id:Yt(`${e.slug}-${e.tracking_number}`).toString(),metrics:{created_at:i,updated_at:i}})];const d=((l=document.querySelector("#aftership_create_nonce"))==null?void 0:l.value)||"";yield fetch(`/wp-admin/admin-ajax.php?action=aftership_save_order_tracking&security=${d}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({order_id:window.woocommerce_admin_meta_boxes.post_id,trackings:s})}),yield ge()})}function Wt(e){return te(this,null,function*(){var t;const n=((t=document.querySelector("#aftership_delete_nonce"))==null?void 0:t.value)||"";yield fetch(`/wp-admin/admin-ajax.php?action=aftership_delete_order_tracking&security=${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({order_id:window.woocommerce_admin_meta_boxes.post_id,tracking_id:e})}),yield ge()})}function Qt(){return te(this,null,function*(){yield fetch("/wp-admin/admin-ajax.php?action=aftership_get_settings").then(e=>e.json()).then(e=>{const n=e.data.couriers,t=new Map(He());n.forEach(i=>{t.set(i.slug,i)}),lt(i=>new Map([...i,...t])),qt(n),Vt(e.data.custom_domain)})})}var Jt=typeof global=="object"&&global&&global.Object===Object&&global,Kt=Jt,Xt=typeof self=="object"&&self&&self.Object===Object&&self,en=Kt||Xt||Function("return this")(),tn=en,nn=tn.Symbol,oe=nn,at=Object.prototype,rn=at.hasOwnProperty,sn=at.toString,he=oe?oe.toStringTag:void 0;function on(e){var n=rn.call(e,he),t=e[he];try{e[he]=void 0;var i=!0}catch(s){}var r=sn.call(e);return i&&(n?e[he]=t:delete e[he]),r}var ln=Object.prototype,an=ln.toString;function cn(e){return an.call(e)}var un="[object Null]",fn="[object Undefined]",ct=oe?oe.toStringTag:void 0;function dn(e){return e==null?e===void 0?fn:un:ct&&ct in Object(e)?on(e):cn(e)}function gn(e){return e!=null&&typeof e=="object"}var hn="[object Symbol]";function _n(e){return typeof e=="symbol"||gn(e)&&dn(e)==hn}function vn(e,n){for(var t=-1,i=e==null?0:e.length,r=Array(i);++t<i;)r[t]=n(e[t],t,e);return r}var mn=Array.isArray,yn=mn,bn=1/0,ut=oe?oe.prototype:void 0,ft=ut?ut.toString:void 0;function dt(e){if(typeof e=="string")return e;if(yn(e))return vn(e,dt)+"";if(_n(e))return ft?ft.call(e):"";var n=e+"";return n=="0"&&1/e==-bn?"-0":n}function gt(e){return e==null?"":dt(e)}function pn(e,n,t){var i=-1,r=e.length;n<0&&(n=-n>r?0:r+n),t=t>r?r:t,t<0&&(t+=r),r=n>t?0:t-n>>>0,n>>>=0;for(var s=Array(r);++i<r;)s[i]=e[i+n];return s}function $n(e,n,t){var i=e.length;return t=t===void 0?i:t,!n&&t>=i?e:pn(e,n,t)}var wn="\\ud800-\\udfff",xn="\\u0300-\\u036f",Sn="\\ufe20-\\ufe2f",kn="\\u20d0-\\u20ff",Cn=xn+Sn+kn,Nn="\\ufe0e\\ufe0f",An="\\u200d",In=RegExp("["+An+wn+Cn+Nn+"]");function ht(e){return In.test(e)}function Tn(e){return e.split("")}var _t="\\ud800-\\udfff",jn="\\u0300-\\u036f",Mn="\\ufe20-\\ufe2f",En="\\u20d0-\\u20ff",Dn=jn+Mn+En,Ln="\\ufe0e\\ufe0f",On="["+_t+"]",Ue="["+Dn+"]",qe="\\ud83c[\\udffb-\\udfff]",Bn="(?:"+Ue+"|"+qe+")",vt="[^"+_t+"]",mt="(?:\\ud83c[\\udde6-\\uddff]){2}",yt="[\\ud800-\\udbff][\\udc00-\\udfff]",Pn="\\u200d",bt=Bn+"?",pt="["+Ln+"]?",Rn="(?:"+Pn+"(?:"+[vt,mt,yt].join("|")+")"+pt+bt+")*",zn=pt+bt+Rn,Hn="(?:"+[vt+Ue+"?",Ue,mt,yt,On].join("|")+")",Yn=RegExp(qe+"(?="+qe+")|"+Hn+zn,"g");function Un(e){return e.match(Yn)||[]}function qn(e){return ht(e)?Un(e):Tn(e)}function Zn(e){return function(n){n=gt(n);var t=ht(n)?qn(n):void 0,i=t?t[0]:n.charAt(0),r=t?$n(t,1).join(""):n.slice(1);return i[e]()+r}}var Fn=Zn("toUpperCase"),Vn=Fn;function Gn(e){return Vn(gt(e).toLowerCase())}var we={container:"_container_1s8av_1",backdrop:"_backdrop_1s8av_8",modal:"_modal_1s8av_15"},Wn="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmkteCIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBmaWxsPSIjNjY2IiBkPSJNNC42NDYgNC42NDZhLjUuNSAwIDAgMSAuNzA4IDBMOCA3LjI5M2wyLjY0Ni0yLjY0N2EuNS41IDAgMCAxIC43MDguNzA4TDguNzA3IDhsMi42NDcgMi42NDZhLjUuNSAwIDAgMS0uNzA4LjcwOEw4IDguNzA3bC0yLjY0NiAyLjY0N2EuNS41IDAgMCAxLS43MDgtLjcwOEw3LjI5MyA4IDQuNjQ2IDUuMzU0YS41LjUgMCAwIDEgMC0uNzA4eiIvPgo8L3N2Zz4=";const Qn=V('<div><div></div><section><header><h1></h1><div role="button"><img></div></header><article></article><footer></footer></section></div>');function Jn(e){return Te(()=>{e.visible?document.body.style.overflowY="hidden":document.body.style.overflowY="auto"}),U(Pe,{get when(){return e.visible},get children(){const n=Qn.cloneNode(!0),t=n.firstChild,i=t.nextSibling,r=i.firstChild,s=r.firstChild,d=s.nextSibling,l=d.firstChild,p=r.nextSibling,a=p.nextSibling;return Re(t,"click",e.onCancel,!0),M(s,()=>e.title),Re(d,"click",e.onCancel,!0),ne(l,"src",Wn),M(p,()=>e.children),M(a,U(it,{get disabled(){return e.disabled},onClick:()=>e.onOk&&e.onOk(),type:"primary",get children(){return e.okText||"Ok"}})),q(u=>{const S=we.container,w=we.backdrop,A=we.modal,b=we.header;return S!==u._v$&&(n.className=u._v$=S),w!==u._v$2&&(t.className=u._v$2=w),A!==u._v$3&&(i.className=u._v$3=A),b!==u._v$4&&(r.className=u._v$4=b),u},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0}),n}})}ue(["click"]);var Ze={root:"_root_b92ih_1",suffix:"_suffix_b92ih_25",action:"_action_b92ih_30"},Kn="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktY2FyZXQtdXAtZmlsbCIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBmaWxsPSIjNWM1ZjYyIiBkPSJtNy4yNDcgNC44Ni00Ljc5NiA1LjQ4MWMtLjU2Ni42NDctLjEwNiAxLjY1OS43NTMgMS42NTloOS41OTJhMSAxIDAgMCAwIC43NTMtMS42NTlsLTQuNzk2LTUuNDhhMSAxIDAgMCAwLTEuNTA2IDB6Ii8+Cjwvc3ZnPg==",Xn="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktY2FyZXQtZG93bi1maWxsIiB2aWV3Qm94PSIwIDAgMTYgMTYiPgogIDxwYXRoIGZpbGw9IiM1YzVmNjIiIGQ9Ik03LjI0NyAxMS4xNCAyLjQ1MSA1LjY1OEMxLjg4NSA1LjAxMyAyLjM0NSA0IDMuMjA0IDRoOS41OTJhMSAxIDAgMCAxIC43NTMgMS42NTlsLTQuNzk2IDUuNDhhMSAxIDAgMCAxLTEuNTA2IDB6Ii8+Cjwvc3ZnPg==";const ei=V("<div>of </div>"),ti=V('<div><div><input type="number" inputmode="numeric"></div><div aria-hidden><div role="button" tabindex="-1"><img></div><div role="button" tabindex="-1"><img></div></div></div>');function ni(e){let n;const t=Et({step:1},e);function i(p){return t.min!==void 0&&Number(p)<t.min}function r(p){return t.max!==void 0&&Number(p)>t.max}function s(p){!p||i(p)||r(p)||t.onChange(Number(p))}function d(p){if(p)if(i(p)){t.onChange(t.min),n.value=String(t.min);return}else if(r(p)){t.onChange(t.max),n.value=String(t.max);return}else t.onChange(Number(p));else n.value="",t.onChange(void 0)}function l(p){const a=t.value;let u;if(a===void 0)u=p>0?t.min:t.max,t.onChange(u||0);else{u=a+p*t.step;const S=String(u);if(i(S)||r(S))return}t.onChange(u)}return(()=>{const p=ti.cloneNode(!0),a=p.firstChild,u=a.firstChild,S=a.nextSibling,w=S.firstChild,A=w.firstChild,b=w.nextSibling,m=b.firstChild;return u.addEventListener("blur",f=>d(f.currentTarget.value)),u.$$input=f=>s(f.currentTarget.value),(f=>n=f)(u),M(p,U(Pe,{get when(){return t.max!==void 0},get children(){const f=ei.cloneNode(!0);return f.firstChild,f.$$click=()=>n.focus(),M(f,()=>t.max,null),q(()=>f.className=Ze.suffix),f}}),S),w.$$click=()=>l(1),ne(A,"src",Kn),b.$$click=()=>l(-1),ne(m,"src",Xn),q(f=>{const C=Ze.root,o=t.min,c=t.max,y=t.value,$=Ze.action;return C!==f._v$&&(p.className=f._v$=C),o!==f._v$2&&ne(u,"min",f._v$2=o),c!==f._v$3&&ne(u,"max",f._v$3=c),y!==f._v$4&&(u.value=f._v$4=y),$!==f._v$5&&(S.className=f._v$5=$),f},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0,_v$5:void 0}),p})()}ue(["input","click"]);var xe={modal:"_modal_kfzs9_1",empty:"_empty_kfzs9_5",items:"_items_kfzs9_11",input:"_input_kfzs9_32"};function ii(e){const n=new Map;return e.forEach(i=>{var r;(r=i.line_items)==null||r.forEach(s=>{n.has(Number(s.id))?n.set(Number(s.id),(n.get(Number(s.id))||0)+Number(s.quantity)):n.set(Number(s.id),Number(s.quantity))})}),Zt().map(i=>{const r=n.get(i.id)||0;return{id:i.id,name:i.name,quantity:i.quantity-r}}).filter(i=>i.quantity>0)}const ri=V("<table><thead><tr><th>Items</th><th>Qty.</th></tr></thead><tbody></tbody></table>"),si=V('<div style="color: red;"></div>'),oi=V('<div><hr><div><div><label>Courier:<select></select></label><a href="admin.php?page=aftership-setting-admin">Update carrier list</a></div><div><label>Tracking number:<input></label></div></div></div>'),li=V("<div>All items have been fulfilled</div>"),ai=V("<tr><td></td><td></td></tr>"),ci=V("<option></option>"),ui=V("<div><label>:<input></label></div>"),Se={tracking_id:"",tracking_number:"",slug:"",additional_fields:{account_number:"",key:"",postal_code:"",ship_date:"",destination_country:"",state:""},line_items:{}};function fi(e){const[n,t]=X(Se),i=F(()=>n().slug||""),r=F(()=>{var m;return(((m=He().get(i()))==null?void 0:m.required_fields)||[]).map(f=>({key:f.replace(/^tracking_/,""),name:f.replace(/^tracking_/,"").split("_").map(Gn).join(" ")}))}),s=F(()=>e.value?se().filter(b=>{var m;return b.tracking_id!==((m=e.value)==null?void 0:m.tracking_id)}):se()),d=F(()=>s().length),l=F(()=>ii(s()));Te(()=>{var f,C,o;const b=new Date().toISOString().split("T")[0],m=((f=e.value)==null?void 0:f.line_items)||[];e.value?e.value.line_items?t({tracking_id:e.value.tracking_id,slug:e.value.slug,tracking_number:e.value.tracking_number,additional_fields:z(R({},e.value.additional_fields),{ship_date:e.value.additional_fields.ship_date||b}),line_items:Object.fromEntries(m.map(c=>[Number(c.id),Number(c.quantity)]))}):d()?t({tracking_id:e.value.tracking_id,slug:e.value.slug,tracking_number:e.value.tracking_number,additional_fields:z(R({},e.value.additional_fields),{ship_date:e.value.additional_fields.ship_date||b}),line_items:Object.fromEntries(l().map(c=>[Number(c.id),0]))}):t({tracking_id:e.value.tracking_id,slug:e.value.slug,tracking_number:e.value.tracking_number,additional_fields:z(R({},e.value.additional_fields),{ship_date:e.value.additional_fields.ship_date||b}),line_items:Object.fromEntries(l().map(c=>[Number(c.id),Number(c.quantity)]))}):t(z(R({},Se),{slug:((o=(C=ot())==null?void 0:C[0])==null?void 0:o.slug)||"",additional_fields:z(R({},Se.additional_fields),{ship_date:b}),line_items:Object.fromEntries(l().map(c=>[Number(c.id),Number(c.quantity)]))}))});const p=()=>{t(b=>{const m=new Date().toISOString().split("T")[0];return z(R({},b),{additional_fields:z(R({},Se.additional_fields),{ship_date:m})})})},a=F(()=>{let b=!0;const m={};return Object.entries(n().line_items||[]).some(([,C])=>!!C)||(b=!1),n().slug===""&&(b=!1,m.slug="Required"),n().tracking_number===""&&(b=!1),s().some(C=>C.slug===n().slug&&C.tracking_number===n().tracking_number)&&(b=!1,m.tracking_number="This shipment has already been added."),r().forEach(C=>{n().additional_fields[C.key]===""&&(b=!1,m.additional_fields=z(R({},m.additional_fields),{[C.key]:"Required"}))}),{isValid:b,errors:m}}),u=(b,m)=>{console.log("handleLineItemChange"),t(f=>z(R({},f),{line_items:z(R({},f.line_items),{[b]:m})}))},S=(b,m)=>{t(f=>z(R({},f),{[b]:m.trim()}))},w=(b,m)=>{t(f=>z(R({},f),{additional_fields:z(R({},f.additional_fields),{[b]:m.trim()})}))};return U(Jn,{get title(){var b;return((b=e.value)==null?void 0:b.tracking_id)?"Edit tracking":"Add tracking"},get visible(){return e.visible},get okText(){var b;return((b=e.value)==null?void 0:b.tracking_id)?"Save":"Add"},onOk:()=>e.onOk(n()),get onCancel(){return e.onCancel},get disabled(){return!a().isValid},get children(){const b=oi.cloneNode(!0),m=b.firstChild,f=m.nextSibling,C=f.firstChild,o=C.firstChild,c=o.firstChild,y=c.nextSibling,$=C.nextSibling,k=$.firstChild,N=k.firstChild,L=N.nextSibling;return M(b,U(Dt,{get fallback(){return(()=>{const x=li.cloneNode(!0);return q(()=>x.className=xe.empty),x})()},get children(){return U(Lt,{get when(){return l().length>0},get children(){const x=ri.cloneNode(!0),T=x.firstChild,B=T.nextSibling;return M(B,U(be,{get each(){return l()},children:O=>(()=>{const Z=ai.cloneNode(!0),P=Z.firstChild,ee=P.nextSibling;return M(P,()=>O.name),M(ee,U(ni,{min:0,get max(){return O.quantity},step:1,get value(){var W;return((W=n().line_items)==null?void 0:W[O.id])||0},onChange:W=>u(O.id,W||0)})),Z})()})),q(()=>x.className=xe.items),x}})}}),m),m.style.setProperty("margin","20px 0"),y.addEventListener("change",x=>{p(),S("slug",x.currentTarget.value)}),M(y,U(be,{get each(){return ot()},children:x=>(()=>{const T=ci.cloneNode(!0);return M(T,()=>x.name||x.other_name),q(()=>T.value=x.slug),T})()})),L.$$input=x=>S("tracking_number",x.currentTarget.value),M($,U(Pe,{get when(){return a().errors.tracking_number},get children(){const x=si.cloneNode(!0);return M(x,()=>a().errors.tracking_number),x}}),null),M(f,U(be,{get each(){return r()},children:x=>(()=>{const T=ui.cloneNode(!0),B=T.firstChild,O=B.firstChild,Z=O.nextSibling;return M(B,()=>x.name,O),Z.$$input=P=>w(x.key,P.currentTarget.value),q(P=>{const ee=x.key==="ship_date"?"date":"text",W=n().additional_fields[x.key];return ee!==P._v$5&&ne(Z,"type",P._v$5=ee),W!==P._v$6&&(Z.value=P._v$6=W),P},{_v$5:void 0,_v$6:void 0}),T})()}),null),q(x=>{var P;const T=xe.modal,B=xe.input,O=(P=n())==null?void 0:P.slug,Z=n().tracking_number;return T!==x._v$&&(b.className=x._v$=T),B!==x._v$2&&(f.className=x._v$2=B),O!==x._v$3&&(y.value=x._v$3=O),Z!==x._v$4&&(L.value=x._v$4=Z),x},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0}),b}})}ue(["input"]);const di=V("<div><div></div><div></div></div>"),gi=V('<div><div><div>Shipment </div><div><a>Edit</a><a>Delete</a></div></div><div><div><strong></strong></div><div><a target="_blank"></a></div></div></div>'),hi=()=>{const[e,n]=X(!1),[t,i]=X();St(()=>{ge(),Qt()});const r=l=>te(this,null,function*(){const p=l.line_items||{};yield Gt(z(R({},l),{line_items:Object.entries(p).map(([a,u])=>({id:Number(a),quantity:u})).filter(a=>a.quantity>0)})),n(!1),i(void 0)}),s=()=>{n(!1),i(void 0)},d=l=>/^https?:\/\//.test(Ye())?`${Ye()}/${l.slug}/${l.tracking_number}`:`https://${Ye()}/${l.slug}/${l.tracking_number}`;return(()=>{const l=di.cloneNode(!0),p=l.firstChild,a=p.nextSibling;return M(p,U(be,{get each(){return se()},children:(u,S)=>(()=>{const w=gi.cloneNode(!0),A=w.firstChild,b=A.firstChild;b.firstChild;const m=b.nextSibling,f=m.firstChild,C=f.nextSibling,o=A.nextSibling,c=o.firstChild,y=c.firstChild,$=c.nextSibling,k=$.firstChild;return M(b,()=>S()+1,null),f.$$click=()=>te(this,null,function*(){yield ge(),i(u),n(!0)}),C.$$click=()=>Wt(u.tracking_id),M(y,()=>{var N;return((N=He().get(u.slug))==null?void 0:N.name)||u.slug}),M(k,()=>u.tracking_number),q(N=>{const L=$e.tracking,x=$e.title,T=$e.content,B=d(u);return L!==N._v$&&(w.className=N._v$=L),x!==N._v$2&&(A.className=N._v$2=x),T!==N._v$3&&(o.className=N._v$3=T),B!==N._v$4&&ne(k,"href",N._v$4=B),N},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0}),w})()})),a.style.setProperty("padding","12px"),M(a,U(it,{onClick:()=>te(this,null,function*(){yield ge(),n(!0)}),style:{width:"100%"},children:"Add Tracking Number"})),M(l,U(fi,{get visible(){return e()},get value(){return t()},onCancel:s,onOk:r}),null),q(()=>l.className=$e.root),l})()};ue(["click"]);var Bi="";console.log("src/index.js"),customElements.define("aftership-meta-box",class extends HTMLElement{constructor(){super();wt(this,"initialized",!1);this.attachShadow({mode:"open"})}connectedCallback(){if(!!this.shadowRoot&&!this.initialized){this.initialized=!0;{const n=document.createElement("link");n.rel="stylesheet",n.href="/wp-content/plugins/aftership-woocommerce-tracking/assets/meta-box/dist/style.css",this.shadowRoot.appendChild(n)}Ot(()=>U(hi,{}),this.shadowRoot)}}})})();
|
assets/meta-box/dist/style.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
._button_1dv9o_1{border:1px solid #ccc;border-radius:3px;background-color:#f7f7f7;color:#555;font-size:13px;min-height:30px;padding:0 10px;cursor:pointer}._button_1dv9o_1[disabled]{color:#a7aaad!important;background:#f6f7f7!important;border-color:#dcdcde!important;cursor:not-allowed}._primary_1dv9o_18{border-color:#2271b1;background:#2271b1;color:#fff}._primary_1dv9o_18:hover{background:#135e96;border-color:#135e96}._root_1nuhb_1{position:relative}._loading_1nuhb_5{position:absolute;height:100%;width:100%;top:0;left:0;background:#fff;opacity:.6;pointer-events:none;display:flex;align-items:center;justify-content:center}._tracking_1nuhb_19{padding:16px 12px;border-bottom:1px solid #eeeeee}._tracking_1nuhb_19 ._title_1nuhb_23{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;color:#5f5f5f}._tracking_1nuhb_19 ._title_1nuhb_23 a{font-size:12px}._tracking_1nuhb_19 ._title_1nuhb_23 a:nth-child(2){color:#a00;margin-left:12px}._tracking_1nuhb_19 ._content_1nuhb_37{background-color:#f6f6f6;padding:12px;font-size:14px;line-height:1.43;word-break:break-all;display:flex;flex-direction:column}._tracking_1nuhb_19 ._content_1nuhb_37 a{text-decoration:none}._tracking_1nuhb_19 ._content_1nuhb_37 strong{font-weight:600;color:#3c434a}._container_1s8av_1{position:fixed;top:0;right:0;z-index:99999}._backdrop_1s8av_8{width:100vw;height:100vh;background-color:#000;opacity:.7}._modal_1s8av_15{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background-color:#fff;width:500px}._modal_1s8av_15 header{background:#fcfcfc;padding:1em 1.5em;border-bottom:1px solid #ddd}._modal_1s8av_15 header h1{margin:0;font-size:18px;font-weight:700;line-height:1.5em}._modal_1s8av_15 header div{position:absolute;top:0;right:0;width:54px;height:54px;display:flex;align-items:center;justify-content:center;cursor:pointer;border-left:1px solid #ddd;color:#666}._modal_1s8av_15 header div:hover{background:#ddd;border-color:#ccc}._modal_1s8av_15 header img{height:32px;width:32px}._modal_1s8av_15 footer{padding:1em 1.5em;background:#fcfcfc;border-top:1px solid #dfdfdf;box-shadow:0 -4px 4px -4px #0000001a;display:flex;justify-content:flex-end}._root_b92ih_1{display:flex;align-items:center;justify-content:space-between;border:1px solid #8c8f94;border-radius:4px;height:30px;overflow:hidden}._root_b92ih_1 input{line-height:26px;border:0;padding-left:8px}._root_b92ih_1 input:focus{outline:0}._root_b92ih_1 input[type=number]::-webkit-outer-spin-button,._root_b92ih_1 input[type=number]::-webkit-inner-spin-button{appearance:none;margin:0}._root_b92ih_1 input[type=number]{appearance:textfield}._root_b92ih_1 ._suffix_b92ih_25{color:#6c7075;margin-right:8px;cursor:default}._root_b92ih_1 ._action_b92ih_30{width:22px;padding:2px;height:100%;display:grid;row-gap:2px}._root_b92ih_1 ._action_b92ih_30 div{border-radius:2px;background-color:#e4e5e7;display:flex;align-items:center;justify-content:center;cursor:pointer}._root_b92ih_1 ._action_b92ih_30 div:hover{background-color:#c9cbcf}._root_b92ih_1 ._action_b92ih_30 div:active{background-color:#b3b5b9}._root_b92ih_1 ._action_b92ih_30 div img{width:10px;height:10px;user-select:none}._modal_kfzs9_1{padding:20px}._empty_kfzs9_5{text-align:center;font-size:16px;color:#999c9f}._items_kfzs9_11{display:grid;text-align:left;grid-template-columns:1fr auto;column-gap:10px;row-gap:6px;align-items:center}._items_kfzs9_11 thead,._items_kfzs9_11 tbody,._items_kfzs9_11 tr{display:contents}._items_kfzs9_11 th:last-child,._items_kfzs9_11 td:last-child{text-align:right}._items_kfzs9_11 th{margin-bottom:8px}._input_kfzs9_32{color:#3c434a;display:grid;grid-template-columns:1fr 1fr;column-gap:20px;row-gap:10px}._input_kfzs9_32 label{display:flex;flex-direction:column}._input_kfzs9_32 a{font-size:12px;text-decoration-line:underline;margin-left:2px;width:fit-content}._input_kfzs9_32 label{margin-left:2px}._input_kfzs9_32 select{border:1px solid #8c8f94;border-radius:4px;min-height:30px;font-size:14px;line-height:28px;padding:0 8px}._input_kfzs9_32 input{border:1px solid #8c8f94;border-radius:4px;font-size:14px;line-height:28px;padding:0 8px}/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}:host{all:initial;font-family:inherit;font-size:inherit}*{box-sizing:border-box}a{cursor:pointer;color:#2271b1;transition:color .5s ease-in-out}a:hover{color:#135e96}
|
includes/api/v4/class-aftership-api-orders.php
CHANGED
@@ -250,28 +250,14 @@ class AfterShip_API_V4_Orders extends AfterShip_API_V3_Orders {
|
|
250 |
}
|
251 |
|
252 |
$trackings = array();
|
|
|
|
|
253 |
// The function definition will be available after installing the aftership plugin.
|
254 |
-
if ( function_exists( 'order_post_meta_getter' ) ) {
|
255 |
-
|
256 |
-
if ( ! empty( $aftership_tracking_number ) ) {
|
257 |
-
$trackings[] = array(
|
258 |
-
'slug' => order_post_meta_getter( $order, 'aftership_tracking_provider' ),
|
259 |
-
'tracking_number' => $aftership_tracking_number,
|
260 |
-
'additional_fields' => array(
|
261 |
-
'account_number' => order_post_meta_getter( $order, 'aftership_tracking_account' ),
|
262 |
-
'key' => order_post_meta_getter( $order, 'aftership_tracking_key' ),
|
263 |
-
'postal_code' => order_post_meta_getter( $order, 'aftership_tracking_postal' ),
|
264 |
-
'ship_date' => order_post_meta_getter( $order, 'aftership_tracking_shipdate' ),
|
265 |
-
'destination_country' => order_post_meta_getter( $order, 'aftership_tracking_destination_country' ),
|
266 |
-
'state' => null,
|
267 |
-
'origin_country' => null,
|
268 |
-
),
|
269 |
-
);
|
270 |
-
}
|
271 |
-
|
272 |
// 兼容 wooCommerce 官方的 tracking 插件.
|
273 |
$woocommerce_tracking_arr = order_post_meta_getter( $order, 'wc_shipment_tracking_items' );
|
274 |
-
if (
|
275 |
foreach ( $woocommerce_tracking_arr as $trackingKey => $trackingVal ) {
|
276 |
$trackingInfo = $this->getTrackingInfoByShipmentTracking( $trackingVal );
|
277 |
$trackings[] = array(
|
@@ -290,7 +276,6 @@ class AfterShip_API_V4_Orders extends AfterShip_API_V3_Orders {
|
|
290 |
}
|
291 |
}
|
292 |
}
|
293 |
-
$tracking_items = aftership()->actions->get_tracking_items_for_api( $id );
|
294 |
$order_data['trackings'] = $this->uniquify_tracking_items( array_merge( $trackings, $tracking_items ) );
|
295 |
|
296 |
return apply_filters( 'aftership_api_order_response', $order_data, $order, $fields, $this->server );
|
250 |
}
|
251 |
|
252 |
$trackings = array();
|
253 |
+
// 获取 AfterShip 插件新、旧 tracking 数据
|
254 |
+
$tracking_items = aftership()->actions->get_tracking_items_for_api( $id );
|
255 |
// The function definition will be available after installing the aftership plugin.
|
256 |
+
if ( empty( $tracking_items ) && function_exists( 'order_post_meta_getter' ) ) {
|
257 |
+
// 此处删除了获取老插件获取tracking的方式, 重复逻辑,已废弃 [CNT-12278]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
// 兼容 wooCommerce 官方的 tracking 插件.
|
259 |
$woocommerce_tracking_arr = order_post_meta_getter( $order, 'wc_shipment_tracking_items' );
|
260 |
+
if ( ! empty( $woocommerce_tracking_arr ) ) {
|
261 |
foreach ( $woocommerce_tracking_arr as $trackingKey => $trackingVal ) {
|
262 |
$trackingInfo = $this->getTrackingInfoByShipmentTracking( $trackingVal );
|
263 |
$trackings[] = array(
|
276 |
}
|
277 |
}
|
278 |
}
|
|
|
279 |
$order_data['trackings'] = $this->uniquify_tracking_items( array_merge( $trackings, $tracking_items ) );
|
280 |
|
281 |
return apply_filters( 'aftership_api_order_response', $order_data, $order, $fields, $this->server );
|
includes/class-aftership-actions.php
CHANGED
@@ -173,37 +173,6 @@ class AfterShip_Actions {
|
|
173 |
|
174 |
$this->migrate();
|
175 |
|
176 |
-
$tracking_items = $this->get_tracking_items( $post->ID );
|
177 |
-
|
178 |
-
echo '<div id="tracking-items">';
|
179 |
-
$count = 1;
|
180 |
-
if ( count( $tracking_items ) > 0 ) {
|
181 |
-
foreach ( $tracking_items as $index => $tracking_item ) {
|
182 |
-
$this->display_html_tracking_item_for_meta_box( $post->ID, $tracking_item, $count );
|
183 |
-
$count++;
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
echo '</div>';
|
188 |
-
echo '<div class="show-form-btn-container" style="padding: 12px;">';
|
189 |
-
echo '<button class="button button-show-form" type="button">' . __( 'Add Tracking Number', 'aftership' ) . '</button>';
|
190 |
-
echo '</div>';
|
191 |
-
echo '<div id="aftership-tracking-form">';
|
192 |
-
echo '<p class="form-field aftership_tracking_slug_field">';
|
193 |
-
echo '<label for="aftership_tracking_slug">' . __( 'Courier:', 'aftership' ) . '</label>';
|
194 |
-
echo '<select id="aftership_tracking_slug" name="aftership_tracking_slug" class="chosen_select" style="width:100%;">';
|
195 |
-
foreach ( $GLOBALS['AfterShip']->selected_couriers as $courier ) {
|
196 |
-
echo '<option value="' . esc_attr( sanitize_title( $courier['slug'] ) ) . '">' . esc_html( $courier['name'] ) . '</option>';
|
197 |
-
}
|
198 |
-
echo '</select>';
|
199 |
-
echo '<a class="link-to-setting" href="admin.php?page=aftership-setting-admin">Update carrier list</a>';
|
200 |
-
echo '</p>';
|
201 |
-
|
202 |
-
$options = array();
|
203 |
-
foreach ( $GLOBALS['AfterShip']->selected_couriers as $courier ) {
|
204 |
-
$options[ sanitize_title( $courier['slug'] ) ] = $courier['name'];
|
205 |
-
}
|
206 |
-
|
207 |
woocommerce_wp_hidden_input(
|
208 |
array(
|
209 |
'id' => 'aftership_get_nonce',
|
@@ -225,135 +194,8 @@ class AfterShip_Actions {
|
|
225 |
)
|
226 |
);
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
'id' => 'aftership_tracking_id',
|
231 |
-
'value' => '',
|
232 |
-
)
|
233 |
-
);
|
234 |
-
|
235 |
-
woocommerce_wp_text_input(
|
236 |
-
array(
|
237 |
-
'id' => 'aftership_tracking_number',
|
238 |
-
'label' => __( 'Tracking number:', 'aftership' ),
|
239 |
-
'placeholder' => '',
|
240 |
-
'description' => '',
|
241 |
-
'value' => '',
|
242 |
-
)
|
243 |
-
);
|
244 |
-
|
245 |
-
woocommerce_wp_text_input(
|
246 |
-
array(
|
247 |
-
'id' => 'aftership_tracking_account_number',
|
248 |
-
'label' => __( 'Account number:', 'aftership' ),
|
249 |
-
'placeholder' => '',
|
250 |
-
'description' => '',
|
251 |
-
'value' => '',
|
252 |
-
)
|
253 |
-
);
|
254 |
-
|
255 |
-
woocommerce_wp_text_input(
|
256 |
-
array(
|
257 |
-
'id' => 'aftership_tracking_key',
|
258 |
-
'label' => __( 'Account key:', 'aftership' ),
|
259 |
-
'placeholder' => '',
|
260 |
-
'description' => '',
|
261 |
-
'value' => '',
|
262 |
-
)
|
263 |
-
);
|
264 |
-
|
265 |
-
woocommerce_wp_text_input(
|
266 |
-
array(
|
267 |
-
'id' => 'aftership_tracking_postal_code',
|
268 |
-
'label' => __( 'Postal code:', 'aftership' ),
|
269 |
-
'placeholder' => '',
|
270 |
-
'description' => '',
|
271 |
-
'value' => '',
|
272 |
-
)
|
273 |
-
);
|
274 |
-
|
275 |
-
woocommerce_wp_text_input(
|
276 |
-
array(
|
277 |
-
'id' => 'aftership_tracking_ship_date',
|
278 |
-
'label' => __( 'Date shipped:', 'aftership' ),
|
279 |
-
'placeholder' => date_i18n( __( 'Y-m-d', 'aftership' ), time() ),
|
280 |
-
'description' => '',
|
281 |
-
'class' => 'date-picker-field',
|
282 |
-
'value' => date_i18n( __( 'Y-m-d', 'aftership' ), current_time( 'timestamp' ) ),
|
283 |
-
)
|
284 |
-
);
|
285 |
-
|
286 |
-
woocommerce_wp_text_input(
|
287 |
-
array(
|
288 |
-
'id' => 'aftership_tracking_destination_country',
|
289 |
-
'label' => __( 'Ship Destination Country (ISO3):', 'aftership' ),
|
290 |
-
'placeholder' => '',
|
291 |
-
'description' => '',
|
292 |
-
'value' => '',
|
293 |
-
)
|
294 |
-
);
|
295 |
-
|
296 |
-
woocommerce_wp_text_input(
|
297 |
-
array(
|
298 |
-
'id' => 'aftership_tracking_state',
|
299 |
-
'label' => __( 'Ship State:', 'aftership' ),
|
300 |
-
'placeholder' => '',
|
301 |
-
'description' => '',
|
302 |
-
'value' => '',
|
303 |
-
)
|
304 |
-
);
|
305 |
-
|
306 |
-
echo '<div style="padding: 9px 0px 4px 0px;">';
|
307 |
-
echo '<button class="button button-primary button-save-form">' . __( 'Save', 'aftership' ) . '</button>';
|
308 |
-
echo '<button class="button button-cancel">' . __( 'Cancel', 'aftership' ) . '</button>';
|
309 |
-
echo '</div>';
|
310 |
-
|
311 |
-
echo '</div>';
|
312 |
-
|
313 |
-
$js = "
|
314 |
-
$('p.aftership_tracking_key_field').hide();
|
315 |
-
$('p.aftership_tracking_account_number_field').hide();
|
316 |
-
$('p.aftership_tracking_postal_code_field').hide();
|
317 |
-
$('p.aftership_tracking_ship_date_field').hide();
|
318 |
-
$('p.aftership_tracking_destination_country_field').hide();
|
319 |
-
$('p.aftership_tracking_state_field').hide();
|
320 |
-
jQuery('#aftership_tracking_slug').change( function() {
|
321 |
-
$('p.aftership_tracking_key_field').hide();
|
322 |
-
$('p.aftership_tracking_account_number_field').hide();
|
323 |
-
$('p.aftership_tracking_postal_code_field').hide();
|
324 |
-
$('p.aftership_tracking_ship_date_field').hide();
|
325 |
-
$('p.aftership_tracking_destination_country_field').hide();
|
326 |
-
$('p.aftership_tracking_state_field').hide();
|
327 |
-
var required_fields_mapping = {
|
328 |
-
tracking_key: 'aftership_tracking_key',
|
329 |
-
tracking_account_number: 'aftership_tracking_account_number',
|
330 |
-
tracking_postal_code: 'aftership_tracking_postal_code',
|
331 |
-
tracking_ship_date: 'aftership_tracking_ship_date',
|
332 |
-
tracking_destination_country: 'aftership_tracking_destination_country',
|
333 |
-
tracking_state: 'aftership_tracking_state',
|
334 |
-
};
|
335 |
-
var slug = jQuery( '#aftership_tracking_slug' ).val();
|
336 |
-
if (!slug) return;
|
337 |
-
var couriers = JSON.parse( decodeURIComponent( '" . rawurlencode( wp_json_encode( $GLOBALS['AfterShip']->selected_couriers ) ) . "' ) );
|
338 |
-
var courier = couriers.find(item => item.slug === slug);
|
339 |
-
var required_fields = courier.required_fields;
|
340 |
-
for (var field of required_fields) {
|
341 |
-
var field_name = required_fields_mapping[field];
|
342 |
-
$('p.' + field_name + '_field').show();
|
343 |
-
}
|
344 |
-
} ).change();";
|
345 |
-
|
346 |
-
if ( function_exists( 'wc_enqueue_js' ) ) {
|
347 |
-
wc_enqueue_js( $js );
|
348 |
-
} else {
|
349 |
-
WC()->add_inline_js( $js );
|
350 |
-
}
|
351 |
-
|
352 |
-
wp_enqueue_style( 'aftership_styles_chosen', aftership()->plugin_url . '/assets/plugin/chosen/chosen.min.css' );
|
353 |
-
wp_enqueue_script( 'aftership-js', $GLOBALS['AfterShip']->plugin_url . '/assets/js/meta-box.js' );
|
354 |
-
wp_enqueue_script( 'aftership-js', $GLOBALS['AfterShip']->plugin_url . '/assets/plugin/chosen/chosen.jquery.min.js' );
|
355 |
-
wp_enqueue_script( 'aftership-js', $GLOBALS['AfterShip']->plugin_url . '/assets/plugin/chosen/chosen.proto.min.js' );
|
356 |
-
|
357 |
}
|
358 |
|
359 |
/**
|
@@ -557,7 +399,7 @@ class AfterShip_Actions {
|
|
557 |
break;
|
558 |
}
|
559 |
}
|
560 |
-
$this->save_tracking_items( $order_id, $tracking_items );
|
561 |
}
|
562 |
|
563 |
return $is_deleted;
|
@@ -1020,4 +862,194 @@ class AfterShip_Actions {
|
|
1020 |
|
1021 |
<?php
|
1022 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1023 |
}
|
173 |
|
174 |
$this->migrate();
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
woocommerce_wp_hidden_input(
|
177 |
array(
|
178 |
'id' => 'aftership_get_nonce',
|
194 |
)
|
195 |
);
|
196 |
|
197 |
+
echo '<aftership-meta-box></aftership-meta-box>';
|
198 |
+
wp_enqueue_script( 'aftership-js-tracking-items', $GLOBALS['AfterShip']->plugin_url . '/assets/meta-box/dist/index.js' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
}
|
200 |
|
201 |
/**
|
399 |
break;
|
400 |
}
|
401 |
}
|
402 |
+
$this->save_tracking_items( $order_id, array_values( $tracking_items ) );
|
403 |
}
|
404 |
|
405 |
return $is_deleted;
|
862 |
|
863 |
<?php
|
864 |
}
|
865 |
+
|
866 |
+
/**
|
867 |
+
* Order Tracking Get All Order Items AJAX
|
868 |
+
*
|
869 |
+
* Function for getting all tracking items associated with the order
|
870 |
+
*/
|
871 |
+
public function get_settings() {
|
872 |
+
$this->format_aftership_tracking_output(
|
873 |
+
200,
|
874 |
+
'success',
|
875 |
+
array(
|
876 |
+
'couriers' => $GLOBALS['AfterShip']->selected_couriers,
|
877 |
+
'custom_domain' => $GLOBALS['AfterShip']->custom_domain,
|
878 |
+
)
|
879 |
+
);
|
880 |
+
}
|
881 |
+
|
882 |
+
/**
|
883 |
+
* Order Tracking Get All Order Items AJAX
|
884 |
+
*
|
885 |
+
* Function for getting all tracking items associated with the order
|
886 |
+
*/
|
887 |
+
public function get_order_detail() {
|
888 |
+
check_ajax_referer( 'get-tracking-item', 'security', true );
|
889 |
+
|
890 |
+
if ( empty( $_REQUEST['order_id'] ) ) {
|
891 |
+
$this->format_aftership_tracking_output( 422, 'missing order_id field' );
|
892 |
+
}
|
893 |
+
$order_id = wc_clean( $_REQUEST['order_id'] );
|
894 |
+
|
895 |
+
// migrate old tracking data
|
896 |
+
$this->convert_old_meta_in_order( $order_id );
|
897 |
+
|
898 |
+
// get order line items
|
899 |
+
$order_line_items = $this->get_order_item_data( $order_id );
|
900 |
+
// get exist order trackings
|
901 |
+
$order_tracking_items = $this->get_tracking_items( $order_id );
|
902 |
+
|
903 |
+
$order_trackings = array(
|
904 |
+
'line_items' => $order_line_items,
|
905 |
+
'trackings' => $order_tracking_items,
|
906 |
+
);
|
907 |
+
|
908 |
+
$this->format_aftership_tracking_output( 200, 'success', $order_trackings );
|
909 |
+
}
|
910 |
+
|
911 |
+
/**
|
912 |
+
* Order Tracking Save AJAX
|
913 |
+
*
|
914 |
+
* Function for saving tracking items via AJAX
|
915 |
+
*/
|
916 |
+
public function save_order_tracking() {
|
917 |
+
check_ajax_referer( 'create-tracking-item', 'security', true );
|
918 |
+
|
919 |
+
$params = json_decode( file_get_contents( 'php://input' ), true );
|
920 |
+
$order_id = wc_clean( $params['order_id'] );
|
921 |
+
$order_trackings = $params['trackings'];
|
922 |
+
// check order trackings fields from front
|
923 |
+
$this->check_aftership_tracking_fields( $order_id, $order_trackings );
|
924 |
+
// check fulfill item quantity
|
925 |
+
$this->check_order_fulfill_items( $order_id, $order_trackings );
|
926 |
+
|
927 |
+
$this->save_tracking_items( $order_id, $order_trackings );
|
928 |
+
// date_modified update
|
929 |
+
$order = new WC_Order( $order_id );
|
930 |
+
$order->set_date_modified( current_time( 'mysql' ) );
|
931 |
+
$order->save();
|
932 |
+
|
933 |
+
$this->format_aftership_tracking_output( 200, 'success' );
|
934 |
+
}
|
935 |
+
|
936 |
+
/**
|
937 |
+
* Order Tracking Delete
|
938 |
+
*
|
939 |
+
* Function to delete a tracking item
|
940 |
+
*/
|
941 |
+
public function delete_order_tracking() {
|
942 |
+
check_ajax_referer( 'delete-tracking-item', 'security', true );
|
943 |
+
|
944 |
+
$params = json_decode( file_get_contents( 'php://input' ), true );
|
945 |
+
$order_id = wc_clean( $params['order_id'] );
|
946 |
+
$tracking_id = wc_clean( $params['tracking_id'] );
|
947 |
+
|
948 |
+
if ( empty( $order_id ) || empty( $tracking_id ) ) {
|
949 |
+
$this->format_aftership_tracking_output( 422, 'missing required field' );
|
950 |
+
}
|
951 |
+
|
952 |
+
$this->delete_tracking_item( $order_id, $tracking_id );
|
953 |
+
|
954 |
+
// date_modified update
|
955 |
+
$order = new WC_Order( $order_id );
|
956 |
+
$order->set_date_modified( current_time( 'mysql' ) );
|
957 |
+
$order->save();
|
958 |
+
|
959 |
+
$this->format_aftership_tracking_output( 200, 'success' );
|
960 |
+
}
|
961 |
+
|
962 |
+
/**
|
963 |
+
* Validate required fields
|
964 |
+
*/
|
965 |
+
private function check_aftership_tracking_fields( $order_id, $trackings ) {
|
966 |
+
// check order trackings from front
|
967 |
+
if ( empty( $order_id ) || empty( $trackings ) || ! is_array( $trackings ) ) {
|
968 |
+
$this->format_aftership_tracking_output( 422, 'missing required field' );
|
969 |
+
}
|
970 |
+
|
971 |
+
foreach ( $trackings as $tracking_one ) {
|
972 |
+
if ( empty( $tracking_one['tracking_number'] ) || empty( $tracking_one['slug'] ) ) {
|
973 |
+
$this->format_aftership_tracking_output( 422, 'missing required field' );
|
974 |
+
}
|
975 |
+
}
|
976 |
+
}
|
977 |
+
|
978 |
+
/**
|
979 |
+
* Check fulfill item quantity
|
980 |
+
*/
|
981 |
+
private function check_order_fulfill_items( $order_id, $trackings ) {
|
982 |
+
// get order line items
|
983 |
+
$order_line_items = $this->get_order_item_data( $order_id );
|
984 |
+
$line_item_quantity = absint( array_sum( array_column( $order_line_items, 'quantity' ) ) );
|
985 |
+
$tracking_items = array_column( $trackings, 'line_items' );
|
986 |
+
|
987 |
+
// line_items 降为二维数组
|
988 |
+
$tmp = array();
|
989 |
+
foreach ( $tracking_items as $one ) {
|
990 |
+
$result = array_merge( $tmp, $one );
|
991 |
+
$tmp = $result;
|
992 |
+
}
|
993 |
+
$fulfill_items_quantity = absint( array_sum( array_column( $tmp, 'quantity' ) ) );
|
994 |
+
|
995 |
+
if ( $fulfill_items_quantity > $line_item_quantity ) {
|
996 |
+
$this->format_aftership_tracking_output( 422, 'fulfill item quantity gte order item qiantity' );
|
997 |
+
}
|
998 |
+
}
|
999 |
+
|
1000 |
+
/**
|
1001 |
+
* Get order item detail
|
1002 |
+
*/
|
1003 |
+
private function get_order_item_data( $order_id ) {
|
1004 |
+
$order = wc_get_order( $order_id );
|
1005 |
+
$line_items = array();
|
1006 |
+
foreach ( $order->get_items() as $item_key => $item ) {
|
1007 |
+
$data = $item->get_data();
|
1008 |
+
$format_decimal = array( 'subtotal', 'subtotal_tax', 'total', 'total_tax', 'tax_total', 'shipping_tax_total' );
|
1009 |
+
|
1010 |
+
// Format decimal values.
|
1011 |
+
foreach ( $format_decimal as $key ) {
|
1012 |
+
if ( isset( $data[ $key ] ) ) {
|
1013 |
+
$data[ $key ] = wc_format_decimal( $data[ $key ], wc_get_price_decimals() );
|
1014 |
+
}
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
// Add SKU and PRICE to products.
|
1018 |
+
if ( is_callable( array( $item, 'get_product' ) ) ) {
|
1019 |
+
$data['sku'] = $item->get_product() ? $item->get_product()->get_sku() : null;
|
1020 |
+
$data['price'] = $item->get_quantity() ? $item->get_total() / $item->get_quantity() : 0;
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
// Add parent_name if the product is a variation.
|
1024 |
+
if ( is_callable( array( $item, 'get_product' ) ) ) {
|
1025 |
+
$product = $item->get_product();
|
1026 |
+
|
1027 |
+
if ( is_callable( array( $product, 'get_parent_data' ) ) ) {
|
1028 |
+
$data['parent_name'] = $product->get_title();
|
1029 |
+
} else {
|
1030 |
+
$data['parent_name'] = null;
|
1031 |
+
}
|
1032 |
+
}
|
1033 |
+
$line_items[] = $data;
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
return $line_items;
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
/**
|
1040 |
+
* Format output
|
1041 |
+
*/
|
1042 |
+
private function format_aftership_tracking_output( $code, $message, $data = array() ) {
|
1043 |
+
$response = array(
|
1044 |
+
'meta' => array(
|
1045 |
+
'code' => $code,
|
1046 |
+
'type' => $code === 200 ? 'OK' : 'ERROR',
|
1047 |
+
'message' => $message,
|
1048 |
+
),
|
1049 |
+
'data' => $data,
|
1050 |
+
);
|
1051 |
+
header( 'Content-Type: application/json' );
|
1052 |
+
wp_send_json( $response );
|
1053 |
+
wp_die();
|
1054 |
+
}
|
1055 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.aftership.com/
|
|
4 |
Tags: woocommerce shipping,woocommerce tracking,shipment tracking,order tracking, woocommerce,track order,dhl,ups,usps,fedex,shipping,tracking,order
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 5.7
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -138,6 +138,9 @@ Tailor a dynamic branded tracking page. Upload promotional banner, logo, and fav
|
|
138 |
|
139 |
== Changelog ==
|
140 |
|
|
|
|
|
|
|
141 |
= 1.13.10 =
|
142 |
* Update courier list
|
143 |
|
4 |
Tags: woocommerce shipping,woocommerce tracking,shipment tracking,order tracking, woocommerce,track order,dhl,ups,usps,fedex,shipping,tracking,order
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 5.7
|
7 |
+
Stable tag: 1.14.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
138 |
|
139 |
== Changelog ==
|
140 |
|
141 |
+
= 1.14.0 =
|
142 |
+
* New Feature: Support fulfillment according to order items
|
143 |
+
|
144 |
= 1.13.10 =
|
145 |
* Update courier list
|
146 |
|