allcaps['edit_shop_order'] || !$get_userdata->allcaps['read_shop_order'] || !$get_userdata->allcaps['edit_shop_orders'] || !$get_userdata->allcaps['edit_others_shop_orders'] || !$get_userdata->allcaps['publish_shop_orders'] || !$get_userdata->allcaps['read_private_shop_orders'] || !$get_userdata->allcaps['edit_private_shop_orders'] || !$get_userdata->allcaps['edit_published_shop_orders']) { return false; } $order_id = $order->get_id(); $currentUrl = home_url(add_query_arg(null, null)); $history = get_comments(array( 'post_id' => $order_id, 'orderby' => 'comment_ID', 'order' => 'DESC', 'approve' => 'approve', 'type' => 'order_note', )); $history_list = array(); if (count($history) > 0) { foreach ($history as $shipment) { $history_list[] = $shipment->comment_content; } } $last_track = ""; if (count($history_list)) { foreach ($history_list as $history) { $awbno = strstr($history, "- Order No", true); $awbno = trim($awbno, "AWB No."); if (isset($awbno)) { if ((int)$awbno) { $last_track = $awbno; break; } } $awbno = trim($awbno, "Aramex Shipment Return Order AWB No."); if (isset($awbno)) { if ((int)$awbno) { $last_track = $awbno; break; } } } } ?>