function slp_display_tracking_info($order = '')
{
    //track only if order status is complete
    if ($order->get_status() === 'completed') {
        //get shipment data
        $shipment = get_post_meta($order->id, '_shipment', true);
        //get shipping method
        $provider = get_post_meta($order->id, '_shipping_method', true);
        //format text excerpt for display
        if (strtotime($shipment['_shipping_date']) > current_time('time_stamp')) {
            $verb = 'is scheduled for shipment';
        } else {
            $verb = 'was shipped';
        }
        //format shipping date for display
        $date_shipped = ' ' . sprintf(__('on %s', 'slp'), date_i18n(__('l, F jS, Y', 'slp'), strtotime($shipment['_shipping_date'], current_time('timestamp'))));
        ob_start();
        ?>
        <!--End PHP/HTML Start-->
        
        <style type="text/css">
			#slp_order_packages {
				border: 0.5px solid #555; 	
			}
			#slp_order_packages thead {
				background: #985F01;
				color: #fff;
			}
			#slp_order_packages th, #slp_order_packages td {
				padding: 0 5px;
				text-align: left;
			}
			#slp_order_packages > tbody tr {
				background: #eee;
				padding:0 5px;
			}
		</style>
        
        <p style="margin:5px 0;">The table below contains up-to-date tracking information. <!--Click the tracking numbers below to view complete tracking history.--></p>
        
		<table id="slp_order_packages" width="100%" style="margin:10px 0;"> 
        	<thead>
        		<tr> 
                	<th>Tracking Number</th>
                    <th>Status Date</th>
                    <th>Status</th>
                    <th>Description</th>
				</tr>
           	</thead>
            <tbody>
				<?php 
        foreach ($shipment['_packages'] as $key => $package) {
            $tracking_link = get_tracking_url($tracking_provider, $package->id, $order->shipping_postcode);
            ?>
            <tr>
                <td><?php 
            echo $package->id;
            ?>
</td>
                <td><?php 
            echo $package->TrackingStatus['timestamp'];
            ?>
</td>
                <td><?php 
            echo $package->TrackingStatus['status'];
            ?>
</td>
                <td><?php 
            echo $package->TrackingStatus['desc'];
            ?>
</td>
            </tr><?php 
        }
        ?>
            </tbody>
        </table>
		
		<!--End HTML/PHP Start--><?php 
        $tracking_table = ob_get_clean();
        $tracking_provider = ' ' . __('via ', 'slp') . '<strong>' . $order->get_shipping_method() . '</strong>';
        echo wpautop(sprintf(__('<p style="margin-top:10px;">This order ' . $verb . '%s%s.</p>', 'slp'), $date_shipped, $tracking_provider));
        echo wpautop($tracking_table);
    }
}
<?php

$shipment = get_post_meta($order->id, '_shipment', true);
$date_shipped = $shipment['_shipping_date'];
$tracking_provider = $shipment['_shipping_method'];
$postcode = get_post_meta($order_id, '_shipping_postcode', true);
$packages = $shipment['_packages'];
if ($date_shipped) {
    $date_shipped = ' ' . sprintf(__('on %s', 'shipping_label_pro'), date_i18n(__('l, F jS, Y', 'shipping_label_pro'), strtotime($date_shipped)));
}
foreach ($packages as $package) {
    if ($tracking_provider) {
        $link_format = '';
        $providers = get_tracking_url();
        $link_format = $providers['tracking_provider'];
        if ($link_format) {
            $link = sprintf($link_format, $package->id, urlencode($postcode));
            $links[] = sprintf('<a href="%s">%s</a>', $link, $package->id);
        }
    }
}
$tracking_provider = ' ' . __('via ', 'slp') . '<strong>' . $tracking_provider . '</strong>';
if (sizeof($links) > 1) {
    $tracking_link = 's ' . implode(',', $links);
} else {
    $tracking_link = ' ' . $links;
}
?>
<p><?php 
sprintf(__('Your order was shipped%s%s. Tracking number%s. You can check the tracking status of your shipment below if avaliable.', 'shipping_label_pro'), $date_shipped, $tracking_provider, $tracking_link);
?>
예제 #3
0
    if (!empty($package['tracking'])) {
        ?>
									<a href="#" data-toggle="popover" data-popover-content="#popover-<?php 
        echo $package['idx'];
        ?>
" data-placement="bottom" data-trigger="focus" role="button" tabindex="<?php 
        echo $package['idx'];
        ?>
"><?php 
        echo $package['tracking'];
        ?>
</a><br />(<?php 
        echo strtoupper($package['carrier']) . " " . ucwords(strtolower($package['method']));
        ?>
 <a href="<?php 
        echo get_tracking_url($package['tracking']);
        ?>
"><span class="glyphicon glyphicon-new-window" aria-hidden="true"></span></a>)</td>
									<?php 
    } else {
        ?>
									None Yet
									<?php 
    }
    ?>
								</td>
								<td><?php 
    echo $package['shipper'];
    ?>
</td>
								<td><?php 
 public function get_shipments()
 {
     global $wpdb, $woocommerce;
     $shipments = array();
     $posts = $wpdb->get_results($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type LIKE %s AND post_status LIKE %s ORDER BY ID", 'shop_order', 'wc-completed'));
     foreach ($posts as $key => $post) {
         $order = wc_get_order($post->ID);
         $shipment = get_post_meta($order->id, '_shipment', true);
         $shipment = cleanse_shipment($order, $shipment);
         $order_number = get_post_meta($order->id, '_order_number') ? get_post_meta($order->id, '_order_number', true) : $order->id;
         $service = $order->get_shipping_method();
         $carrier = explode(',', $service);
         $carrier = trim(preg_replace('#[()]#', '', substr($carrier[0], strpos($carrier[0], '('))));
         $order_link = '<a href="' . admin_url('post.php?post=' . $order->id . '&action=edit') . '">' . $order_number . '</a>';
         foreach ($shipment['_packages'] as $key => $package) {
             $trackingNumbers = get_tracking_url($carrier, $package->id, $order->shipping_postcode);
         }
         if (is_array($shipment['_shipment_status'])) {
             $shipment['_shipment_status'] = $shipment['_shipment_status'][0];
             self::update_shipment($order - id, $shipment);
         }
         /*if( ! isset( $status['status'] ) || ( ! $status['status'] == "DELIVERED" && ! $status['status'] == 'Not Trackable' ) ){
         			$shipment = self::track_shipment( $order->id, $shipment );	
         		}*/
         array_push($shipments, array('<input type="checkbox" class="sel_shipments" id="' . $order->id . '"/>', $order_link, ucwords($order->billing_first_name) . ' ' . ucwords($order->billing_last_name), $trackingNumbers, $service, $shipment['_shipping_date'], $shipment['_shipment_status'], wc_price($shipment['_shipping_costs'])));
     }
     echo json_encode($shipments);
     die;
 }