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
  #1  
Old 04-17-2012, 01:18 PM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default Display product extra field data on Invoice

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)
Attached Files
File Type: pdf XC8635.pdf (25.0 KB, 580 views)
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #2  
Old 04-17-2012, 04: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

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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #3  
Old 04-17-2012, 05:42 PM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #4  
Old 04-17-2012, 05:45 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

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>
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #5  
Old 04-18-2012, 12:05 PM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #6  
Old 04-18-2012, 12: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

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).
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following user thanks cherie for this useful post:
tartaglia (04-20-2012)
  #7  
Old 04-20-2012, 08:28 AM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #8  
Old 04-20-2012, 08:34 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

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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #9  
Old 04-20-2012, 09:06 AM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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.
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #10  
Old 03-12-2013, 09:29 AM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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.
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote

The following 6 users thank tartaglia for this useful post:
Claraweb (03-12-2013), DS21 (11-24-2020), mcanitano (07-28-2014), qualiteam (05-29-2017), testing (04-12-2018), Wazowski (10-11-2013)
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 11:41 AM.

   

 
X-Cart forums © 2001-2020