X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Display product extra field data on Invoice (https://forum.x-cart.com/showthread.php?t=63314)

tartaglia 04-17-2012 01:18 PM

Display product extra field data on Invoice
 
1 Attachment(s)
We have a music store where about 2/3 of all products are sheet music. Each piece of sheet music has been sucessfully set up in X-cart 4.4.5 with extra fields for things like Orchestration, Publisher, etc. I need the ability to display some of these extra fields on the invoice (with each sheet music product ordered) so that the Admin can print it and that the customer can see it. I have gotten very close on my own but can't seem to get it to work.

Here is what I have done....

Modified: skin/common_files/mail/html/order_data.tpl to add the following lines...(inside the foreach loop that displays the product lines for each ordered product)

{*BEGIN display extra field data DAC*}
{if $active_modules.Extra_Fields}
{include file="modules/Extra_Fields/product_orchestration_invoice.tpl"}
{/if}
{*END display extra field data DAC*}

Obviously I created the file: skin/common_files/modules/Extra_Fields/product_orchestration_invoice.tpl which looks like.

{foreach from=$product.extra_fields item=v}
{*{if $v.field eq "Orchestration" and $v.active eq "Y" and $v.field_value}*}
<div>
<span>{$v.field}:{$v.field_value}</span>
</div>
{*{/if}*}
{/foreach}

Notice that I commented out the {if} statement because I was getting nothing output. Now at least I get all the Extra Field names (Orchestration, Publisher, Genre, etc.) showing under each line item of the invoice, but the field values don't display (see screenshot XC8635.pdf). (yes, I have confirmed that the products on the example invoice have values for these extra fields)

Can someone please help, I'm guessing that for some reason the names are available but not the values.

David Coggan
Carolyn Nussbaum Music Company
(getting ready to launch X-cart 4.4.5 or 4.5.0)

cherie 04-17-2012 04:09 PM

Re: Display product extra field data on Invoice
 
Maybe "active" isn't set? Do a dump of the array and see if everything is as you expect it.

I like to key off service_name since it usually never changes but the name of the field could be changed at any time.

tartaglia 04-17-2012 05:42 PM

Re: Display product extra field data on Invoice
 
Cherie,

Thanks for responding, but I'm afraid you are speaking a bit over my head. Did I mention I not really a programmer, just a logical thinker.

Can you explain how to "do a dump of the array"?

And I'm sorry, but I have no idea what you are talking about in your second comment " ..keep off service_name..". Sorry for my ignorance, can you explain a little more?

Thanks
David

cherie 04-17-2012 05:45 PM

Re: Display product extra field data on Invoice
 
Whoops, that should have been "key" instead. I edited it.

Did you look to see if "active" is actually set?

You can use something like this to see what is in $product to see if all of the extra_fields stuff is like you are expecting:
Code:

<pre>{$product|@print_r}</pre>

tartaglia 04-18-2012 12:05 PM

Re: Display product extra field data on Invoice
 
Cherie, you are being most patient with me. In which .tpl file do I put the code:

<pre>{$product|@print_r}</pre>

and...(even after your edit) I do not understand what you mean by " I like to key off service_name..."
David

cherie 04-18-2012 12:09 PM

Re: Display product extra field data on Invoice
 
You would put it in the new tpl you created where you are doing the "if" statement that is commented.

You are currently keying off "field" with $v.field eq "Orchestration" where I would use the service_name (see your Extra Fields list).

tartaglia 04-20-2012 08:28 AM

Re: Display product extra field data on Invoice
 
Cherie,

Your help and patience were amazing. I was able to use your guidance to display extra fleid data on both the invoice (mail/html/order_data.tpl) and on the product listings (customer/main/product_list.tpl) by calling modified versions of the /modules/Extra_Fields/product.tpl file. The calls determined the extra fields value to be displayed by passing the service_name.

The only that would make this better would be if I didn't make the call for "ORCHESTRATION" for example unless the product being displayed to the customer was a piece of sheet music. (If its a T-shirt, looking for orcehstartion wouldn't make sense) So basically I would love to wrap the include statement inside an IF condition based on the category of the product being displayed. Is there a way to determine the category of a product that is being displayed to the customer and use it in a IF condition? Somthing like (pseudocode)...

LOOP EachProductToBeDisplayed
Display ProductInfo
IF (Product is in CategoryA)
Display ExtraFieldA
ENDIF
END LOOP

Thanks,
David

cherie 04-20-2012 08:34 AM

Re: Display product extra field data on Invoice
 
You would have to dig into the php to get the list of categories the product is in so you could compare (if).

I think you already have a good test by looking for Orchestration since it sounds like that would never be assigned to a t-shirt.

tartaglia 04-20-2012 09:06 AM

Re: Display product extra field data on Invoice
 
Right, it works good now (thanks to you) I was just trying to be efficient in the code so it didn't look through all my extra fields on every product that was displayed every time. Seemed like a waste of computing resources. But good enough for now. Thanks again.

tartaglia 03-12-2013 09:29 AM

Re: Display product extra field data on Invoice
 
So here is an update to this ticket for all who want to be able to display extra fields on the Invoice. This is currently working on X-Cart 4.5.4 and I have more than a few people ask me how to do it. My thanks to Qualiteam and the other posters on this thread for their assistance.

Create a NEW file: /skin/<yourskin>/modules/Extra_Fields/product_extra_fields_invoice.tpl

Code:


{foreach from=$product.extra_fields item=v}
  {if $v.service_name eq $xtrafieldservicename and $v.active eq "Y" and $v.value}
    <div>
      <span style="font-style: italic;">{$v.field}:&nbsp;{$v.value}</span>
    </div>
  {/if}
{/foreach}


Then MODIFY the file: /skin/<yourskin>/mail/html/order_data.tpl
by placing the following new if statement code inside the loop:

Code:


{foreach from=$products item=product}


and after the if statement:

Code:

{if $active_modules.Gift_Registry}
          {include file="modules/Gift_Registry/product_event_invoice.tpl"}
        {/if}


Here is the code to be added.

Code:


        {if $active_modules.Extra_Fields}
          {include file="modules/Extra_Fields/product_extra_fields_invoice.tpl" xtrafieldservicename="xfieldservicename1"}
          {include file="modules/Extra_Fields/product_extra_fields_invoice.tpl" xtrafieldservicename="xfieldservicename2"}
          {include file="modules/Extra_Fields/product_extra_fields_invoice.tpl" xtrafieldservicename="xfieldservicename3"}
        {/if}


Obviously you will need to replace the values "xfieldservicename1","xfieldservicename2","xfields ervicename2" with teh actual xtrafieldservicename from your database.

Hope this helps lots of folks, being able to add extra field data easily to lots of places inside X-cart would be a great built in feature for QT to add in the future. Examples include Cart page, Invoice (shown here), WishList page, New Arrivals Page, Product listing page, etc. Maybe if this post gets lots of attention "thanks", they will consider it.

Wazowski 10-11-2013 02:29 PM

Re: Display product extra field data on Invoice
 
Thanks man!

mcanitano 07-29-2014 09:48 AM

Re: Display product extra field data on Invoice
 
1 Attachment(s)
We're trying to get our extra fields values to show in the admin product list so we can quickly edit the value (like you can with price and inventory). We created a new extra field for cost since we are a dealer of products.

I've added the following code to a new TPL file:

Code:

{foreach from=$products item=product name=prod}  {*this gets the product array*}
    {if $smarty.section.prod.index eq $smarty.foreach.prod.index} {*this makes sure the product array from /common_files/main/products.tpl *}
testing products
{foreach from=$product.extra_fields item=v}  {* gets product extra field array *}
testing extra fields
        {if $v.service_name eq "Cost" and $v.field_value}}
testing extra field of 'Cost'
<input type="text" size="9" maxlength="15" name="efields[{$v.fieldid}]" value="{if $v.is_value eq 'Y'}{$v.field_value|escape:html}{else}{$v.value|escape:html}{/if}"/>

          {else}
         
          {/if}
         
      {/foreach}
    {/if}
{/foreach}


It seems as if the product extra field array is not working, since it is not printing anything.

xtech 09-07-2014 06:26 AM

Re: Display product extra field data on Invoice
 
Quote:

Originally Posted by tartaglia
So here is an update to this ticket for all who want to be able to display extra fields on the Invoice. This is currently working on X-Cart 4.5.4 and I have more than a few people ask me how to do it. My thanks to Qualiteam and the other posters on this thread for their assistance.

Create a NEW file: /skin/<yourskin>/modules/Extra_Fields/product_extra_fields_invoice.tpl

Code:


{foreach from=$product.extra_fields item=v}
  {if $v.service_name eq $xtrafieldservicename and $v.active eq "Y" and $v.value}
    <div>
      <span style="font-style: italic;">{$v.field}:&nbsp;{$v.value}</span>
    </div>
  {/if}
{/foreach}


Then MODIFY the file: /skin/<yourskin>/mail/html/order_data.tpl
by placing the following new if statement code inside the loop:

Code:


{foreach from=$products item=product}


and after the if statement:

Code:

{if $active_modules.Gift_Registry}
          {include file="modules/Gift_Registry/product_event_invoice.tpl"}
        {/if}


Here is the code to be added.

Code:


        {if $active_modules.Extra_Fields}
          {include file="modules/Extra_Fields/product_extra_fields_invoice.tpl" xtrafieldservicename="xfieldservicename1"}
          {include file="modules/Extra_Fields/product_extra_fields_invoice.tpl" xtrafieldservicename="xfieldservicename2"}
          {include file="modules/Extra_Fields/product_extra_fields_invoice.tpl" xtrafieldservicename="xfieldservicename3"}
        {/if}


Obviously you will need to replace the values "xfieldservicename1","xfieldservicename2","xfields ervicename2" with teh actual xtrafieldservicename from your database.

Hope this helps lots of folks, being able to add extra field data easily to lots of places inside X-cart would be a great built in feature for QT to add in the future. Examples include Cart page, Invoice (shown here), WishList page, New Arrivals Page, Product listing page, etc. Maybe if this post gets lots of attention "thanks", they will consider it.


Will it work on 4.6.1 Platinum? How to call this in cart and checkout page?

anandat 05-28-2017 07:18 AM

Re: Display product extra field data on Invoice
 
Quote:

Originally Posted by tartaglia
So here is an update to this ticket for all who want to be able to display extra fields on the Invoice. This is currently working on X-Cart 4.5.4 and I have more than a few people ask me how to do it. My thanks to Qualiteam and the other posters on this thread for their assistance.

Create a NEW file: /skin/<yourskin>/modules/Extra_Fields/product_extra_fields_invoice.tpl

Code:


{foreach from=$product.extra_fields item=v}
  {if $v.service_name eq $xtrafieldservicename and $v.active eq "Y" and $v.value}
    <div>
      <span style="font-style: italic;">{$v.field}:&nbsp;{$v.value}</span>
    </div>
  {/if}
{/foreach}


Then MODIFY the file: /skin/<yourskin>/mail/html/order_data.tpl
by placing the following new if statement code inside the loop:

Code:


{foreach from=$products item=product}


and after the if statement:

Code:

{if $active_modules.Gift_Registry}
          {include file="modules/Gift_Registry/product_event_invoice.tpl"}
        {/if}


Here is the code to be added.

Code:


        {if $active_modules.Extra_Fields}
          {include file="modules/Extra_Fields/product_extra_fields_invoice.tpl" xtrafieldservicename="xfieldservicename1"}
          {include file="modules/Extra_Fields/product_extra_fields_invoice.tpl" xtrafieldservicename="xfieldservicename2"}
          {include file="modules/Extra_Fields/product_extra_fields_invoice.tpl" xtrafieldservicename="xfieldservicename3"}
        {/if}


Obviously you will need to replace the values "xfieldservicename1","xfieldservicename2","xfields ervicename2" with teh actual xtrafieldservicename from your database.

Hope this helps lots of folks, being able to add extra field data easily to lots of places inside X-cart would be a great built in feature for QT to add in the future. Examples include Cart page, Invoice (shown here), WishList page, New Arrivals Page, Product listing page, etc. Maybe if this post gets lots of attention "thanks", they will consider it.

This mod works with 4.5.4 but it's not working with 4.7.7 :(
Any one can help me please ?

cherie 05-28-2017 05:09 PM

Re: Display product extra field data on Invoice
 
Quote:

Originally Posted by anandat
This mod works with 4.5.4 but it's not working with 4.7.7 :(

A quick look at func_order_data() in func.order.php shows that it is no longer getting Extra_Fields like with earlier versions. You could see if you need to copy some code from an earlier version.

anandat 05-29-2017 11:33 PM

Re: Display product extra field data on Invoice
 
Quote:

Originally Posted by cherie
A quick look at func_order_data() in func.order.php shows that it is no longer getting Extra_Fields like with earlier versions. You could see if you need to copy some code from an earlier version.

func.order.php is big file..can't able to locate exact code....can you please help ? :-)

cherie 05-30-2017 08:12 AM

Re: Display product extra field data on Invoice
 
In that file look for "function func_order_data(..." and you'll see in older versions there is code for Extra_Fields that does not appear to be present in 4.7.7.
Most likely this was during the Extra_Field purge in 4.7.4: https://forum.x-cart.com/showthread.php?t=73783

anandat 05-31-2017 05:45 AM

Re: Display product extra field data on Invoice
 
Quote:

Originally Posted by cherie
In that file look for "function func_order_data(..." and you'll see in older versions there is code for Extra_Fields that does not appear to be present in 4.7.7.
Most likely this was during the Extra_Field purge in 4.7.4: https://forum.x-cart.com/showthread.php?t=73783



in function func_order_data sectio in 4.7.7 following code is missing
PHP Code:

if (!empty($active_modules['Extra_Fields']) && $v['is_deleted'] != 'Y') {

            
$v['extra_fields'] = func_query("SELECT $sql_tbl[extra_fields].*, $sql_tbl[extra_field_values].*, IF($sql_tbl[extra_fields_lng].field != '', $sql_tbl[extra_fields_lng].field, $sql_tbl[extra_fields].field) as field FROM $sql_tbl[extra_field_values]$sql_tbl[extra_fields] LEFT JOIN $sql_tbl[extra_fields_lng] ON $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_fields_lng].fieldid AND $sql_tbl[extra_fields_lng].code = '$shop_language' WHERE $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_field_values].fieldid AND $sql_tbl[extra_field_values].productid = '$v[productid]' AND $sql_tbl[extra_fields].active = 'Y' ORDER BY $sql_tbl[extra_fields].orderby");

        } 

So If I add above code in 4.7.7 will it work or it will still required some modification ?

cherie 05-31-2017 12:19 PM

Re: Display product extra field data on Invoice
 
Yes, it probably will work.

anandat 06-06-2017 12:29 AM

Re: Display product extra field data on Invoice
 
Hi cherie,
Thanks a lot. Your suggestion did work :D/

If any one want to get it work for 4.7.7 then just open /include/func/func.order.php
and before
PHP Code:

if ($v['extra_data']) { 

at around line number 812

Put the following code

PHP Code:

if (!empty($active_modules['Extra_Fields']) && $v['is_deleted'] != 'Y') {

            
$v['extra_fields'] = func_query("SELECT $sql_tbl[extra_fields].*, $sql_tbl[extra_field_values].*, IF($sql_tbl[extra_fields_lng].field != '', $sql_tbl[extra_fields_lng].field, $sql_tbl[extra_fields].field) as field FROM $sql_tbl[extra_field_values]$sql_tbl[extra_fields] LEFT JOIN $sql_tbl[extra_fields_lng] ON $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_fields_lng].fieldid AND $sql_tbl[extra_fields_lng].code = '$shop_language' WHERE $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_field_values].fieldid AND $sql_tbl[extra_field_values].productid = '$v[productid]' AND $sql_tbl[extra_fields].active = 'Y' ORDER BY $sql_tbl[extra_fields].orderby");

        } 


anandat 12-18-2017 10:24 PM

Re: Display product extra field data on Invoice
 
It's possible to display extra fields in invoice which has marked as "Don't show" in admin ?

Lets say my extra field No 5 has been named as "Supplier" & I don't want to display this field info to customer but in invoice I required this field value.
How to achieve this ?

Keith007 05-13-2018 05:30 AM

Re: Display product extra field data on Invoice
 
Hi All,

I been using this on version 4.6.6 and recently upgraded to ver 4.7.9
Unfortunately this is not working as it did previously

Can any one help me

Regards

Keith

BCSE 05-14-2018 06:39 AM

Re: Display product extra field data on Invoice
 
This would need to be customized. It wouldn't be hard to do though. You can drop us an email for a quote if you'd like.

https://www.bcsengineering.com/free_quote/

Thanks,

Carrie


All times are GMT -8. The time now is 03:32 PM.

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