1 <?php
2 3 4 5 6 7 8 9 10 11
12
13 class WC_Shortcode_Order_Tracking {
14
15 16 17 18 19 20 21
22 public static function get( $atts ) {
23 return WC_Shortcodes::shortcode_wrapper( array( __CLASS__, 'output' ), $atts );
24 }
25
26 27 28 29 30 31 32
33 public static function output( $atts ) {
34
35
36 if ( is_null( WC()->cart ) ) {
37 return;
38 }
39
40 extract(shortcode_atts(array(
41 ), $atts));
42
43 global $post;
44
45 if ( ! empty( $_REQUEST['orderid'] ) ) {
46
47 wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-order_tracking' );
48
49 $order_id = empty( $_REQUEST['orderid'] ) ? 0 : esc_attr( $_REQUEST['orderid'] );
50 $order_email = empty( $_REQUEST['order_email'] ) ? '' : esc_attr( $_REQUEST['order_email']) ;
51
52 if ( ! $order_id ) {
53
54 echo '<p class="woocommerce-error">' . __( 'Please enter a valid order ID', 'woocommerce' ) . '</p>';
55
56 } elseif ( ! $order_email ) {
57
58 echo '<p class="woocommerce-error">' . __( 'Please enter a valid order email', 'woocommerce' ) . '</p>';
59
60 } else {
61
62 $order = new WC_Order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );
63
64 if ( $order->id && $order_email ) {
65
66 if ( strtolower( $order->billing_email ) == strtolower( $order_email ) ) {
67 do_action( 'woocommerce_track_order', $order->id );
68 wc_get_template( 'order/tracking.php', array(
69 'order' => $order
70 ) );
71
72 return;
73 }
74
75 } else {
76
77 echo '<p class="woocommerce-error">' . sprintf( __( 'Sorry, we could not find that order id in our database.', 'woocommerce' ), get_permalink($post->ID ) ) . '</p>';
78
79 }
80
81 }
82
83 }
84
85 wc_get_template( 'order/form-tracking.php' );
86 }
87 }