hi guys, could you please help me on how to add more option field on order delivery. because when i tried to add one just give blank filed name however field box appears. thank you.
Wizzud
2005-03-14 18:27
What have you changed?
plop1973
2005-03-15 04:06
i tried to add more field option such as state, country and so on however the field box is appears but not the label. thanks
Wizzud
2005-03-15 09:31
Let me rephrase the question ...
Exactly which files have you changed (so far)?
More information is needed for a sensible and reasonably concise answer. Otherwise I have to write an essay to cover all the possible things that might have happened - or not happened!
plop1973
2005-03-16 16:27
sorry for unclear question. i put some option field in orders_delivery.tpl such as State, Country, etc. you can give a try at http://www.aussietogo.com.au/store and make a test purchasing.
OK. You want to add State and Country and you've started with the template file. One thing to remember is that the templates are not the be-all and end-all of the cart - they simply provide a way for the PHP code to output standardised and easily maintainable HTML, thereby effectively acting as the cart's front end. The templates handle the appearance, while the content is handled by the PHP code - the classic designer/developer split of responsibilities.
So.. You've got 2 extra pieces of information about the customer that you want to capture and store. Capture is easy (you've already changed the template), but where and how to store? Where is the current information (name,address, etc) stored, because that seems to be the obvious place for the new stuff? = db/orders.php, so you're going to be appending 2 new fields to each record in this file. When is the information put in this file? = when '$p=delivery', so track down that section in index.php. What happens when $p=delivery and the form has been submitted? = code calls saveOrder function with contents of POSTed form. What does saveOrder function do? = find it in core/orders.php ... after a bit of data manipulation it calls dbSaveOrder passing the form through again. What does dbSaveOrder do? = all 'db...' functions are held in the '...-ff.php' files so find core/orders-ff.php and look at dbSaveOrder. This appears to list all the form fields in the order they appear in the file (db/orders.php) and calls another function. We probably don't need to worry about digging further since we could try adding our 2 new fields to the end of the list using the same format as all the other fields use - in your case 'sState' and 'sCountry' (from your template)
OK, you've changed the template that will capture the new data and you've changed the code that will store it, so try it out and see if the new data gets stored in db/orders.php.
Assuming it does (!) you've now got to use that new stored data, ie. get out of the db/orders.php file. Use the same technique as outlined above to track what you need to change, ie. work out what $p is set to when you want to see the new data (look at the URL) - '$p=windowPrintOrder' possibly; track down likely functions (throwOrder?) which will probably be in core/orders.php,withthe 'db...' ones in core/orders-ff.php; somewhere along the line you will find a bit of code that expands the record from the file into a list of fields,and you will probably want to try adding your 2 new fields to the end of that list. Track it back up and you will find 1 (or more) other template files that you will have to add your new fields to in order to get them output to the screen. Don't forget Admin! You can do exactly the same tracking exercise through the admin.php side of things, checking for functions in the core/orders-admin.php file as well as the others you've already looked at.
Thats the basics of how to go about adding any new fields. Now its over to you! I hope this helps.
plop1973
2005-03-17 18:24
to Wizzud, thanks it works.
phpconfused
2005-03-18 23:54
Thanks Wizzud, for taking the time to explain. Appreciate it.
Do you have any suggestions for a simple way to bypass the store function for certain fields (eg Credit Card number)?
--justin
Sheep
2005-08-27 23:25
Maybe an old topic but very helpful! Cheers Wizzud!
ORiON
2005-11-14 23:20
Hey Wizzud.. all is correct... but how i add a field with two options? likes Courier.. 2 options
<select name='iCourier' class='input' onchange='ordersCouriers( this );'> <option value=''>$lang[choose]</option> $sSelectCourier </select>
How i insert 2 options in the string $sSelectCourier ?
That's all
Evan
2006-04-28 12:31
Why would something like State not be included? Quick.Cart is a shopping cart right? Are people supposed to look up the ZIP code every time an order is placed?
oceancomputer
2007-08-23 16:09
Adding new fields in this area should be something that you can do in the administration area