2012-12-31 18:25:09 +00:00
|
|
|
<?php
|
2017-05-23 14:40:19 +00:00
|
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2012-12-31 18:25:09 +00:00
|
|
|
/**
|
|
|
|
* Order Tracking Shortcode
|
|
|
|
*
|
|
|
|
* Lets a user see the status of an order by entering their order details.
|
|
|
|
*
|
2017-01-18 16:45:20 +00:00
|
|
|
* @author WooThemes
|
|
|
|
* @category Shortcodes
|
|
|
|
* @package WooCommerce/Shortcodes/Order_Tracking
|
2017-03-15 16:36:53 +00:00
|
|
|
* @version 3.0.0
|
2012-12-31 18:25:09 +00:00
|
|
|
*/
|
|
|
|
class WC_Shortcode_Order_Tracking {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the shortcode content.
|
|
|
|
*
|
|
|
|
* @param array $atts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function get( $atts ) {
|
2013-08-09 16:11:15 +00:00
|
|
|
return WC_Shortcodes::shortcode_wrapper( array( __CLASS__, 'output' ), $atts );
|
2012-12-31 18:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output the shortcode.
|
|
|
|
*
|
|
|
|
* @param array $atts
|
|
|
|
*/
|
|
|
|
public static function output( $atts ) {
|
|
|
|
|
2014-02-26 15:27:26 +00:00
|
|
|
// Check cart class is loaded or abort
|
|
|
|
if ( is_null( WC()->cart ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-03 18:13:27 +00:00
|
|
|
extract( shortcode_atts( array(), $atts, 'woocommerce_order_tracking' ) );
|
2012-12-31 18:25:09 +00:00
|
|
|
|
|
|
|
global $post;
|
|
|
|
|
2014-10-21 07:46:14 +00:00
|
|
|
if ( ! empty( $_REQUEST['orderid'] ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-order_tracking' ) ) {
|
2012-12-31 18:25:09 +00:00
|
|
|
|
2017-01-18 16:45:20 +00:00
|
|
|
$order_id = empty( $_REQUEST['orderid'] ) ? 0 : esc_attr( $_REQUEST['orderid'] );
|
|
|
|
$order_email = empty( $_REQUEST['order_email'] ) ? '' : esc_attr( $_REQUEST['order_email'] );
|
2012-12-31 18:25:09 +00:00
|
|
|
|
|
|
|
if ( ! $order_id ) {
|
2017-01-18 16:45:20 +00:00
|
|
|
wc_add_notice( __( 'Please enter a valid order ID', 'woocommerce' ), 'error' );
|
2012-12-31 18:25:09 +00:00
|
|
|
} elseif ( ! $order_email ) {
|
2017-01-18 16:45:20 +00:00
|
|
|
wc_add_notice( __( 'Please enter a valid order email', 'woocommerce' ), 'error' );
|
2012-12-31 18:25:09 +00:00
|
|
|
} else {
|
2014-08-15 12:29:21 +00:00
|
|
|
$order = wc_get_order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );
|
2012-12-31 18:25:09 +00:00
|
|
|
|
2016-08-05 14:56:23 +00:00
|
|
|
if ( $order && $order->get_id() && $order_email ) {
|
2016-08-05 14:57:40 +00:00
|
|
|
if ( strtolower( $order->get_billing_email() ) == strtolower( $order_email ) ) {
|
2016-08-05 14:56:23 +00:00
|
|
|
do_action( 'woocommerce_track_order', $order->get_id() );
|
2013-11-25 12:45:04 +00:00
|
|
|
wc_get_template( 'order/tracking.php', array(
|
2016-08-27 01:46:45 +00:00
|
|
|
'order' => $order,
|
2012-12-31 18:25:09 +00:00
|
|
|
) );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2017-01-18 16:45:20 +00:00
|
|
|
wc_add_notice( __( 'Sorry, we could not find that order ID in our database.', 'woocommerce' ), 'error' );
|
2012-12-31 18:25:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-18 16:45:20 +00:00
|
|
|
wc_print_notices();
|
|
|
|
|
2013-11-25 12:45:04 +00:00
|
|
|
wc_get_template( 'order/form-tracking.php' );
|
2012-12-31 18:25:09 +00:00
|
|
|
}
|
2014-09-20 19:33:32 +00:00
|
|
|
}
|