Way to prevent a user from removing an item from the cart?

Posts: 4
Joined: 12/31/2007

First off, Ubercart rocks! Many thanks to the team for an excellent Drupal module.

Secondly, please pardon me in advance for a long posting!

We are trying to set up a website that allows new users to:

1. create a basic account (this is free)
2. enroll in our school by paying an Enrollment Fee
3. register for classes they wish to take (each class is also fee-based)

Account creation works fine. We have the Enrollment Fee and each class set up as items - users can browse the catalog, select items, etc. That all works just fine.

Here's what we want to do (our design):

4. When a new user just has a free account, their role is set to "student_new_account".

5. When a user has the enrollment fee in their cart, their role is changed to "student_enrolled" (note they've not yet paid, but we want them to be able to enroll and add courses in one financial transaction).

6. If a user just pays for the enrollment fee only, their role remains "student_enrolled"

7. If a user pays for the enrollment fee and for at least one class, their role is changed to "student_registered"

My questions are as follows:

8. Is there a way to implement a role change based cart contents? (see #5 above)

9. Is there a way to prevent a new user from removing the Enrollment Fee from the cart if their role is "student_new_account"?

10. Allow a user to browse the catalog any time, but prevent a user from registering for a class (or even adding it to their cart) if their role is "student_new_account" (i.e., until they've paid the enrollment fee they can't register for classes)?

11. Finally, prevent a user from adding the Enrollment Fee into their cart if their role is NOT "student_new_account" (this prevents them from paying the Enrollment Fee more than once.

Thanks to anyone who has read this far into the posting and might have some ideas on how we can implement this!

Posts: 4
Joined: 12/31/2007

bump...anyone?

Posts: 332
Joined: 08/07/2007
Administrator

It sounds like, instead of using a series of roles and creating a enrollment fee as a product, you'd be better off using a custom module that uses hook_line_item. You could have all your class products grant the role student_enrolled then at checkout, using hook_line_item, you could apply a Enrollment Fee line item that would only get applied if the customer doesn't have the student_enrolled role. This would make the enrollment fee a one time charge for customer.

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 4
Joined: 12/31/2007

Thanks very much for the input and for an excellent idea. That seems like a more elegant solution than what we were trying for.