Jump to content

{Resolved] How to show description on print out invoice?


bosanci28

Recommended Posts

Considering the product's 'description' is, as stored in the Order Summary table, 'basket' column, the HTML tags are stripped and the result is truncated to 255 characters. Why? I do not know. There is no limit to the size of this string that can be serialized (other than the total space allocated to the database table 'basket' column -- 64KiB).

The inventory 'description' could be wickedly detailed and rather lengthy. Later versions of CC6 allow for a "Short Description" that can be used for tight spaces, such as product panels in a category page, reviewing cart contents during checkout, and line items on shipping manifests.

Also realize that once the order is made, the 'basket' column is the only permanent record of the order's original contents. The admin can add, update, and/or delete the order's contents at any time.

Also realize that at any time, such as after the order is paid for, the admin can change the description of that inventory item.

So, we have a decision to make:
* change the way the order's item's description is stored in 'basket' to retain the full HTML
* use the plain truncated description
* use the short description (has HTML)
* fetch the current (short) description from the Inventory table

Then, we need to decide:
* use the 'basket' from Order Summary table, or
* use the Order Inventory table, which then requires us to fetch the current descriptions.

Your solution depends, of course, entirely on your business needs. But we need to get the approach nailed down to avoid unnecessary work.

Link to comment
Share on other sites

Hello Bsmither! and thank you for replying.

I guess:

"* fetch the current (short) description from the Inventory table"

and on the second one ,not sure exactly witch one will be easy to do.

So like this is the main product page witch a client see before making the purchase:

9zwqs1.jpg

So those few lines to appear in the print invoice, Is good to have as proof of whatever they got.

I am thinking whatever is easier to do and to show that short description on the invoice when i print out

to include one in the package that will send out to client.

 

Thank you!

 

Link to comment
Share on other sites

Ok, so assuming you will not be changing the inventory description, we will use that.

In the file /admin/sources/orders.index.inc.php:

Near line 461, find:

if (($summaries = $GLOBALS['db']->select('CubeCart_order_summary', false, array('cart_order_id' => $order_list))) !== false) {
  foreach ($summaries as $key => $summary) {
    $summary['raw'] = $summary;
    $GLOBALS['smarty']->assign('PAGE_TITLE', (count($_GET['print'])>1) ? $lang['orders']['title_invoices'] : sprintf($lang['orders']['title_invoice_x'], $summary['cart_order_id']));
    if (($inventory = $GLOBALS['db']->select('CubeCart_order_inventory', false, array('cart_order_id' => $summary['cart_order_id']))) !== false) {
      foreach ($inventory as $item) {
        $item['raw'] = $item;

Add after:
        $inventory_desc = $GLOBALS['db']->select('CubeCart_inventory',array('description','description_short'),array('product_id'=>$item['product_id']));
        $item['description'] = $inventory_desc[0]['description'];
        $item['description_short'] = $inventory_desc[0]['description_short'];
        // Does not take into account any translations of the inventory description.

Next, we need to add the data variable to the template. In the admin template orders.print.php:

Find near line 50:

{foreach from=$order.items item=item}
<div class="product">
  <span class="price">{$item.price}</span>{$item.quantity} &times; {$item.name} {if !empty($item.product_code)}({$item.product_code}){/if}
  {if isset($item.options)}
  <ul>
  {foreach from=$item.options item=option}
    <li>{$option}</li>
  {/foreach}
  </ul>
  {/if}
</div>
{/foreach}

Insert the following variable where you want the description to be seen:
{$item.description} or {$item.description_short}

 

Edited by bsmither
Syntax error
Link to comment
Share on other sites

Hello,

I try it and looks like the first code , while in admin and wanted to click on "orders" it goes in 500 error white page.

/admin/sources/orders.index.inc.php

My code:

	// Hook
	foreach ($GLOBALS['hooks']->load('admin.order.index.display') as $hook) include $hook;
	$GLOBALS['smarty']->assign('PLUGIN_TABS', $smarty_data['plugin_tabs']);
	$GLOBALS['smarty']->assign('DISPLAY_FORM', true);

} else if (isset($_GET['print']) && !empty($_GET['print'])) {
		// Generate a printable page, and display it
		// Made somewhat trickier by the way the templating system works
		// so we'll generate the page, stick it in the cache folder, trigger the print, then delete the file
		foreach ($_GET['print'] as $order_id) $order_list[] = "'".$order_id."'";

		if (($summaries = $GLOBALS['db']->select('CubeCart_order_summary', false, array('cart_order_id' => $order_list))) !== false) {
			foreach ($summaries as $key => $summary) {
				$summary['raw'] = $summary;
				$GLOBALS['smarty']->assign('PAGE_TITLE', (count($_GET['print'])>1) ? $lang['orders']['title_invoices'] : sprintf($lang['orders']['title_invoice_x'], $summary['cart_order_id']));
				if (($inventory = $GLOBALS['db']->select('CubeCart_order_inventory', false, array('cart_order_id' => $summary['cart_order_id']))) !== false) {
					foreach ($inventory as $item) {

$item['image'] = $GLOBALS['gui']->getProductImage($item['product_id'],'subcategory');

						$item['raw'] = $item;

$inventory_desc = $GLOBALS['db']->select('CubeCart_inventory','array('description','description_short'),array('product_id'=>$item['product_id']));
        $item['description'] = $inventory_desc[0]['description'];
        $item['description_short'] = $inventory_desc[0]['description_short'];
        // Does not take into account any translations of the inventory description.



						$item['item_price'] = Tax::getInstance()->priceFormat($item['price'], true);
						$item['price'] = Tax::getInstance()->priceFormat(($item['price']*$item['quantity']), true);
						if (!empty($item['product_options'])) {
							$options = ($array = cc_unserialize($item['product_options'])) ? $array : explode("\n", $item['product_options']);
							foreach ($options as $option) {
								$value = trim($option);
								if (empty($

And for that second file this is where i added :

orders.print.php

<div class="product">
		<span class="price">{$LANG.common.price}</span>
		<strong>{$LANG.common.product}</strong>
	  </div>
	  

{foreach from=$order.items item=item}
		<div class="product">
		<span class="price">{$item.price}</span><div>{$item.quantity} &times; {$item.name} {if !empty($item.product_code)}({$item.product_code}){/if}</div>
		<div style="float:left;"><img src="{$item.image}" /></div>{if isset($item.options)}
{$item.description}
		<div style="float:left;"><ul>
		{foreach from=$item.options item=option}
		<li>{$option}</li>
		{/foreach}
		</ul></div>
		{/if}
		</div>
		{/foreach}
		<div id="totals">

		<div class="total">{$LANG.basket.total_sub} <strong>{$order.subtotal}</strong></div>
		<div class="total">{$LANG.basket.total_discount} {if !empty($order.percent)}({$order.percent}){/if} <strong>{$order.discount}</strong></div>
		<div class="total">{$LANG.basket.shipping} <strong>{$order.shipping}</strong></div>
		{if isset($order.taxes)} {foreach from=$order.taxes item=tax}
		<div class="total">{$tax.name} <strong>{$tax.value}</strong></div>
		{/foreach}{/if}
		<br>

Thank you.

Edited by bosanci28
Link to comment
Share on other sites

Please make this edit (this forum's code editor is a hassle):

From:
$inventory_desc = $GLOBALS['db']->select('CubeCart_inventory','array('description','description_short')

To:
$inventory_desc = $GLOBALS['db']->select('CubeCart_inventory',array('description','description_short')

I fixed the syntax error in my post above.

Link to comment
Share on other sites

Hello,

Ok so no more error,but when i added the one line there:

{foreach from=$order.items item=item}
<div class="product">
  <span class="price">{$item.price}</span>{$item.quantity} &times; {$item.name} {if !empty($item.product_code)}({$item.product_code}){/if}
  {if isset($item.options)}
  {$item.description_short}
  <ul>
  {foreach from=$item.options item=option}
    <li>{$option}</li>
  {/foreach}
  </ul>
  {/if}
</div>
{/foreach}

Insert the following variable where you want the description to be seen:
{$item.description} or {$item.description_short}

The info from the description still does not show up. I have added there see above in code.

 

Thank you,

Link to comment
Share on other sites

In the file orders.print.php, at the very end, add:

{debug}

When you next tell CubeCart that you want to print an order's shipping invoice, along with the browser window showing the invoice, there will be another popup window showing the variables assigned to this template. (Be sure to allow window popups for your site.)

Scroll to $order and find the $items array element. Then for each item, determine if/what the description and description_short is.

Link to comment
Share on other sites

I found this:

   description => "<p>&nbsp;POWER SUPPLY</p> <p>715G3829-P03-W30-003S</p> <p>DEFECTIVE SOLD AS..."
    description_short => ""
    item_price => "$26.99"
taxes => Array (1)
  0 => Array (2)
    name => "Total Tax"
    value => "$0.00"
percent => ""

If you look at top there:

description => "<p>&nbsp;POWER SUPPLY</p> <p>715G3829-P03-W30-003S</p> <p>DEFECTIVE SOLD AS..."
    description_short => ""

that line "defective..." normally is not in my title on main website.

http://alltvparts.com/power-supply-715g3829-p03-w30-003s.html

Edited by bosanci28
Link to comment
Share on other sites

The Smarty engine truncates the display of variable values for its own purposes within the debug console. The item's 'description' is not actually truncated, and will appear in its entirety where {$item.description} is located.

But note that you have not provided a Short Description for this item. That's why it does not appear on the shipping invoice.

"that line "defective..." normally is not in my title on main website."

The product's "Name" (or "Title") is not the same as the product's "Description".

Link to comment
Share on other sites

I see, you right there! I think i never put any info in the "short description" box, just the title and the full description.

But looks like it works now, i have replaced

{$item.description_short}
to
{$item.description} 

Now not sure if this is possible,to make the description appear under the image,as if is 3 lines is okay but if is 4 lines it kind looks not aligned,so under the picture will be nice.

2 examples:

6qck69.jpg

and

28jvh4.jpg

Now i have put 5 of this: <br>

{foreach from=$order.items item=item}
		<div class="product">
		<span class="price">{$item.price}</span><div>{$item.quantity} &times; {$item.name} {if !empty($item.product_code)}({$item.product_code}){/if}</div>
		<div style="float:left;"><img src="{$item.image}" /></div>
<br>
<br>
<br>
<br>
<br>
{$item.description}
  {if isset($item.options)}

		<div style="float:left;"><ul>
		{foreach from=$item.options item=option}
		<li>{$option}</li>
		{/foreach}

	

and it looks it pushed the words down under the picture, not sure if this is the right way of doing.

Now:

2rpyxwo.jpg

and

r1hs15.jpg

Thank you.

Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...