Forum
Displaying/viewing an order from the url
From the list of orders in the account section for a logged in customer, to view an individual order I'm using the following code to view the order selected. Is this ok or is there a better way? It displays the correct order but maybe there is a cleaner way?
url to view an order is : /account/orders/27
url pattern in runway is: account/orders/[i:orderID]
Code on the display order page is:
function getUriSegments() {
return explode("/", parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
}
function getUriSegment($n) {
$segs = getUriSegments();
return count($segs)>0&&count($segs)>=($n-1)?$segs[$n]:'';
}
// View order based on order id in url
perch_shop_order(getUriSegment(3));
I've tried this but it doesn't display the order as i guess it doesn't know where to look for the number or url?
perch_shop_order($order_id);
Look here: https://docs.grabaperch.com/runway/routing/named-segments/
All you need is:
another perspective
Thanks Duncan & Robert they worked a treat! thought there had to be a simpler way :o) Thanks again!