Order History - Order Address Detail
Hi Drew,
I'm trying to create an order history for customers.
I'd like to essentially recreate my order confirm page so that they can view all of the historical order details.
I've been able to pull in the static cart from the order, as well as the shipping method. I've done this by pasting those respective templates into a new template called `order_details.html', then:
<?php perch_shop_order(perch_get('orderID'), ['template' => 'shop/orders/order_details.html',]); ?>
However, I'm not able to pull in the billing and shipping addresses used for the order. Are there template tags or page functions that can accomplish this?
Thank you!
You can get the order, then get the addresses. I then just add that to a variable and output it in my template. So something like:
Thank you Rachel!!
I've been playing around with it and I've gotten the proper addresses to show up, but with an "array to string conversion" error that I can't seem to get rid of.
I don't have much experience passing variables into templates, so I'm not sure how I would use 'formattedAddress' in the address template. If
PerchSystem::set_var()
is the best way to do this, I regret that I'll need a little more coaching.Also with your above,
$order_id
is not set and when I try something like this, noting is returned:I think you want your original
perch_get('orderID')
to read the order ID from the URL.Which line is throwing the array conversion error?
Hi Drew, it's this line:
What's the value of
orderID
on the URL?It's just the number, like "50."
and
returns "50"
That's the only part on that line that could be returning an array, and it's not.
Can you show me the exact error message you're getting?
Yes indeed! ---
It's also printing "Array" right above the templated address output
And 81 is this line?
So with lots of distracting code removed I realised that I was actually echoing:
eek!
Now with the echo in there, I was getting the "Array" issue but I was also getting the proper address. When I took the echo out I got nothing.
When I did this below, I got just the proper addresses (yay)...is doing this okay??
That shouldn't be necessary -
perch_shop_customer_address()
should echo itself:It was the
true
I had in there.All good. cheers Drew!
Hi Drew, I just updated to Perch Shop 1.0.6 and this address function broke...
From the debug, orderID is NULL...just here, my other order details are coming through fine.
If you
PerchUtil::debug($order)
what do you get?Hmm, I think the issue here is that we exclude addresses that are already assigned to an order. When an order is placed, the address is copied and frozen, so that the records aren't invalidated by later edits.
These functions were designed with address book management in mind - i.e. pre-order. Therefore looking up an address that is assigned to an order doesn't currently work.
Thank you for taking such a thorough look at it Drew; I really appreciate it.
I haven't set up the order confirm emails yet, but I see that they contain addresses and other cart details--are they then generated before the the cart is destroyed, and informed by the cart rather then the order?
No, it's really just a filter on the query. All the data is there - but we don't use those runtime functions internally.
It's going to need a bug fix in the next update, which I'm afraid won't be until I'm back in the UK at the beginning of next week.
Ah, I see, that's good news. Thank you Drew!!
Hi Drew, Not sure if this made it into 1.0.8?
Recap: trying to get the order addresses to display on a historical order page via: