Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Pictures in shopping cart


Kennith

Recommended Posts

Hi,

 

I would like to ad a miniature picture to the products in the shopping cart does anyone know if there is a contribrtion that can do that or could some one explain to mw how it could be done?

 

Regards

Kennith

Link to comment
Share on other sites

Hi,

 

I would like to ad a miniature picture to the products in the shopping cart does anyone know if there is a contribrtion that can do that or could some one explain to mw how it could be done?

 

Regards

Kennith

 

seems like several people are interested in this, so i'll jump in and take a stab at it.

 

do i understand correctly that you want the image to appear in the shopping cart box that appears in the right or left column on all pages?

 

i am assuming this to be the case, because if you actually go to the shopping cart page, catalog/shopping_cart.php, the stock osC already has the image in it.

 

so working from the assumption that you want the image in the shopping cart box, you need to modify the file "catalog/includes/boxes/shopping_cart.php". please note the path carefully, because there are several other files named "shopping_cart.php" located in different directories.

 

of course, always back up so you can recover if this doesn't work, or you make mistakes.

 

in catalog/includes/boxes/shopping_cart.php, find

		$cart_contents_string .= $products[$i]['name'] . '</span></a><br>';

 

and replace it with:

		$cart_contents_string .= $products[$i]['name'] . '</span> ' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], 30) . '</a><br>';

 

this puts a 30px wide image of the product in the shopping cart box. i leave it to you to sort out the layout.

 

cheers,

rj

Link to comment
Share on other sites

Hi Rj,

 

I tried that but nothing happened, although my code is a little different to that, & I did nothing about the layout. So it doesnt mean it wont work for someone else.

Link to comment
Share on other sites

Thank you very much rrrhythm. That was exatly what i wanted :D

 

Now that I see it I would like one thing changed when i click the miniature I go to the product page could that be changed so I instead get the big popup image instead? I have my big images in a seperate folder called big_img placed in the standard image folder.

 

Thank you for your help

Best Regards

 

Kennith

Link to comment
Share on other sites

Thank you very much rrrhythm. That was exatly what i wanted :D

 

Now that I see it I would like one thing changed when i click the miniature I go to the product page could that be changed so I instead get the big popup image instead? I have my big images in a seperate folder called big_img placed in the standard image folder.

 

Thank you for your help

Best Regards

 

Kennith

 

can be done, but i got no time to do it for you right now, although i'll sketch it out.

1. move the closing tag for the anchor (</a>) so that the image is now outside the link

$cart_contents_string .= $products[$i]['name'] . '</span></a> ' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], 30) . '<br>';

 

2.wrap the image it's own anchor (<a></a>) using the tep_href_link() function. you'll have to sort out the details. the popup is a javascript thing, so you'll have to got to product_info.php and look at how the pop-up image is handled there, and do the same thing where you want it.

 

cheers,

rj

Link to comment
Share on other sites

Hi Rj,

 

I tried that but nothing happened, although my code is a little different to that, & I did nothing about the layout. So it doesnt mean it wont work for someone else.

 

well, then something isn't right.

 

first, check your source code for the page to see if the <img> tag is coming up. it might just be that it can't find the right file.

 

otherwise, you'll have to post your code and see if we can sort it out.

 

rj

 

(ok, time to get out to the shop and actually make some stuff!)

Link to comment
Share on other sites

Thank you :thumbsup:

 

I've been short on time my self, but I had a quick look at it and I believe that I can take it from here my self. For those interessted I'll post the neeesary changes when done that should, with a bit of luck, be witin the next 24 hours ;)

 

Kennith

Link to comment
Share on other sites

Thank you :thumbsup:

 

I've been short on time my self, but I had a quick look at it and I believe that I can take it from here my self. For those interessted I'll post the neeesary changes when done that should, with a bit of luck, be witin the next 24 hours ;)

 

Kennith

 

Thanks Kennith, we'll look forward to it

Link to comment
Share on other sites

OK here's something for those of you that would like to play around with this. I've worked on the code provided by rrrythems there where a coupple of minor bugs in it. But now everything works beautifull. I haven't yet changed links to point to popup image as I mentioned ealier in the thread because that is just something I want.

 

What I have done is included a small image in the shoppingcart infobox and created some different clases to allow you to partly control the look and fee of the cart box from the stylesheet. And then I've made comments explaining just about everything in the catalog/includes/boxes/shoppping_cart.php so anyone with a basic knowledge of HTML should be able to make their own adjustments.

 

But enough talk here's what you need to make it happen.

 

1. Make a backup of the file catalog/includes/boxes/shopping_cart.php

 

2. Create a new document in your favorite text editor

 

3. Copy and past all the code below

 

<?php
/*
 $Id: shopping_cart.php,v 1.18 2003/02/10 22:31:06 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2003 osCommerce

 Released under the GNU General Public License

 Changes made to add pictures to the shopping cart infobox
 Comments and changes added by Kennith [url="http://www.grafikstudiet.dk"]http://www.grafikstudiet.dk[/url]

*/
?>
<!-- shopping_cart //-->
         <tr>
           <td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART);

 new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART));

 $cart_contents_string = '';
 if ($cart->count_contents() > 0) {

// start of content

// This creates the tabel used to control the display of the cart contents cellpadding changed to 1 to add a little space
// between pictures and added a class to give seperatecontrol over this info

   $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="1" class="cartInfoBox">';
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {

//makes the <tr> and starts the fist cell in the row that contains the number of items
// Changed the class name to allow seperate control from the stylesheet of the content and changed the valign from top to middle to center it with respect to the image 

     $cart_contents_string .= '<tr><td align="right" valign="middle" class="cartInfoBoxContents">';

// This section adds a span with a class to the first cell depending on if it's the latest product or an existing
// changed the name of the classes to ensure consistency in the classes used

     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
       $cart_contents_string .= '<span class="cartInfoBoxContentsNew">';
     } else {
       $cart_contents_string .= '<span class="cartInfoBoxContents">';
     }

// First part $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td>
// create the contents of the first cell showing how many of a given item that is in the cart followed by x

// second part <td valign="middle" class="cartInfoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';
// Starts the second cell and starts the link to the product in the catalog

     $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="middle" class="cartInfoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';

// This section adds a span with a class to the second cell depending on if it's the latest product or an existing
// changed the name of the classes to ensure consistency in the classes used

     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
       $cart_contents_string .= '<span class="cartInfoBoxContentsNew">';
     } else {
       $cart_contents_string .= '<span class="cartInfoBoxContents">';
     }

// The first part $cart_contents_string .= $products[$i]['name'] . '</span></a></td> ends the link in the secondcell and ends the second cell
// Then this <td align="right" class="cartInfoBoxContentsPic">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], 40) . '</td></tr>'; starts the 3 cell containing the picture
// the number in $products[$i]['name'], 40 defines the width of the image

     $cart_contents_string .= $products[$i]['name'] . '</span></a></td><td align="right" class="cartInfoBoxContentsPic">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], 40) . '</td></tr>';

     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
       tep_session_unregister('new_products_id_in_cart');
     }
   }

// This ends the tabel listing the products in the cart or displays the cart emty message if that is the case

   $cart_contents_string .= '</table>';
 } else {
   $cart_contents_string .= BOX_SHOPPING_CART_EMPTY;
 }

 $info_box_contents = array();
 $info_box_contents[] = array('text' => $cart_contents_string);

 if ($cart->count_contents() > 0) {

// If there's anything ind the cart this draws a line under the products

   $info_box_contents[] = array('text' => tep_draw_separator());

// 1st line aligns the total amount to the right 2nd line shows the total
   $info_box_contents[] = array('align' => 'right',
                                'text' => $currencies->format($cart->show_total()));
 }

 new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- shopping_cart_eof //-->

 

4. Save the new document as shopping_cart.php

 

5. Upload it to catalog/includes/boxes/ and overwrite the existing shopping_cart.php

 

6. Add the following code at the end of catalog/stylesheet.css

 

 

TABLE.cartInfoBox {
 }

TD.cartInfoBoxContents {
 color: #000;
 font-size: 10px;
 font-family: Verdana, Arial, sans-serif;
 }

TD.cartInfoBoxContentsPic {
 color: #000;
 font-size: 10px;
 font-family: Verdana, Arial, sans-serif;
 padding-right: 5px;
 }

SPAN.cartInfoBoxContents {
 color: #000;
 font-size: 10px;
 font-family: Verdana, Arial, sans-serif;
 }
SPAN.cartInfoBoxContentsNew {
 color: #000;
 font-size: 10px;
 font-family: Verdana, Arial, sans-serif;
 font-weight: bold;
 }

 

7. Save it and upload it.

 

8. Visit your shop add somthing to the cart and if you get a picture in the shoppingcart infobox pad your self on the shoulder for a job well done ;)

 

I hope you finde this helpfull. Feel free to ask if you have any questions. I'll post on this thread when I've had time to change the linking to popups instead of the catalog....enjoy

 

Oh and BTW if you have any contributions making any kind of changes to you shopping cart infobox think before you act and replace it all. instead you should just use the comments as a refference and make changes to your exixting file......

 

Best regards

Kennith

Link to comment
Share on other sites

Kennith,

 

If you havent already, why dont you upload it to the contribution section. It really is a good idea, my shopping cart is modified, so I cant just do a clean over write. Im a little clueless when it comes to coding. Id rather just follow install intsructions from a contribution. (Its just easier for us clueless people)

 

RJ,

 

Heres my catalog/includes/boxes/shopping_cart.php before adding the code you have suggested above.(Its modified as you can see)

 

<?php
/*
 $Id: shopping_cart.php,v 1.18 2003/02/10 22:31:06 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- shopping_cart //-->
	  <tr>
		<td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART);

 new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART));

 $cart_contents_string = '';
 if ($cart->count_contents() > 0) {
$cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  $cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">';

  if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
	$cart_contents_string .= '<span class="newItemInCart">';
  } else {
	$cart_contents_string .= '<span class="infoBoxContents">';
  }

  $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';

  if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
	$cart_contents_string .= '<span class="newItemInCart">';
  } else {
	$cart_contents_string .= '<span class="infoBoxContents">';
  }

$cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>';

  if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
	tep_session_unregister('new_products_id_in_cart');
  }
}
$cart_contents_string .= '</table>';
 } else {
$cart_contents_string .= BOX_SHOPPING_CART_EMPTY;
 }

 $info_box_contents = array();
 $info_box_contents[] = array('text' => $cart_contents_string);

 if ($cart->count_contents() > 0) {
$info_box_contents[] = array('text' => tep_draw_separator());
$info_box_contents[] = array('align' => 'right',
							 'text' => $currencies->format($cart->show_total()));
 }

 new infoBox($info_box_contents);
?>
		</td>
	  </tr>
<!-- shopping_cart_eof //-->

Link to comment
Share on other sites

Hey Ausgirl,

 

I was thinking of adding it to the contribution but I want ot "polish" it a bit more an add some extra features first.

 

work nights and it's now 11.35 AM here in Denmark so I'm not quit as smart as normal ;) and just want to check: you would like this function added to your cart and want me to look at your code and tell you where to alter? If so I'll have a look at i at some time later when I've had som sleep :D

Link to comment
Share on other sites

Hey Ausgirl,

 

I was thinking of adding it to the contribution but I want ot "polish" it a bit more an add some extra features first.

 

work nights and it's now 11.35 AM here in Denmark so I'm not quit as smart as normal ;) and just want to check: you would like this function added to your cart and want me to look at your code and tell you where to alter? If so I'll have a look at i at some time later when I've had som sleep :D

 

Yes, Please. No hurry though, when you have a minute is fine.

 

Thanks

Link to comment
Share on other sites

Hey again Ausgirl

 

I just ran a quick compare of the code you posted against a clean install, and they are identical. So if you changed your shoppingcart I must be the "real" shoppingcart found in catalog/shopping_cart.php in other words if the posted code is from your current catalog/includes/boxes/shoppin_cart.php then go right ahead and use what I posted already. And if you want to be absoluly sure just remember backup backup backup, then you can always go back if there are any problems...

Link to comment
Share on other sites

G'day Kennith,

 

I changed my shoppingcart file & added the code to stylesheets but nothing happened <_< I dont have the stock OSC shopping cart box.

You know what it is. It just dawned on me. (LOL) I have a Login box not a Shopping cart box. Thats why I thought my shoppingcart file had been modified. :blush:

 

Thats why its not working for me.

Link to comment
Share on other sites

G'day Kennith,

 

I changed my shoppingcart file & added the code to stylesheets but nothing happened <_< I dont have the stock OSC shopping cart box.

You know what it is. It just dawned on me. (LOL) I have a Login box not a Shopping cart box. Thats why I thought my shoppingcart file had been modified. :blush:

 

Thats why its not working for me.

 

LOL that would be a petty good explanation.

 

 

Well but anyway if anyone would like to see it in action then you can see it here http://new.crystalgalleriet.dk/detail as you'll see this page is in early development so feel free to tryout anything....

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...