Author Topic: Print cart?  (Read 37059 times)

Pisu

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 451
  • ..still looking for..
    • Blog di Stefano Bagnatica
Print cart?
« on: January 25, 2007, 10:16:42 am »
Hi, has someone made an hack / component to print the cart content? I mean, that you go to cart, click on a "PRINT" button and a window is opened with printable-format cart content... It will be very useful for us, to give a estimate document to customers that ask for prices in our shop.

Update 11/09/2007: I'm attaching the updated package for printing the cart; updated for VirtueMart 1.0.12
Compatibly also with VM 1.0.13

[attachment cleanup by admin]
Pisu - Team VMItalia (Supporto Italiano VirtueMart)
www.stefanobagnatica.it | www.vmitalia.net

Bolle

  • Jr. Member
  • **
  • Posts: 54
Re: Print cart?
« Reply #1 on: January 25, 2007, 12:23:07 pm »
hi pisu,

try together ok!

in my template basket_b2b_html.php i put this on the first

Code: [Select]
<?
// Set-up the parameters object for print-icon.
$params = & new mosParameters( '' );
$params->def( 'print', true );
$params->def( 'popup', false );
$params->def( 'icons', true );

// link used by print button
$print_link = $mosConfig_live_site. '/index2.php?option=com_virtuemart&task=details&did=' . $row->id .'&pop=1&page='. $page . $row->Itemid_link;

// Draw the Print icon.
mosHTML::PrintIcon( $row, $params, false,$print_link );

now the popup to print work and the output of busket ist ok,

but the print link in the popup don't work?

any idea?

Bolle

Bolle

  • Jr. Member
  • **
  • Posts: 54
Re: Print cart?
« Reply #2 on: January 25, 2007, 14:46:07 pm »
hi pisu,

i have found another solution of this.

i have try this and it works fine  ;).

Code: [Select]
<?
// Set-up the parameters object.
global $option, $hide_js;;

$popup = intval( mosGetParam( $_REQUEST, 'popup', 0 ) );

$row = new stdClass; // I don't think $row is used at all.

$params = new mosParameters( '' );

// if set to 0, there won't be a print icon at all
$params->set( 'print', '1' );

// set to 0 to use text instead of icon.
$params->set( 'icons', '1' );

// if set to 1, this will invoke the browser's print function.
$params->set( 'popup', $popup );

// lookup sefRelToAbs in the forum if you don't know what it does
$link = $mosConfig_live_site.'/index2.php?option=com_virtuemart&popup=1&page=shop.cart';
$status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,'
. 'resizable=yes,width=640,height=480,directories=no,location=no';
// Draw the Print icon.
mosHTML::PrintIcon( $row, $params, $hide_js, $link, $status );
?>

Bolle

Pisu

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 451
  • ..still looking for..
    • Blog di Stefano Bagnatica
Re: Print cart?
« Reply #3 on: January 25, 2007, 19:39:49 pm »
Thank you bolle! This is a nice beginning, I'll try to do some changes...
There are some problems to resolve, in the print windows:

  • remove buttons (print,edit,delete) and entire column "Actions"
  • remove the coupont message and textbox
  • remove the checkout button
  • add shop title and reference (address and so on...)
  • in case user in logged, add user infos

What do you think of this? I think this can become an official function in VM...
Pisu - Team VMItalia (Supporto Italiano VirtueMart)
www.stefanobagnatica.it | www.vmitalia.net

Bolle

  • Jr. Member
  • **
  • Posts: 54
Re: Print cart?
« Reply #4 on: January 25, 2007, 22:32:53 pm »
hi pisu,

 ;D

yes thats right.

i have an idea, because the images in cart.

you make an extra link in the cart with name for example "show/hide images"
if you click on this link or button you can hidden the images.

i think it is a better solution because any customers like print with images.
so can everybody choose the output and after click on the print icon.

the link is an fake link <a href="#"...> generated with a javascript function

for the images i use an div tag with id for hidden the elements on click.

if i have a concret solution i poste here again.

Bolle

Pisu

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 451
  • ..still looking for..
    • Blog di Stefano Bagnatica
Re: Print cart?
« Reply #5 on: January 26, 2007, 12:08:55 pm »
Yes bolle I understand you idea, and it's quite easy to do. But I think that there are few customers that want to print cart; in my opinion, this feature can be more useful to shoppers that want to print somewhat to customers that come in "real" shop. And in this case, images are not a real need... But, it could be another feature to add!
Pisu - Team VMItalia (Supporto Italiano VirtueMart)
www.stefanobagnatica.it | www.vmitalia.net

Bolle

  • Jr. Member
  • **
  • Posts: 54
Re: Print cart?
« Reply #6 on: January 26, 2007, 13:26:01 pm »
hi pisu,

i have not another solution because i can not deliver any input on the popup

i must clear the output before i click on the print icon thats the problem.

i must ensure that the customer can checkout.

so i can not hidde the images always with a setting there without images(link) can't checkout!

or have you another solution to this problem.

Bolle

Pisu

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 451
  • ..still looking for..
    • Blog di Stefano Bagnatica
Re: Print cart?
« Reply #7 on: January 26, 2007, 15:53:38 pm »
Soon I'll work on this. I'll try to understand what variables are passed to the page to be converted in printer-friedly, and add some PHP if conditions, to remove undesidered elements in print page.
Pisu - Team VMItalia (Supporto Italiano VirtueMart)
www.stefanobagnatica.it | www.vmitalia.net

Fredrik Larsson

  • Beginner
  • *
  • Posts: 21
Re: Print cart?
« Reply #8 on: January 29, 2007, 23:47:10 pm »
Thanks for the help! This is what I was looking for to. I also figured out how to disable the "Checkout" since my shop doesn't take any order but only allow to print lists. If you figure out the parameters and how to remove them on the "popup" page I would like to know. Additionally those parameters might be something that should be explained on the wiki...

Pisu

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 451
  • ..still looking for..
    • Blog di Stefano Bagnatica
Re: Print cart?
« Reply #9 on: February 02, 2007, 12:11:26 pm »
Ok I made somewhat (very simple in fact)! I passed the variable "print" to the opened popup window, in order to remove all thing I didn't want.

In template (basket_b2c.html.php for tax display, basket_b2c.html.php for no tax), added this code (Tnx to Bolle, note '&print=1' in $link variable) before table begins:

Code: [Select]
if (empty($_REQUEST['print'])) {
/* STAMPA CARRELLO */
global $option, $hide_js;

$popup = intval( mosGetParam( $_REQUEST, 'popup', 0 ) );

$row = new stdClass; // I don't think $row is used at all.

$params = new mosParameters( '' );

// if set to 0, there won't be a print icon at all
$params->set( 'print', '1' );

// set to 0 to use text instead of icon.
$params->set( 'icons', '1' );

// if set to 1, this will invoke the browser's print function.
$params->set( 'popup', $popup );

// lookup sefRelToAbs in the forum if you don't know what it does
$link = $mosConfig_live_site.'/index2.php?option=com_virtuemart&popup=1&print=1&page=shop.cart';
$status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,'
. 'resizable=yes,width=640,height=480,directories=no,location=no';
// Draw the Print icon.
mosHTML::PrintIcon( $row, $params, $hide_js, $link, $status );
}

Then, I put these if conditions, in order to remove ACTIONS column:
Code: [Select]
<?php if (empty($_REQUEST['print'])) { ?>
<th colspan="2" align="center"><?php echo $VM_LANG->_PHPSHOP_CART_ACTION ?></th>
<?php ?>
and:
Code: [Select]
<?php if (empty($_REQUEST['print'])) { ?>
    <td><?php echo $product['update_form'?></td>
    <td><?php echo $product['delete_form'?></td>
<?php ?>

In order to replace quantity box with simple quantity number:
Code: [Select]
<?php if (empty($_REQUEST['print'])) { ?>
<?php echo $product['quantity_box'?>
<?php } else { ?>
<?php echo $product['quantity'?>
<?php ?>

But this, need a addition in basket.php, line 112:
Code: [Select]
$product_rows[$i]['quantity'] = $cart[$i]["quantity"];

Returning to basket template (basket_b2c.html.php), before closing table tag (</TABLE>) added a "Print" button that appear only in popup window, and not display in print:
Code: [Select]
  <?php if (!empty($_REQUEST['print'])) { ?>
<style type="text/css" media="print">
.noprintme { display:none }
</style>
  <tr>
    <td colspan="7" style="text-align:center"><input type="button" value="<?php echo _CMN_PRINT?>" onclick="window.print()" class="noprintme"></td>
  </tr>
  <?php ?>

Again in basket.php, in order to remove box for coupon insertion, at line 258:
Code: [Select]
if (empty($_REQUEST['print'])) {
        /* Input Field for the Coupon Code */
        if( PSHOP_COUPONS_ENABLE=='1'
                && !@$_SESSION['coupon_redeemed']
                && ($page == "shop.cart"
                        || @$checkout_this_step == CHECK_OUT_GET_PAYMENT_METHOD
                        || @$checkout_this_step == CHECK_OUT_GET_SHIPPING_ADDR && CHECKOUT_STYLE != 3
                        || @$checkout_this_step == CHECK_OUT_GET_SHIPPING_METHOD && CHECKOUT_STYLE == 3
                        )
) { 
include (PAGEPATH."coupon.coupon_field.php");
}
}

At last, I wished to remove checkout links; so open shop.cart.php, line 49, and change this way:
Code: [Select]
if ($cart["idx"] && empty($_REQUEST['print'])) {


So the link section is not displayed if in print window.

OK for now it's enough... waiting for comments. I'm attaching modified files.

PS: this is my 100th message, I'm now Full Member, yuppi!

[attachment cleanup by admin]
Pisu - Team VMItalia (Supporto Italiano VirtueMart)
www.stefanobagnatica.it | www.vmitalia.net

Bolle

  • Jr. Member
  • **
  • Posts: 54
Re: Print cart?
« Reply #10 on: February 02, 2007, 13:56:09 pm »
hi Pisu,

thx for the first hack of this topic.

i try to test it and post my opinion again.

congratulation to your full member status  ;D.

Bolle

Bolle

  • Jr. Member
  • **
  • Posts: 54
Re: Print cart?
« Reply #11 on: February 02, 2007, 14:07:05 pm »
hi Pisu,

ok i test your solution (hack)

nice! nice! nice!  :P

the following is in my opinion unnecessary.

suggestion:

1. remove the pruduct_link on popup, because the costumer can not go back.

- i haven't the problem, because i have a back button on flypage only the image_link is the problem.

Bolle

Pisu

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 451
  • ..still looking for..
    • Blog di Stefano Bagnatica
Re: Print cart?
« Reply #12 on: February 02, 2007, 16:22:32 pm »
oook you're right. Not because customers can't go back, but because in a print window nobody needs to follow links, but only to print. So here the solution:

In basket.php, around line 80, add:
Code: [Select]
$product_rows[$i]['product_name_nolink'] = "<strong>". $ps_product->get_field($_SESSION['cart'][$i]["product_id"], "product_name") . "</strong>";
In template (basket_b2c.html.php), line 60:
Code: [Select]
<td><?php
if (empty($_REQUEST['print'])) {
echo $product['product_name'] . $product['product_attributes'];
} else {
echo $product['product_name_nolink'] . $product['product_attributes'];
}
?>
</td>
Pisu - Team VMItalia (Supporto Italiano VirtueMart)
www.stefanobagnatica.it | www.vmitalia.net

Bolle

  • Jr. Member
  • **
  • Posts: 54
Re: Print cart?
« Reply #13 on: February 02, 2007, 16:48:29 pm »
hi Pisu,

thx for your fast answer.

i work already on onother great feature.

i develope a coupon generator. i have create a sript (it works) but i don't know how i integrate this in VM.

can you help me please. if you want i poste you my script.

my first steps can you see here: http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=23781.0

Bolle

adriano

  • Beginner
  • *
  • Posts: 18
Re: Print cart?
« Reply #14 on: March 06, 2007, 12:26:20 pm »
I have downloaded VM_Cart_Print_Hack.zip , but i don't know hot to integrate this.
Where should i put these files ?