Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

osc234 w/Bootstrap/Bettercheckout add an image to checkout page


dculley

Recommended Posts

Been trying to figure out how to add an image to the checkout_confirmation.php.  The file is located: catalog/includes/bettercheckout/checkout_confimation.php.  Found the lines of code that puts in the qty and description of the items.  Starts at line 234.

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
    echo '          <tr>' . "\n" .
         '            <td align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x </td>' . "\n" .
         '            <td valign="top">' . $order->products[$i]['name'];

I was trying to get the image to the right of the qty and description.  But have had no luck getting the image at all. 

 

Can anyone help?  Please.

Link to comment
Share on other sites

How are you adding the img tag for picture to show up?

 

Please add the code you have modified. If you add the tag like:  <img src="img name.xxx" height="" width=""> does the page give any error?

 

Need more information.

Best Regards,
Gaurav

Link to comment
Share on other sites

I also have better checkout, but no BS, I'll have a look at the code if it is easy to add

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

the data that is shown, is fetched from the orders class, which in turn gets it from the shoppingcart class

The shopping cart class, has the image defined because it is already shown in the shopping cart, so just need to add it to the order class

 

so try this

 

in includes/classes/order.php

 

find this section

 

      $products = $cart->get_products();
      for ($i=0, $n=sizeof($products); $i<$n; $i++) {
        $this->products[$index] = array('qty' => $products[$i]['quantity'],
                                        'name' => $products[$i]['name'],
                                        'model' => $products[$i]['model'],

add this line

 

                                        'image' => $products[$i]['image'],

 

in checkout_confirmation, you can now refer to the image like

 $order->products[$i]['image']

 

you just need to decide where you want to put it, and surround it with the tep_image code and size parameters of the image, you can probably take that from the shopping_cart.php page for consistency.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

added the image in an extra column and increased the colspan by 1 for the 2 sections before.

Works on my system (without BS), but I think it doesn't matter in this case if it is BS or not..

 

 

  if (sizeof($order->info['tax_groups']) > 1) {
?>
          <tr>
            <td colspan="3"></td>
            <td align="right"><strong><?php echo HEADING_TAX; ?></strong></td>
            <td align="right"><strong><?php echo HEADING_TOTAL; ?></strong></td>
          </tr>

<?php
  } else {
?>        <tr>
            <td colspan="5"></td>
          </tr>

<?php
  }

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
    echo '          <tr>' . "\n" .
         '            <td width="'.SMALL_IMAGE_WIDTH.'">'. tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) .'</td>' ."\n".
         '            <td align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
         '            <td valign="top">' . $order->products[$i]['name'];
 

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

@@bruyndoncx

 

Hi Carine,  Thanks for helping.  I'm not a programmer, but can follow some of what you are doing. 

I added the line to "orders.php" and I added the change lines above.   I do not get any error.  I still do not get an image, I do how ever get the "no image available" space holder to the right of the qty and description. 

 

I took out the line in "order.php" and it did not change anything.  Still have the "no image" place holder.

 

Closer to the goal.

 

I only have the evenings during the week to work on this.  That is why I am slow getting back with results. 

 

Here is the code in my bettercheckout, with your added lines.  Hope this helps.

<?php
  if (sizeof($order->info['tax_groups']) > 1) {
?>

          <tr>
            <td colspan="2"><?php echo '<strong>' . HEADING_PRODUCTS . '</strong> <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
            <td align="right"><strong><?php echo HEADING_TAX; ?></strong></td>
            <td align="right"><strong><?php echo HEADING_TOTAL; ?></strong></td>
          </tr>

<?php
  } else {
?>

          <tr>
            <td colspan="3"><?php echo '<strong>' . HEADING_PRODUCTS . '</strong> <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
          </tr>

<?php
  }

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
    echo '          <tr>' . "\n" .
         '            <td width="'.SMALL_IMAGE_WIDTH.'">'. tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) .'</td>' ."\n".
         '            <td align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
         '            <td valign="top">' . $order->products[$i]['name'];

Thanks a million for reaching out.

Link to comment
Share on other sites

can you post your catalog/includes/classes/order.php and catalog/includes/classes/shopping_cart.php so I can compare with mine

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

the posted order.php file doesn't have the image line added as i pointed out above, please add that and see what happens

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

@@bruyndoncx

 

I mintioned above that I had added the image line to the order.php and nothing happened. Then I took it back out and still did not change the results.  See #6 above.  I attached the unchanged files. Thought that is what you wanted.   Sorry that I have not had time to work on it some more.  I work at a nother company during the day M-F.  I work on this site a little in the evanings when I get back in and weekends.  I will try and work somemore this evening.  Let me know if there is anything you want me to try.  Before moving the site over to bootstrap and adding better checkout (i'm very happy with) I applied an addon that added images to shopping cart, on the old site.  Bootstrap runs under checkout and seems to pull info differuntly.

 

Thanks for your time and help.  If I understud more about the code and inter workings I could better help.

Link to comment
Share on other sites

no problem, i understand. but to show the image it must be at a minimum listed in the order.php file

 

can you share the catalog/shopping_cart.php file that pulls the image out on your old site ? perhaps you have your images stored differently ?

it must be something silly, bootstrap in itself doesn't really change much in the backend, it is really the look & feel of oscommerce that is changed

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

@@dculley

 

Just a guess but are you using KissIT Image Thumbnailer and an http:// link to reference the image you want to display?  I had a similar issue yesterday.

 

Dan 

  •  
Link to comment
Share on other sites

@@Dan Cole

 

Hi Dan,  Yes I am using KissIt.  But not a link.  I first tried a link using a line code from the addon on the old sire, but had no luck.  When I used

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
    echo '          <tr>' . "\n" .
         '            <td width="'.SMALL_IMAGE_WIDTH.'">'. tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) .'</td>' ."\n".
         '            <td align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
         '            <td valign="top">' . $order->products[$i]['name'];

from Carine help.  I get a "no image" image place holder.  That was the closest I got to an image. 

Link to comment
Share on other sites

@@bruyndoncx@@Dan Cole

 

http://addons.oscommerce.com/info/9048  This is what I was first trying to incorporate on the line where Carine has the SMALL_IMAGE_WIDTH. 

Goto file catalog/includes/modules/boxes/bm_shopping_cart.php

Goto Line 54

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

REPLACE WITH

          $cart_contents_string .= '</td><td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">'. tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);

All I got was syntec errors.  Then I tried Carine line and I got no errors and closer to a image.

 

Hope this helps.

Link to comment
Share on other sites

@@dculley

 

Different issue then.   If it helps you're getting the no image placeholder since it's not finding the image....I would try outputting the $products array to see what you get.

 

Dan 

Link to comment
Share on other sites

@@bruyndoncx @@Dan Cole

 

I have added image line back to includes/classes/order.php

I have changed the fist line of code as follows in the includes/bettercheckout/checkout_confirmation.php

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
    echo '          <tr>' . "\n" .
	 '            <td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">'. tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) .'</td>' ."\n".	
         '            <td align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x </td>' . "\n" .
         '            <td valign="top">' . $order->products[$i]['name'];

Did not change anything.  Still getting the "no image"

 

post-303521-0-68462500-1440605097_thumb.gif

Link to comment
Share on other sites

@@Dan Cole @@Dan Cole

 

Got it to work with this.

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
    echo '          <tr>' . "\n" .
	 '	      <td width="'.SMALL_IMAGE_WIDTH. '">'. tep_image(DIR_WS_IMAGES . $order->products[$i]['image'], $order->products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) .'</td>' ."\n".	
         '            <td align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x </td>' . "\n" .
         '            <td valign="top">' . $order->products[$i]['name'];
		 

I left the image line in the order.php.

added the $order-> on the first line.

 

Thank you both.

Link to comment
Share on other sites

ahaah, correct wonder where my products array got filled - your code is the correct code

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

For anyone who wants this add on

Adding images to shopping cart for BS.

In includes/classes/order.php

Around line 299

Find this section:

      $products = $cart->get_products();
      for ($i=0, $n=sizeof($products); $i<$n; $i++) {
        $this->products[$index] = array('qty' => $products[$i]['quantity'],
                                        'name' => $products[$i]['name'],
                                        'model' => $products[$i]['model'],

Add this line:
                                        'image' => $products[$i]['image'],

In includes/bettercheckout/checkout_confimation.php

Around line 234

Find this section:

    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
      echo '          <tr>' . "\n" .
           '            <td align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x </td>' . "\n" .
           '            <td valign="top">' . $order->products[$i]['name'];

Replace with this:

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
    echo '          <tr>' . "\n" .
         '	          <td width="'.SMALL_IMAGE_WIDTH. '">'. tep_image(DIR_WS_IMAGES . $order->products[$i]['image'], $order->products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) .'</td>' ."\n".	
         '            <td valign="bottom" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x </td>' . "\n" .
         '            <td valign="bottom">' . $order->products[$i]['name'];

Enjoy

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...