View Single Post
  #12  
Old 03-25-2005, 10:15 PM
 
dsparks dsparks is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 34
 

Default

Well, this one was fun...

It seems that the extra field information is not saved with the order data when an order is placed or generated when the order is read back from the database.

What I did was just pull the extra field information when the order is regenerated for display.

A real fix would be to store the extra field data along with the order when it is saved in case the extra field data is changed at a later date.

Oh well, maybe next time.



To change this you will need to do the following:


1) Enable the Extra Fields module under the Administration area, Modules section.

2) Create your extra fields under the Products area, Extra Fields section

3) Then pick a product you want to test with and add some extra field data to it, and save it.

4) Change the file /include/func.php around line 2601 in function func_order_data, right after the code:


Code:
foreach ($products as $k=>$v) {

add the following additional code:

Code:
if ($active_modules["Extra_Fields"]) { $productid = $v["productid"]; $extra_fields = func_query("SELECT $sql_tbl[extra_fields].*, $sql_tbl[extra_field_values].value as field_value, IF($sql_tbl[extra_field_values].fieldid > 0, 'Y', '') as is_value FROM $sql_tbl[extra_fields] LEFT JOIN $sql_tbl[extra_field_values] ON $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_field_values].fieldid AND $sql_tbl[extra_field_values].productid = '$productid' ORDER BY $sql_tbl[extra_fields].fieldid"); } else $extra_fields = array(); $v["extra_fields"] = $extra_fields;


5) then, change the file /skin1/main/order_info.tpl around line 68 to see the extra field data on screen order displays:

after the code:
Code:
<TR> <TD valign="top">{$lng.lbl_quantity}</TD> <TD valign="top">{$products[prod_num].amount} item(s)</TD> </TR>

add this code:

Code:
{if $active_modules.Extra_Fields ne ""} {section name=field loop=$products[prod_num].extra_fields} {if $products[prod_num].extra_fields[field].field_value} <TR><TD> {$products[prod_num].extra_fields[field].field} </TD><TD> {$products[prod_num].extra_fields[field].field_value} </TD></TR> {/if} {/section} {/if}

6) then, change the file /skin1/mail/order_data.tpl around line 23, look for the code:

Code:
{/section}

which is the end section for the code section {section name=prod_num loop=$products}

and insert the following code right above it:

Code:
{if $active_modules.Extra_Fields ne ""} {section name=field loop=$products[prod_num].extra_fields} {if $products[prod_num].extra_fields[field].field_value} {$products[prod_num].extra_fields[field].field}: {$products[prod_num].extra_fields[field].field_value} {/if} {/section} {/if}


7) Find an order or create a new order that has the product with the extra field on it and is should now display the new extra field data.

I did not include an example on how to modify the html version of the invoice, but you should be able to take the code above and insert it into that file and make it work.

Also, there is no checking to see whether the SHOW flag in the extra fields maintenance is on or off, but you can add or leave that out where needed.


Hope this works for you....
__________________
X-Cart Gold: v4.0.17
Reply With Quote