Welcome Guest, Not a member yet? Register   Sign In
controller interoperability with a twist!
#1

[eluser]coldfire82[/eluser]
Here is the pickle. BTW i am new to CI

structure is:

+views
- register
- login
- ...

+controller
- itempurchase
- register_user
- ...



I have a payment page at my (shopping) site which takes signup information IF the user is NOT signed in. When the customer enters the payment information along with singUp information, I want to do two operations. i.e.

1. Register a user
2. Process payment information. (like billingname,city,country, item, quantity etc., here, this information is then stored in a DB table)

The problem is, the html <form> is 1 and I want to accomplish these 2 separate operations in one go i.e. on form submit, it registers ther person and continue processing the payment. How to do that? Because, If I submit the form, it can either go to register_user or itempurchase and there is no interoperability between controllers (as far as i know, and I dont know v.much about CI Wink )


the ideas in my mind were to

idea 1: make the action of the form as "register_user" and by somehow either call the function in another controller or copy the controller function which is in itempurchase.
(i think this is totally against rules)

idea 2: make the action of the form as "register_user" and create a dummy view like "autopayment". Then, create a hidden form there and fill all variable values which will come in an array when i will load this view and at the end of the form, send this form using javascript to "itempurchase" controller.

idea3: viceversa of idea2. but with some tricky coding like first register the person and then process the controller.

idea4: put "register_user" in some common library and access it from the "itempurchase" controller.

i am really in trouble here...maybe its not so difficult if i know more abt the capabilities of CI!

SOS i am stuck!
#2

[eluser]WebsiteDuck[/eluser]
If you have a model function that creates a new user, just use that.

If your user creation process is complicated, create a library for it.

You might want to look at the cart class to save information about what the user is purchasing in case the user creation process fails... but you'll have to decide if using the cart class will actually help in your situation.
#3

[eluser]coldfire82[/eluser]
[quote author="WebsiteDuck" date="1264854252"]If you have a model function that creates a new user, just use that.

If your user creation process is complicated, create a library for it.

You might want to look at the cart class to save information about what the user is purchasing in case the user creation process fails... but you'll have to decide if using the cart class will actually help in your situation.[/quote]

my user creation process is not complicated. I just want to load usercreation controlloer from another controller (purcahseItem).

Is it ideal to put user registration in libraries ?
#4

[eluser]jdav3579[/eluser]
Hi,
I dont think you can load a controller from another controller. I have come across situations like this, where it would be nice.
the solution I have come up with in the past is to create a parent controller as MY_Controller in libraries and then have the two controllers extend MY_Controller.

Then put the code common to both controllers into the parent.

Not sure if this helps with your overall question though...


John




Theme © iAndrew 2016 - Forum software by © MyBB