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(); remove_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments')); $history = get_comments(array( 'post_id' => $order_id, 'orderby' => 'comment_ID', 'order' => 'DESC', 'approve' => 'approve', 'type' => 'order_note', )); add_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments')); $history_list = array(); if (count($history) > 0) { foreach ($history as $shipment) { $history_list[] = $shipment->comment_content; } } $shipped = false; if (count($history_list)) { foreach ($history_list as $val) { if (strpos($val, "- Order No") !== false) { $shipped = true; break; } } } $aramex_return_button = false; if (count($history_list)) { foreach ($history_list as $history) { $pos = strpos($history, 'Return'); if ($pos) { $aramex_return_button = true; break; } $awbno = strstr($history, "- Order No", true); $awbno = trim($awbno, "AWB No."); if ($awbno != "") { $aramex_return_button = true; break; } } } ?>