woocommerce/shortcodes/shortcode-order_tracking.php

83 lines
1.9 KiB
PHP
Raw Normal View History

2011-08-10 17:11:11 +00:00
<?php
/**
* Order Tracking Shortcode
2012-08-14 17:37:50 +00:00
*
2011-08-10 17:11:11 +00:00
* Lets a user see the status of an order by entering their order details.
*
2012-08-14 17:37:50 +00:00
* @author WooThemes
* @category Shortcodes
* @package WooCommerce/Shortcodes/Order Tracking
* @version 1.6.4
2011-08-10 17:11:11 +00:00
*/
2012-08-14 17:37:50 +00:00
/**
* Get the order tracking shortcode content.
*
* @access public
* @param array $atts
* @return string
*/
function get_woocommerce_order_tracking( $atts ) {
global $woocommerce;
2012-08-14 17:37:50 +00:00
return $woocommerce->shortcode_wrapper('woocommerce_order_tracking', $atts);
2011-08-10 17:11:11 +00:00
}
2012-08-14 17:37:50 +00:00
/**
* Output the order tracking shortcode.
*
* @access public
* @param array $atts
* @return void
*/
2011-08-10 17:11:11 +00:00
function woocommerce_order_tracking( $atts ) {
2012-02-03 16:17:35 +00:00
global $woocommerce;
2012-08-14 17:37:50 +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));
2012-08-14 17:37:50 +00:00
2011-08-10 17:11:11 +00:00
global $post;
2012-08-14 17:37:50 +00:00
2012-09-06 16:54:07 +00:00
if ( ! empty( $_REQUEST['orderid'] ) ) {
2012-08-14 17:37:50 +00:00
$woocommerce->verify_nonce( 'order_tracking' );
2012-08-14 17:37:50 +00:00
2012-09-06 16:54:07 +00:00
$order_id = empty( $_REQUEST['orderid'] ) ? 0 : esc_attr( $_REQUEST['orderid'] );
$order_email = empty( $_REQUEST['order_email'] ) ? '' : esc_attr( $_REQUEST['order_email']) ;
2012-08-14 17:37:50 +00:00
if ( ! $order_id ) {
2012-08-14 17:37:50 +00:00
echo '<p class="woocommerce_error">' . __('Please enter a valid order ID', 'woocommerce') . '</p>';
2012-08-14 17:37:50 +00:00
} elseif ( ! $order_email ) {
2012-08-14 17:37:50 +00:00
echo '<p class="woocommerce_error">' . __('Please enter a valid order email', 'woocommerce') . '</p>';
2012-08-14 17:37:50 +00:00
} else {
2012-08-14 17:37:50 +00:00
$order = new WC_Order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );
2012-08-14 17:37:50 +00:00
if ( $order->id && $order_email ) {
2012-08-14 17:37:50 +00:00
if ( strtolower( $order->billing_email ) == strtolower( $order_email ) ) {
do_action( 'woocommerce_track_order', $order->id );
woocommerce_get_template( 'order/tracking.php', array(
'order' => $order
) );
2012-08-14 17:37:50 +00:00
return;
}
2012-08-14 17:37:50 +00:00
} else {
2012-08-14 17:37:50 +00:00
echo '<p class="woocommerce_error">' . sprintf( __('Sorry, we could not find that order id in our database.', 'woocommerce'), get_permalink($post->ID ) ) . '</p>';
2012-08-14 17:37:50 +00:00
}
2012-08-14 17:37:50 +00:00
}
2012-08-14 17:37:50 +00:00
}
2012-08-14 17:37:50 +00:00
woocommerce_get_template( 'order/form-tracking.php' );
2011-08-10 17:11:11 +00:00
}