woocommerce/shortcodes/shortcode-order_tracking.php

53 lines
1.3 KiB
PHP
Raw Normal View History

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
*/
function get_woocommerce_order_tracking($atts) {
global $woocommerce;
return $woocommerce->shortcode_wrapper('woocommerce_order_tracking', $atts);
2011-08-10 17:11:11 +00:00
}
function woocommerce_order_tracking( $atts ) {
global $woocommerce, $order;
2011-08-10 17:11:11 +00:00
extract(shortcode_atts(array(
), $atts));
global $post;
if ($_POST) :
$order = &new woocommerce_order();
if (isset($_POST['orderid']) && $_POST['orderid'] > 0) $order->id = (int) $_POST['orderid']; else $order->id = 0;
if (isset($_POST['order_email']) && $_POST['order_email']) $order_email = trim($_POST['order_email']); else $order_email = '';
$woocommerce->verify_nonce( 'order_tracking' );
2011-08-10 17:11:11 +00:00
if ($order->id && $order_email && $order->get_order( $order->id )) :
2011-08-10 17:11:11 +00:00
if ($order->billing_email == $order_email) :
2011-10-06 10:46:19 +00:00
woocommerce_get_template( 'order/tracking.php' );
return;
2011-08-10 17:11:11 +00:00
endif;
endif;
echo '<p>'.sprintf(__('Sorry, we could not find that order id in our database. <a href="%s">Want to retry?</a>', 'woothemes'), get_permalink($post->ID)).'</p>';
2011-08-10 17:11:11 +00:00
else :
woocommerce_get_template( 'order/tracking-form.php' );
2011-08-10 17:11:11 +00:00
endif;
}