Additional product field

kalanta

No avatar

2009-12-22 12:09

I would like to know, how to add one more field in product form. It should be a field like product name field (just a simple text field). I need php help. I know how to do this in v3, but in v2 there is something different.

» Quick.Cart v2.x

beholder

Avatar: beholder

2009-12-24 16:46

So I took a hard look at the antique version and you probably should change function dbSaveProduct() in file core/products-ff.php, change two lines in the function to this:


$oFF
->setRow( Array( $iProduct$sName$fPrice$sDescriptionShort$iStatus$iPosition$sMyNewField ) );
$oFF->setData( Array( 510234) );



If you need to change the data from new field in some way, do it in file core/products-admin.php, in function saveProduct(), on the aForm array data.

Also, you need to add this to the list line in throwProductsData() and throwProduct() in file core/products.php:
, $aList['sMyNewField']
so the line should look something like this (both lines are a bit different):
list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'], $aList['sMyNewField'] ) = $aData;

Also, you need to add the field to the templates/admin/products_form.tpl

And that should do it. This is off the top of my head, if this doesn't work, write me and we will make some arrangement.

kalanta

No avatar

2009-12-25 09:51

It's exactly what I wanted. It works fine. Thank you.

beholder

Avatar: beholder

2009-12-25 13:36

oh, I forgot one thing:
you probably need to add a $ character to the end of every existing entry in file db/products.php
otherwise you may get warnings or even fucked up db as in 3.x.

Newly added products created after this change will already have the additional field there. Only older entries need this.

kalanta

No avatar

2009-12-25 14:09

All works ok and without added $ in that version. I've tried. Maybe it is needed in v3 only.

beholder

Avatar: beholder

2009-12-27 01:50

be careful with writing new products into that file. Check on the file structure ever so often, since in v. 3.x the problem manifests only after writing a new product.

carmycurly

Avatar: carmycurly

2010-02-09 18:38

How Can I send MyNewField to ORDER BASKET?

beholder

Avatar: beholder

2010-02-09 19:13

carmycurly >> stop hijacking other's threads. And what version do you use anyway?

carmycurly

Avatar: carmycurly

2010-02-09 20:42

sorry...my version is 2.2 ext

beholder

Avatar: beholder

2010-02-10 16:52

carmycurly >> what do you need to have in basket? Please be specific, describe your situation and why you need it.

carmycurly

Avatar: carmycurly

2010-02-11 15:45

I have an extra field in product admin (REF). This field shows in product list, product details, but when put this product into basket. The Field (sRef) not show...look at www.veronicamassini.com

beholder

Avatar: beholder

2010-02-11 18:44

carmycurly >> that webshop looks pretty fucked up (sorry for lack of more decent expressions). You have much more serious problem than some parameter not showing in the basket: the javascript on the page is not working because it throws error on some undefined object. The non-working javascript causes the checking if the customer chose all attributes to fail - he can just buy stuff without specifying any attributes. Furthermore, JS also errors with some urchin tracker, might be a google thing or something.

You need a professional help if you want to fix this or add the ref field somewhere in the basket (that actually should not be too difficult for someone experienced).

carmycurly

Avatar: carmycurly

2010-02-12 14:36

have you an idea who can help?

beholder

Avatar: beholder

2010-02-13 03:11

both problems solved, please check your email

The undefined object in javascript checkForm() function was caused by prototype.js. Basically, the script that checks the form was in collision with the prototype.js script which was put there for whatever reason (prototype.js is not a part of original QC 2.x package as far as I know). When I removed prototype.js, everything worked as should.

The technical description of the problem: the checkForm saw 1 additional array element in array aA with weird content when prototype.js was active - the element was not supposed to be there; the checkForm script had to be changed so this last element is ignored otherwise the script just failed with undefined object message or something like that.

The genius is in how I solved it: something had to be changed so that both scripts can work together. In the end I changed just 1 line in file js/checkForm.js and it now works WITH prototype.js without any problem.

beholder

Avatar: beholder

2010-02-13 03:22

BTW the urchin tracker failing was just my problem here, I forgot that I adblock this google script in my browser.

And to be specific with the above answer, here is the change to js/checkForm.js:
change line:
for( i in aA ) {
to:
for( i=0; i<aA.length; i++) {

Back to top
about us | contact