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)

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");

        } 



All times are GMT -8. The time now is 04:54 AM.

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