2011-08-10 17:11:11 +00:00
< ? php
/**
* Order Tracking Shortcode
*
* Lets a user see the status of an order by entering their order details .
*
* @ package WooCommerce
* @ category Shortcode
* @ author WooThemes
*/
2011-12-09 17:01:56 +00:00
function get_woocommerce_order_tracking ( $atts ) {
2011-09-06 11:11:22 +00:00
global $woocommerce ;
return $woocommerce -> shortcode_wrapper ( 'woocommerce_order_tracking' , $atts );
2011-08-10 17:11:11 +00:00
}
function woocommerce_order_tracking ( $atts ) {
2012-02-03 16:17:35 +00:00
global $woocommerce ;
2011-08-10 17:11:11 +00:00
2012-02-24 21:05:15 +00:00
$woocommerce -> nocache ();
2012-02-07 12:09:23 +00:00
2011-08-10 17:11:11 +00:00
extract ( shortcode_atts ( array (
), $atts ));
global $post ;
if ( $_POST ) :
2012-01-13 00:46:56 +00:00
$woocommerce -> verify_nonce ( 'order_tracking' );
2011-08-10 17:11:11 +00:00
2012-01-13 00:46:56 +00:00
if ( isset ( $_POST [ 'orderid' ]) && $_POST [ 'orderid' ] > 0 ) $order_id = ( int ) $_POST [ 'orderid' ]; else $order_id = 0 ;
2011-08-10 17:11:11 +00:00
if ( isset ( $_POST [ 'order_email' ]) && $_POST [ 'order_email' ]) $order_email = trim ( $_POST [ 'order_email' ]); else $order_email = '' ;
2012-01-27 16:38:39 +00:00
$order = new WC_Order ( $order_id );
2011-08-10 17:11:11 +00:00
2012-01-13 00:46:56 +00:00
if ( $order -> id && $order_email ) :
2011-08-10 17:11:11 +00:00
if ( $order -> billing_email == $order_email ) :
2011-10-06 10:46:19 +00:00
2012-02-03 16:17:35 +00:00
woocommerce_get_template ( 'order/tracking.php' , array (
'order' => $order
) );
2011-09-23 14:22:21 +00:00
2011-12-09 17:01:56 +00:00
return ;
2011-09-23 14:22:21 +00:00
2011-08-10 17:11:11 +00:00
endif ;
2011-12-09 17:01:56 +00:00
endif ;
2012-01-05 11:31:22 +00:00
echo '<p>' . sprintf ( __ ( 'Sorry, we could not find that order id in our database. <a href="%s">Want to retry?</a>' , 'woocommerce' ), get_permalink ( $post -> ID )) . '</p>' ;
2011-08-10 17:11:11 +00:00
else :
2012-01-29 13:36:33 +00:00
woocommerce_get_template ( 'order/form-tracking.php' );
2011-08-10 17:11:11 +00:00
endif ;
}