WC_Shortcode_Order_Tracking

Order Tracking Shortcode.

Defined (1)

The class is defined in the following location(s).

/includes/shortcodes/class-wc-shortcode-order-tracking.php  
  1. class WC_Shortcode_Order_Tracking { 
  2.  
  3. /** 
  4. * Get the shortcode content. 
  5. * @param array $atts 
  6. * @return string 
  7. */ 
  8. public static function get( $atts ) { 
  9. return WC_Shortcodes::shortcode_wrapper( array( __CLASS__, 'output' ), $atts ); 
  10.  
  11. /** 
  12. * Output the shortcode. 
  13. * @param array $atts 
  14. */ 
  15. public static function output( $atts ) { 
  16.  
  17. // Check cart class is loaded or abort 
  18. if ( is_null( WC()->cart ) ) { 
  19. return; 
  20.  
  21. extract( shortcode_atts( array(), $atts, 'woocommerce_order_tracking' ) ); 
  22.  
  23. global $post; 
  24.  
  25. if ( ! empty( $_REQUEST['orderid'] ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-order_tracking' ) ) { 
  26.  
  27. $order_id = empty( $_REQUEST['orderid'] ) ? 0 : esc_attr( $_REQUEST['orderid'] ); 
  28. $order_email = empty( $_REQUEST['order_email'] ) ? '' : esc_attr( $_REQUEST['order_email'] ); 
  29.  
  30. if ( ! $order_id ) { 
  31. wc_add_notice( __( 'Please enter a valid order ID', 'woocommerce' ), 'error' ); 
  32. } elseif ( ! $order_email ) { 
  33. wc_add_notice( __( 'Please enter a valid order email', 'woocommerce' ), 'error' ); 
  34. } else { 
  35. $order = wc_get_order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) ); 
  36.  
  37. if ( $order && $order->get_id() && $order_email ) { 
  38. if ( strtolower( $order->get_billing_email() ) == strtolower( $order_email ) ) { 
  39. do_action( 'woocommerce_track_order', $order->get_id() ); 
  40. wc_get_template( 'order/tracking.php', array( 
  41. 'order' => $order,  
  42. ) ); 
  43.  
  44. return; 
  45. } else { 
  46. wc_add_notice( __( 'Sorry, we could not find that order ID in our database.', 'woocommerce' ), 'error' ); 
  47.  
  48. wc_print_notices(); 
  49.  
  50. wc_get_template( 'order/form-tracking.php' );