Spinbox Posted March 15 Share Posted March 15 I want to limit the purchase of some 'event'-typed product to 1 per user. Currently when an event is purchased the user get's added to a pagearrayfield which in turn grants them access to some pages. How could I limit the amount of a product to be added to the cart to 1? And after they bought it, how can I prevent them from buying it again? 1 Link to comment Share on other sites More sharing options...
cwsoft Posted March 15 Share Posted March 15 Sorry didn‘t get the module specific part on my iPhone display. Deleted my old message as it was out of context. Link to comment Share on other sites More sharing options...
kongondo Posted March 16 Share Posted March 16 22 hours ago, Spinbox said: I want to limit the purchase of some 'event'-typed product to 1 per user. Currently when an event is purchased the user get's added to a pagearrayfield which in turn grants them access to some pages. How could I limit the amount of a product to be added to the cart to 1? And after they bought it, how can I prevent them from buying it again? Hi @Spinbox, Just acknowledging that I have seen this. I'll get back to you with a detailed answer. There's various ways to approach this (all easy ?). Link to comment Share on other sites More sharing options...
kongondo Posted April 4 Share Posted April 4 Hi @Spinbox, I have hived off your shipping fee question to a new topic here: Link to comment Share on other sites More sharing options...
kongondo Posted April 4 Share Posted April 4 For the present question about 1 product per user, here is example code: <?php namespace ProcessWire; $eventProductID = 2678; $customerEmail = 'wario_best@gmail.com'; /* NOTES 1. line-time -> padloper-order-line-item (order line item template) 2. product_id -> subfield in padloper_order_line_item field with product ID value 3. parent.order_customer -> Order is the parent of line items. padloper_order_customer is the field with customer details */ // $boughtTicket = $padloper->get("template=line-item, line_item.product_id={$eventProductID},parent.order_customer.email={$customerEmail}"); // if ($boughtTicket instanceof NullPage) { // // NOT YET BOUGHT TICKET // } else { // // BOUGHT TICKET ALREADY // } # OR $boughtTicketID = (int) $padloper->getRaw("template=line-item, line_item.product_id={$eventProductID},parent.order_customer.email={$customerEmail}", 'id'); if (empty($boughtTicketID)) { // NOT YET BOUGHT TICKET } else { // BOUGHT TICKET ALREADY } Let me know if you need clarification. Sorry for the delay! Thanks. 1 Link to comment Share on other sites More sharing options...
Spinbox Posted April 23 Author Share Posted April 23 Great stuff! Cheers ? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now