Skip to content

Instantly share code, notes, and snippets.

@wpacademy
Created September 22, 2022 04:26
Show Gist options
  • Save wpacademy/cfb2f01855e492b469ef4e6e38778f79 to your computer and use it in GitHub Desktop.
Save wpacademy/cfb2f01855e492b469ef4e6e38778f79 to your computer and use it in GitHub Desktop.
Order Tracking Page Code for Advanced eCommerce website tutorial by WP Academy
function wpac_add_query_vars_filter( $vars ){
$vars[] = "order_id";
return $vars;
}
add_filter( 'query_vars', 'wpac_add_query_vars_filter' );
function wpac_order_status() {
if(is_page(1141)){
$id = get_query_var('order_id');
$id = intval($id);
$order = wc_get_order($id);
if($order) {
$status = $order->get_status();
echo $status;
} else {
echo "No Data Found";
}
}
}
add_shortcode("WPAC_ORDER_STATUS", "wpac_order_status");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment