Jump to content

Storing User Purchase history using PW


Vineet Sawant
 Share

Recommended Posts

Hello All,

I'm working on a Drama Ticket Booking website which I'm making using ProcessWire. The experience has been great. 

I'm almost done with the overall development of drama, theatre & shows management part, now moving on to users management.

Users will need to login in order to place an order & buy tickets online. For this, I've used Front-end User Profiles. It's working well, getting the work done.

Now that users can register & login, I want to store their purchase history which users can see whenever they want. I want that there should be someway users can see all the tickets they've purchased, and if the ticket is still valid, he/she can cancel the tickets as well.

Since I'm not a php ninja, I'll need your help. :)

Thanks in advance.

Link to comment
Share on other sites

What I would do is create a page "/tickets/". Under that page there will be children with a "ticket" template. That ticket template has a Page fieldtype (let's say: user_reference) reference to a user. This way you can get the tickets from one user by doing:

$pages->find("ticket_reference=$particularuser");

When a user orders a ticket you basicly create a page underneath "/tickets/" and store the user id in the user_reference field. You can save it like:

$ticket = new Page();
$ticket->template = $templates->get("ticket"); 
$ticket->parent = $pages->get("/tickets/"); 
$ticket->title = "Some title"; 
$ticket->user_reference = $currentUser;
$ticket->save();

All written in the browser, but you should get the idea. Also you might want to check out this excellent thread by soma to create your forms. My advise is to start really simple. Just save and reference user. Test it thoroughly and add additional fields.

  • Like 2
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

×
×
  • Create New...