KiralyVlad 2006-11-05 14:05
**WARNING !! IN ORDER FOR THIS TO WORK YOU NEED TO DISABLE PRODUCTATTRIBUTES PLUGIN !!! I will do my best to make it work in conjunction with the ProductAttributes plugin. Okay, If you want to add the ProductCode on the pages, you will need these files: plugins/productsinrow/productsinrow.php templates/productsinrow.tpl templates/products_list.tpl templates/products_more.tpl Open plugins/productsinrow/productsinrow.php and find: list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'] ) = $aData[$i]; change it to: list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'] , $aList['sProductCode] ) = $aData[$i]; Now open templates/productsinrow.tpl and find: <!-- BEGIN LIST_LIST --> <td> <h2><a href="?p=productsMore&iProduct=$aList[iProduct]&sName=$aList[sNameUrl]">& #36;aList[sName]</a></h2> $aList[sPhoto] <h5>$aList[sCategories]</h5> and right below that add: <br><strong><font color="red">$lang[ProductCode]: $aList[sProductCode]</font></strong> Now open templates/products_list.tpl and find: <!-- BEGIN LIST_LIST --> <div class="entry"> <h2><a href="?p=productsMore&iProduct=$aList[iProduct]&sName=$aList[sNameUrl]" title="$aList[sName]">$aList[sName]</a></h2> <h5>$aList[sCategories]</h5> $aList[sPhoto] and right below that add: <br><strong><font color="red">$lang[ProductCode]: $aList[sProductCode]</font></strong> Now open templates/products_more.tpl and find: <h5>$aData[sCategories]</h5> <h2>$aData[sName]</h2> $aFiles[sPhotosDefault] and right below that add: <br><strong><font color="red">$lang[ProductCode]: $aList[sProductCode]</font></strong> And that's about it.
KiralyVlad 2006-11-11 21:13
SEEMS MY INITIAL POST GOT DELETED, SO I'M POSTING EVERYTHING AT ONCE. **WARNING !! IN ORDER FOR THIS TO WORK YOU NEED TO DISABLE PRODUCTATTRIBUTES PLUGIN !!! I will do my best to make it work in conjunction with the ProductAttributes plugin. Okay, Here is the way to assign a product code field for each of your products. You will need these template files: templates/admin/products_form.tpl templates/admin/products_list.tpl and these script files: core/products-admin.php core/products-ff.php core/products.php First of all, you will have to open your language file, which is located in lang/ and the country code of your selected language (lang/de.php for german for example). There, find this: $lang['stat_price'] and right under it add: $lang['ProductCode'] = 'Product Code'; instead of 'Product Code' you can add the translation in your language. Now open templates/admin/products_form.tpl and find: Array( Array( 'sName' ) ,Array( 'aCategories[]' ) ,Array( 'fPrice', 'float' ) ,Array( 'sDescriptionShort' ) ,Array( 'iPosition', 'int', '-99', null, '>=', 'false' ) ,Array( 'iPosition', 'int', '999', null, '=<', 'false' ) ) );"> and change it to: Array( Array( 'sName' ) ,Array( 'aCategories[]' ) ,Array( 'fPrice', 'float' ) ,Array( 'sDescriptionShort' ) ,Array( 'iPosition', 'int', '-99', null, '>=', 'false' ) ,Array( 'iPosition', 'int', '999', null, '=<', 'false' ) ,Array( 'sProductCode' ) ) );"> then find: <td> <input type="text" name="sName" value="$aData[sName]" size="70" /> </td> </tr> and add right under it: <!-- productcode --> <tr> <td style='text-align: right; padding: 5px;'> <strong>$lang[ProductCode]: </strong> </td> <td> <input type="text" name="sProductCode" value="$aData[sProductCode]" size="15" maxlenght="8" class="input" /> </td> </tr> <!-- end productcode --> Now open up templates/admin/products_list.tpl and find: <td> ID </td> <td> $lang[Name] </td> and change it to: <td> ID </td> <td> $lang[ProductCode] </td> <td> $lang[Name] </td> and find: <td> $aList[iProduct] </td> <td class="listbodystatus_$aList[iStatus]"> <a href="?p=$aActions[g]Form&iProduct=$aList[iProduct]">$aList[sName]</a>< br /> </td> change it to: <td> $aList[iProduct] </td> <td> $aList[sProductCode] </td> <td class="listbodystatus_$aList[iStatus]"> <a href="?p=$aActions[g]Form&iProduct=$aList[iProduct]">$aList[sName]</a>< br /> </td> then find: <td colspan="6"> $lang[Pages]: $aList[sPages] </td> and change it to: <td colspan="7"> $lang[Pages]: $aList[sPages] </td> Now for the scripting part. Open core/products.php and find: for( $i = 0; $i < $iCount; $i++ ){ list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'], ) = $aData[$i]; change it to: for( $i = 0; $i < $iCount; $i++ ){ list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'], $aList['sProductCode'] ) = $aData[$i]; then find: if( empty( $aList['sDescriptionShort'] ) ) $aList['sDescriptionShort'] = ' '; else $aList['sDescriptionShort'] = ereg_replace( '\|n\|', '', $aList['sDescriptionShort'] ); and right under it add: if( empty( $aList['sProductCode'] ) ) $aList['sProductCode'] = ' '; else $aList['sProductCode'] = ereg_replace( '\|n\|', '', $aList['sProductCode'] ); then find: $aList['sDescriptionFull'] = $aList[1]; list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'], ) = $aData; and change it to: $aList['sDescriptionFull'] = $aList[1]; list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'], $aList['sProductCode'] ) = $aData; Now open core/products-admin.php and find: $aForm['sDescriptionShort'] = changeTxt( $aForm['sDescriptionShort'], 'Nds' ); $aForm['sDescriptionFull'] = changeTxt( $aForm['sDescriptionFull'], 'Nds' ); and right under it add: $aForm['sProductCode'] = changeTxt( $aForm['sProductCode'], 'Nds' ); Then open core/products-ff.php and find: global $oFF; extract( $aForm ); $oFF->setRow( Array( $iProduct, $sName, $fPrice, $sDescriptionShort, $iStatus, $iPosition ) ); $oFF->setData( Array( 5, 1, 0, 2, 3, 4 ) ); and change it to: global $oFF; extract( $aForm ); $oFF->setRow( Array( $iProduct, $sName, $fPrice, $sDescriptionShort, $iStatus, $iPosition, $sProductCode ) ); $oFF->setData( Array( 5, 1, 0, 2, 3, 4, 6 ) ); And you're done... you will now see a new field in the "products" page from your administration panel.... Click on one of the products (or on the edit icon), that will take you to the edit page, and there you will see your new field called the way you translated it earlier in your language file. Add your product code, and save the file. You will now see the product code for the product you've edited on the products page. If you want to add the ProductCode on the pages the client sees, you will need these files: plugins/productsinrow/productsinrow.php templates/productsinrow.tpl templates/products_list.tpl templates/products_more.tpl Open plugins/productsinrow/productsinrow.php and find: list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'] ) = $aData[$i]; change it to: list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'] , $aList['sProductCode] ) = $aData[$i]; Now open templates/productsinrow.tpl and find: <!-- BEGIN LIST_LIST --> <td> <h2><a href="?p=productsMore&iProduct=$aList[iProduct]&sName=$aList[sNameUrl]">& amp; #36;aList[sName]</a></h2> $aList[sPhoto] <h5>$aList[sCategories]</h5> and right below that add: <br><strong><font color="red">$lang[ProductCode]: $aList[sProductCode]</font></strong> Now open templates/products_list.tpl and find: <!-- BEGIN LIST_LIST --> <div class="entry"> <h2><a href="?p=productsMore&iProduct=$aList[iProduct]&sName=$aList[sNameUrl]" title="$aList[sName]">$aList[sName]</a></h2> <h5>$aList[sCategories]</h5> $aList[sPhoto] and right below that add: <br><strong><font color="red">$lang[ProductCode]: $aList[sProductCode]</font></strong> Now open templates/products_more.tpl and find: <h5>$aData[sCategories]</h5> <h2>$aData[sName]</h2> $aFiles[sPhotosDefault] and right below that add: <br><strong><font color="red">$lang[ProductCode]: $aList[sProductCode]</font></strong> Now edit the templates/products_print.tpl and find: <h5>$aData[sCategories]</h5> <h2>$aData[sName]</h2> $aFiles[sPhotosDefault] and add right below it: <br><strong><font color="red">$lang[ProductCode]: $aList[sProductCode]</font></strong> The above procedure allows you to show the product code on the products page, the product print page, and the detailed product page (the page you see when you click on a product). I've encountered some dificulties in showing the product code in the basket, and in the orders print (as well as the e-mail sent to customer, because the script that does that actualy sends the orders_print page). I will post the way to add the code in these pages when I`m through with it.
KiralyVlad 2006-11-14 18:47
Ok... I've found the way to show the product code in the orders_basket, orders_delivery and orders_print pages as well.... You will need these files: core/orders-ff.php core/orders.php templates/orders_basket.tpl templates/orders_delivery.tpl templates/orders_print.tpl Open core/orders-ff.php and find: if( !function_exists( 'dbAddOrderProduct' ) ){ /** * Add product to basket * @return void * @param array $aProduct * @param int $iQuantity * @param int $iOrder */ function dbAddOrderProduct( $aProduct, $iQuantity, $iOrder ){ global $oFF; $iElement = throwLastId( DB_ORDERS_PRODUCTS, 0 ) + 1; $oFF->setRow( Array( $iElement, $iOrder, $aProduct['iProduct'], $iQuantity, $aProduct['fPrice'], $aProduct['sName'] ) ); $oFF->addToFile( DB_ORDERS_PRODUCTS, 'end' ); change it to: if( !function_exists( 'dbAddOrderProduct' ) ){ /** * Add product to basket * @return void * @param array $aProduct * @param int $iQuantity * @param int $iOrder */ function dbAddOrderProduct( $aProduct, $iQuantity, $iOrder ){ global $oFF; $iElement = throwLastId( DB_ORDERS_PRODUCTS, 0 ) + 1; $oFF->setRow( Array( $iElement, $iOrder, $aProduct['iProduct'], $iQuantity, $aProduct['fPrice'], $aProduct['sName'], $aProduct['sProductCode'] ) ); $oFF->addToFile( DB_ORDERS_PRODUCTS, 'end' ); then find: if( !function_exists( 'dbSaveOrderProduct' ) ){ /** * Save product to file * @return void * @param array $aData */ function dbSaveOrderProduct( $aData ){ global $oFF; $oFF->setRow( Array( $aData[0], $aData[1], $aData[2], $aData[3], $aData[4], $aData[5] ) ); $oFF->changeInFile( DB_ORDERS_PRODUCTS, $aData[0], 0 ); } // end function dbSaveOrderProduct change it to: if( !function_exists( 'dbSaveOrderProduct' ) ){ /** * Save product to file * @return void * @param array $aData */ function dbSaveOrderProduct( $aData ){ global $oFF; $oFF->setRow( Array( $aData[0], $aData[1], $aData[2], $aData[3], $aData[4], $aData[5], $aData[6] ) ); $oFF->changeInFile( DB_ORDERS_PRODUCTS, $aData[0], 0 ); } // end function dbSaveOrderProduct then find: function dbSaveOrderProducts( $aElements ){ $aFile = file( DB_ORDERS_PRODUCTS ); $rFile = fopen( DB_ORDERS_PRODUCTS, 'w' ); $iCount = count( $aFile ); for( $i = 0; $i < $iCount; $i++ ){ if( $i > 0 ){ $aFile[$i] = rtrim( $aFile[$i] ); $aExp = explode( '$', $aFile[$i] ); if( isset( $aElements[$aExp[0]] ) && $aElements[$aExp[0]] >= 1 ) $aFile[$i] = $aExp[0].'$'.$aExp[1].'$'.$aExp[2].'$'.sprintf( '%01.0f', $aElements[$aExp[0]] ).'$'.$aExp[4].'$'.$aExp[5].'$'."\n"; else $aFile[$i] .= "\n"; } change it to: function dbSaveOrderProducts( $aElements ){ $aFile = file( DB_ORDERS_PRODUCTS ); $rFile = fopen( DB_ORDERS_PRODUCTS, 'w' ); $iCount = count( $aFile ); for( $i = 0; $i < $iCount; $i++ ){ if( $i > 0 ){ $aFile[$i] = rtrim( $aFile[$i] ); $aExp = explode( '$', $aFile[$i] ); if( isset( $aElements[$aExp[0]] ) && $aElements[$aExp[0]] >= 1 ) $aFile[$i] = $aExp[0].'$'.$aExp[1].'$'.$aExp[2].'$'.sprintf( '%01.0f', $aElements[$aExp[0]] ).'$'.$aExp[4].'$'.$aExp[5].'$'.$aExp[5].'$'."\n"; else $aFile[$i] .= "\n"; } Now open core/orders.php and find in the listBasket function: for( $i = 0; $i < $iCount; $i++ ){ list( $aList['iElement'], $aList['iOrder'], $aList['iProduct'], $aList['iQuantity'], $aList['fPrice'], $aList['sProduct'] ) = $aData[$i]; change it to: for( $i = 0; $i < $iCount; $i++ ){ list( $aList['iElement'], $aList['iOrder'], $aList['iProduct'], $aList['iQuantity'], $aList['fPrice'], $aList['sProduct'] , $aList['sProductCode']) = $aData[$i]; Now open your template files: Open templates/orders_basket.tpl and find: <td> <a href="?p=productsMore&iProduct=$aList[iProduct]">$aList[sProduct]</a> </td> change it to: <td> <a href="?p=productsMore&iProduct=$aList[iProduct]">$aList[sProduct]<br><fo nt color="red">($aList[sProductCode])</font></a> </td> then open templates/orders_delivery.tpl and find: <td> <a href="?p=productsMore&iProduct=$aList[iProduct]">$aList[sProduct]</a> </td> change it to: <td> <a href="?p=productsMore&iProduct=$aList[iProduct]">$aList[sProduct]<br><fo nt color="red">($aList[sProductCode])</font></a> </td> now open templates/orders_print.tpl and find: <td> $aList[sProduct] </td> change it to: <td> $aList[sProduct]<br><font color="red">($aList[sProductCode])</font> </td> and you're done.