Tutorial - How to add new product field in Quick.Cart v5.0

treewood (OpenSolution)

Avatar: treewood

2012-03-21 09:45

Here is tutorial "how to add new field to product data". This tutorial is designed to Quick.Cart v5.0.

In the example below we're adding the field named "date" but it could be any other desired field.

1. Edit templates/admin/products.tpl and add code

<tr>
  <
td>$lang['sField1']</td>
  <
td><input type="text" name="sField1" value="$aData[sField1]" size="40" class="input" /></td>
</
tr>

before

<!-- tab options -->



2. Edit database/translations/en.php (or other language you have) and add:

$lang['sField1'] = "Date";

after:

// plugins


You can change "Date" to anything else.

3. Edit database/_fields.php and change add this:

'sField1'

after this code:

'sDescriptionShort''sDescriptionFull'


Finally this shoud look like (in Quick.Cart v5.0 freeware version):
$aProductsFields = Array( 'iProduct', 'sName', 'sNameUrl', 'mPrice', 'iStatus', 'iPosition', 'sAvailable', 'sNameTitle', 'sTemplate', 'sTheme', 'sMetaKeywords', 'sMetaDescription', 'sDescriptionShort', 'sDescriptionFull', 'sField1' );

4. Edit templates/default/products_default.tpl and add this:

option 1

<!-- IF:START FIELD---><div class="field1">$lang['sField1']: $aData[sField1]</div><!-- IF:END FIELD--->

or this (if you want always display this extra field even it is empty):

option 2

<div class="field1">$lang['sField1']: $aData[sField1]</div>


before (you can choose other location in CONTAINER block) for example:

$aImages[1]


5. If you choosed first option from 4 step then edit actions/products.php and add this:

if( !empty( $aData['sField1'] ) )
  
$oTpl->setIf'FIELD-1' );

after:

$oTpl->setIf'NAVIPATH' );


Note: In this step you added statement. This statement will display extra field if it is NOT EMPTY.

6. Log to admin panel and add some text to this field for example: 2012-02-07

7. Now you need to edit templates/default/style.css and add some styles to .field1 for example .field1{font-weight:bold;margin:10px 0;}

Thats all :)

If you want to display this extra field in products list then do 2 more steps:

8. Edit templates/default/pages_default.tpl and add this:

<!-- IF:START FIELD---><div class="field1">$lang['sField1']: $aData[sField1]</div><!-- IF:END FIELD--->

or this (if you want always display this extra field even it is empty):

<div class="field1">$lang['sField1']: $aData[sField1]</div>

after (you can choose other place in PRODUCTS block) for example:

<h3>$aData[sPages]</h3>


9. If you choosed first option from 8 step then edit core/products.php and add this:

if( !empty( $aData['sField1'] ) ){
  
$oTpl->setVariables'aData'$aData );
  
$oTpl->setIf'FIELD-1' );
}

before:

if( !empty( $aData['sDescriptionShort'] ) ){


Have fun!

treewood (OpenSolution)

Avatar: treewood

2012-12-19 14:30

Tutorial "how to add new field to product" to Quick.Cart v6.0 is moved to plugin:
http://opensolution.org/download,en,18.html?sDir=Quick.Cart/plugins#productsNewField

Back to top
about us | contact