0

I'm new to Exp-resso store. According to the docs; I can view an order through its order hash as per below:

{exp:store:orders order_hash="xxxx"}

How do I retrieve the order hash?

Edit: Referring to this answer: Printing Order Summary in Expresso Store

It seems that order hash only available via success page? Is there a way I can retrieve it for later viewing; ala url_title or entry_id?

2 Answers 2

1

There are a few ways to get access to the {order_hash} tag, the most common way that you would probably see it is a result of placing a successful order. This would be achieved by adding return="order/ORDER_HASH" to the final checkout tag.

The next way you can access the order_hash is in your receipt templates that will get sent out to customers on a completed order. You will want to use the {exp:store:orders} tag pair in your receipt templates to get all of the relative order details and this would allow you to create a link to the particular hash (this assumes you have a template group called orders and the template is looking for the hash in the segment_2. You may need to adjust to your site.)

{exp:store:orders}
 Order ID: {order_id}
 View Invoice: {path="orders/{order_hash}"}
{/exp:store:orders}

The other way you can access the order_hash was touched on by Rodrigo in his answer but you should be able to use the {order_hash} tag even though it is not listed on the orders documentation page.

{exp:store:orders member_id="CURRENT_USER"}"}
 Order ID: {order_id}<br />
 <a href='{path="orders/{order_hash}"}'>View Invoice</a>
{/exp:store:orders}

The nice thing about using the order_hash over the order_id as has been mentioned is that it prevents a malicious user from being able to quickly guess other order numbers which might include sensitive information such as address or phone number.

If you do decide to use order_id instead you should make sure that your template to show single orders also includes a conditional for the current member to prevent users from seeing other users orders.

{exp:store:orders member_id="CURRENT_USER"}" order_id="{segment_2}"}
 Order ID: {order_id}<br />
{/exp:store:orders}
1
  • Thanks guys. I wonder why it is not mentioned in the docs. And if possible; allow admin to view the hash string inside the order detail page.
    – aeran
    Commented Apr 21, 2015 at 5:04
1

Yes, you can have a listing of orders by the logged user using:

{exp:store:orders member_id="CURRENT_USER"}
  <a href="{path='/order/{order_id}'}"> view order </a>
{/exp:store:orders}

Then on that template:

{exp:store:orders order_id="{segment_2}"}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.