Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Display product extra field data on Invoice

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 10-11-2013, 02:29 PM
  Wazowski's Avatar 
Wazowski Wazowski is offline
 

Advanced Member
  
Join Date: Jan 2011
Posts: 51
 

Default Re: Display product extra field data on Invoice

Thanks man!
__________________
X-Cart version 4.5.5
Reply With Quote
  #12  
Old 07-29-2014, 09:48 AM
  mcanitano's Avatar 
mcanitano mcanitano is offline
 

eXpert
  
Join Date: Feb 2006
Location: Melbourne, FL
Posts: 216
 

Question Re: Display product extra field data on Invoice

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.
Attached Thumbnails
Click image for larger version

Name:	cost.png
Views:	533
Size:	10.7 KB
ID:	3847  
__________________
Marcello Canitano
New Site: X-Cart v4.5.5 GOLD
X-Cart Mobile v1.4.3
X-Payments v1.0.6
CDSEO Pro v2
Total Server Solutions xCDN

www.silverhorseracing.com
Reply With Quote
  #13  
Old 09-07-2014, 06:26 AM
 
xtech xtech is offline
 

X-Adept
  
Join Date: Jun 2010
Posts: 605
 

Default 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?
__________________
X-cart Platinum
4.6.1
Reboot template
Reply With Quote
  #14  
Old 05-28-2017, 07:18 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Default 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 ?
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #15  
Old 05-28-2017, 05:09 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default 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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #16  
Old 05-29-2017, 11:33 PM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Default 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 ?
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #17  
Old 05-30-2017, 08:12 AM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default 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
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #18  
Old 05-31-2017, 05:45 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Default 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 ?
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #19  
Old 05-31-2017, 12:19 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Display product extra field data on Invoice

Yes, it probably will work.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #20  
Old 06-06-2017, 12:29 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Thumbs up Re: Display product extra field data on Invoice

Hi cherie,
Thanks a lot. Your suggestion did work

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

        } 
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote

The following user thanks anandat for this useful post:
cherie (06-06-2017)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:04 PM.

   

 
X-Cart forums © 2001-2020