X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Extra Field to show on Email receipt only (https://forum.x-cart.com/showthread.php?t=12978)

rubberneck 03-23-2005 05:34 PM

Extra Field to show on Email receipt only
 
I need someone to add the following feature to my Gold 4.0.12 ASAP.

I need a field added to my items. The information in this field needs to NOT show up on the shopper end of the cart. It instead needs to be included in an email when the item is purchased. The information needs to be specific to an item. It may or may not be in each product, but when it is, it needs to be included in the invoice, ESD email, or new email.

I will pay a very reasonable rate. Please PM me if you're interested and able to do this in the next week, or if you have questions.

Thanks,
Jeff

ETInteractive.com 03-24-2005 04:37 AM

You could just add an "extra field".

Then just change your email tpl's to include that extra field.

Set "show" = N, and it wont appear on the customer side.

rubberneck 03-24-2005 02:16 PM

Field names
 
ETInteractive, thanks for the help.

Only question I have is, how do I refer to the extra field in the email templates? What's the coding to call the field?

Thanks!

ETInteractive.com 03-24-2005 05:26 PM

w/o looking into v4 tpls.

try
Code:

$product.param00

the number 00 changes based on how many extra fields you have.

starts 00, 01, 02 etc...

ill try to look in the am, if that dont work.

rubberneck 03-24-2005 05:33 PM

Thanks
 
Thanks for the followup. No luck with that.

Any other ideas?

ETInteractive.com 03-25-2005 04:34 AM

{$extra_fields[field].field}
{$extra_fields[field].field_value}

you will have to play with the value for [field]

try param00, or the paramater name like "my_extra" whatever u called it.

you can find more info in
/skin1/modules/Extra_Fields/

rubberneck 03-25-2005 09:57 AM

hmm
 
Thanks again. Still no luck in getting them to show anything.

I tried {$extra_fields[param00].field_value}, {$extra_fields[param01].field_value} and {$extra_fields[test].field_value}

Any other ideas?

ETInteractive.com 03-25-2005 11:07 AM

i guess you could try

{$extra_fields[field].field}

see what that outputs.

rubberneck 03-25-2005 12:00 PM

ugh
 
Yeah, I tried that too. Nothing.

ETInteractive.com 03-25-2005 12:12 PM

{section name=field loop=$extra_fields}
{$extra_fields[field].field} {$extra_fields[field].field_value}
{/if}
{/section}

im about out of ideas.

rubberneck 03-25-2005 12:26 PM

?
 
Ok, when I use that code, I get an error complaining about the {/if}. Don't I need an openning {if} of some sort?

Is there any reason it should matter which file I'm putting this in? Like if I put it in order_data.tpl, versus an email.tpl?

Thanks so much for all of your help.

dsparks 03-25-2005 10:15 PM

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....

rubberneck 03-27-2005 09:24 PM

hot damn!
 
That's fantastic, thanks so much. I hadn't imagined that it would be so complex.

Don't want to push my luck, but I have 2 more related questions:

1. how can I allow HTML in the extra fields? it appears to parse it out by default

2. how can I change the extra fields to a text box, instead of a single line field? I found the tpl file to edit in /modules/extra_fields, but when I change it, it does not show the existing text when I save or go back in to modify. It appears to be saving ok, just not refilling the form field

Thanks again!

rubberneck 03-27-2005 09:33 PM

oops
 
Spoke too soon. I found the answer to question number one here:

http://forum.x-cart.com/viewtopic.php?t=13801&highlight=extra+field+html


Question two remains.

I have

Quote:

{section name=field loop=$extra_fields}
<TR>
{if $productids ne ''}<TD width="15" class="TableSubHead"><INPUT type="checkbox" value="Y" name="fields[efields][{$extra_fields[field].fieldid}]"></TD>{/if}
<TD class="FormButton" nowrap>{$extra_fields[field].field}</TD>
<TD>
<textarea type="text" cols="50" rows="4" name="efields[{$extra_fields[field].fieldid}]" value="{if $extra_fields[field].is_value eq 'Y'}{$extra_fields[field].field_value|escape:"html"}{else}{$extra_fields[field].value|escape:"html"}{/if}"></textarea></TD>
</TR>
{/section}


I know it's something dumb, but just can't figure it out. Something with 'value' I assume.

rubberneck 03-27-2005 10:48 PM

finally
 
duh!

Stupid HTML mistake. Posting answer for future people. thanks to the two who helped!

Quote:

{section name=field loop=$extra_fields}
<TR>
{if $productids ne ''}<TD width="15" class="TableSubHead"><INPUT type="checkbox" value="Y" name="fields[efields][{$extra_fields[field].fieldid}]"></TD>{/if}
<TD class="FormButton" nowrap>{$extra_fields[field].field}</TD>
<TD>
<textarea type="text" cols="50" rows="4" name="efields[{$extra_fields[field].fieldid}]">{if $extra_fields[field].is_value eq 'Y'}{$extra_fields[field].field_value|escape:"html"}{else}{$extra_fields[field].value|escape:"html"}{/if}</textarea></TD>
</TR>
{/section}



balinor 03-28-2005 04:40 AM

Moving this to the Custom Mods forum.

shwekhaw 04-10-2005 11:54 AM

Hi dsparks:
It is a great mod you posted. But saving extra fields at the time of creating order does not work for me. I need to read the "realtime" extra field value at the time I print out invoice from order detail page. Could you please let me know if you know how to do it? I spent several hours and cannot get it working.

Here is what I did:
Copy and paste the following code from module/Extra_Fields/extra_fields.php into admin/order.php
Code:

$provider_condition = ($single_mode?"":" AND $sql_tbl[extra_fields].provider='$extra_fields_provider' ");
  if($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' WHERE 1 $provider_condition ORDER BY $sql_tbl[extra_fields].fieldid");
  } else {
    $extra_fields = func_query("SELECT $sql_tbl[extra_fields].* FROM $sql_tbl[extra_fields] WHERE 1 $provider_condition ORDER BY $sql_tbl[extra_fields].fieldid");
  }

  $smarty->assign("extra_fields",$extra_fields);


Then somewhere insde /mail/html/order_invoice.tpl, I paste following code from skin1/modules/Extra_Fields/product.tpl


Code:

{section name=field loop=$extra_fields}
                {if $extra_fields[field].field eq "Cost"}
                {$extra_fields[field].field}:

                {$extra_field[field].field_value}
                {/if}
                {/section }


But when I print out, it shows
Cost:
No field value is not printed. I try using $product.extra_fields instead of $extra_fields and nothing prints out.
I am newbie to x-cart still learning how to cut and paste codes. If you can please help me out with this.

shwekhaw 04-10-2005 06:44 PM

Never mind. I learnt basic SQL and spent a couple hours to write my first sql query syntax and everything solved.

S-H-W-E-K-H-A-W

shan 05-23-2005 10:36 AM

Quote:

Originally Posted by dsparks
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....


if you want to add the extra fields to the html invoices you have to do it a bit different.........


Code:

{foreach from=$product.extra_fields key=field_name item=field}

{$field.field} : {$field.field_value}

{/foreach}


junaid 10-01-2005 06:41 AM

okay here is my code but its for product.tpl i think it should work
{section name=field}
{if $extra_fields[field].active eq "Y" && $extra_fields[field].field_value}
{$extra_fields[XX].field_value}
{/if}
{/section}

remember field id does vary and may not be as in the database there do try various combinations.

also i need opinion of others on this, is there any risk showing like this or any improvement in the code.

SellPro 11-01-2005 02:03 PM

I'm trying to achieve the same effect, but I'm having some trouble. Here is the code I'm using. I know that I need the value from the second extra field for each item, but this gives me a smarty error. It's trying to use $location as a smarty tag, I just want it to be a variable. Any help?

Code:

<?
$result = mysql_query("SELECT * FROM `xcart_extra_field_values` WHERE `productid` =$product.productid and `fieldid` =2");
    while($r=mysql_fetch_array($result))
    { $location=$r["value"];
?>
<? echo $location ?>
<? } ?>


DVDirect 12-13-2005 07:05 PM

Hi Everyone,

I have added this code to my site and added the code from Shan

Quote:

if you want to add the extra fields to the html invoices you have to do it a bit different.........


Code:
{foreach from=$product.extra_fields key=field_name item=field}

{$field.field} : {$field.field_value}

{/foreach}

I have placed the above code in
/mail/html/order_data.tpl I hope this is the correct place.

Now my question is what is the code to include in a html email that calls this ectra field information. In my case it is extra field "6"

Any assistance would be greatly appreciated.

Regards,
Andrew

DVDirect 12-18-2005 09:06 PM

FYI... v4.0.15

This is what you can add to your .tpl files to call the Extra Field Data:

In /customer/main/product.tpl you have the followiing calling the Extra Field Data:

Code:

{if $active_modules.Extra_Fields ne ""}
    {include file="modules/Extra_Fields/product.tpl"}
{/if}


Included code in /modules/Extra_Fields/product.tpl

Code:

{* $Id: product.tpl,v 1.7 2004/05/28 12:21:07 max Exp $ *}
{section name=field loop=$extra_fields}
{if $extra_fields[field].active eq "Y" && $extra_fields[field].field_value}
<TR><TD width="30%">
{$extra_fields[field].field}
</TD>
<TD>
{$extra_fields[field].field_value}
</TD>
</TR>
{/if}
{/section}


This justs lists the Extra Data fields on the Product Detail Page.

So to get just the Extra Field you want use the Extra Field ROW#. In Admin you have Extra Field you can add... if the data is in the 3rd row then use '03' inplcase of [field] in the code below... you can use 01,02,03,04,05 etc for represented rows.

Extra field Title:
Code:

{$extra_fields[field].field}
=
{$extra_fields[03].field}


Extra Field Value:
Code:

{$extra_fields[field].field_value}
=
{$extra_fields[03].field_value}


The Other thing you can do is just qualify the Title to make sure that you are displaying the correct ROW incase you have changed the Title to something else.

Taken from above code in /modules/Extra_Fields/product.tpl

Extra Field Title to display only = Test Title

Code:

{section name=field loop=$extra_fields}
{if $extra_fields[field].active eq "Y" && $extra_fields[field].field_value}
{if $extra_fields[field].field eq "Test Title"}
<TR><TD width="30%">
{$extra_fields[field].field}
</TD>
<TD>
{$extra_fields[field].field_value}
</TD>
</TR>
{/if}
{/if}
{/section}


Regards,
Marko


All times are GMT -8. The time now is 01:21 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.