Skip to content

Commit

Permalink
Parse tracking number from shippo order notes
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyao committed Dec 12, 2023
1 parent ec9dfff commit 8698b45
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions includes/class-aftership-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1393,26 +1393,21 @@ private function get_tracking_from_note ($note) {
$tracking['tracking_number'] = $matches[1];
return $tracking;
}
return $this->get_tracking_number_from_shippo($note);
}

private function get_tracking_number_from_shippo ($note) {
$tracking = array(
'tracking_number' => null,
'slug' => (strpos($note, "usps") !== false) ? 'usps': null,
);
if (strpos($note, "Shippo") !== false || strpos($note, "shippo") !== false) {
$html = stripslashes($note);
$pattern = '/<a[^>]*>(.*?)<\/a>/i';
preg_match($pattern, $html, $matches);
if (empty($matches[0])) {
return null;
$home = get_home_url();
if (strpos($home, "99jersey.com") !== false) {
if (strpos($note, "tracking number") !== false) {
$html = stripslashes($note);
$pattern = '/<a[^>]*>(.*?)<\/a>/i';
preg_match($pattern, $html, $matches);
if (empty($matches[0])) {
return null;
}
$tracking['tracking_number'] = $matches[0];
return $tracking;
}
$tracking['tracking_number'] = $matches[0];
return $tracking;
}
return null;
}
}

/**
* Get Order Notes
Expand Down

0 comments on commit 8698b45

Please sign in to comment.