Jump to content

Retrieve orders for a logged in user


alexm
 Share

Recommended Posts

Hi @alexm,

2 hours ago, alexm said:

Is there any info on field names for grabbing details from orders yet? I think it's not in the docs and is TBD.

Yeah, sorry, not yet in the docs.

2 hours ago, alexm said:

I'd like to output stuff like total, items, shipping type and payment type basically on a customer dashboard

The code below can get you started. It finds all orders of the logged in user.

<?php

namespace ProcessWire;

/** @var PageArray $customerOrders */
$customerOrders = $padloper->find("template=order, order_customer.userID={$user}");
# ALTERNATIVE SELECTORS
// $customerOrders = $padloper->find("template=order, order_customer.user_id={$user}");
// $customerOrders = $padloper->find("template=order, order_customer.userID={$user->id}");
// $customerOrders = $padloper->find("template=order, order_customer.user_id={$user->id}");

You can also use $padloper->findRaw() if you will be expecting lots of orders per customer.

Order totals , shipping and payment info will be on the order themselves. Items are the children of the order pages. Line items info will be at the line items level.

Let me know if you need more info.

Thanks.

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...