Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

ShoppingCart Infobox


martigan

Recommended Posts

Hi fellow Oscers,

 

What I search for here on the forums and in the contribution section

is a tool that can make the cart info box dissappearing when it?s empty and

to pop up when the first item has been added.

 

Ithink a simple if script will do but im not good with php :(..

 

Like:

 

If shopping cart is not empty do

 

show cart info box

 

else

 

......

 

Who can make this little if statement in php for me?

 

Thanks a lot,

Erik Ottens

Link to comment
Share on other sites

Ok fixed it myself here is the code for in column_right.php :

 

$cart_contents_string = '';

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

 

require(DIR_WS_BOXES . 'shopping_cart.php');

}

 

Thats all... show the shopping cart infobox only when needed ...

 

Maybe admins could move this topic to tips and tricks?

 

regards, erik.

Link to comment
Share on other sites

Hi there,

 

Happy someone could use it ... I dont use sts myself but try

to search for

 

echo $sts_block['cartbox'];

 

in sts_display_output.php and replace it with

 

$cart_contents_string = '';

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

 

echo $sts_block['cartbox'];

}

 

Please let me know if it worked out, can't test it here...

 

Regards Erik.

Link to comment
Share on other sites

Thank you very much for your code and fast reply! :)

It looks like the code doesn't change anything, I can actually even remove all of this and it doesnt affect anything, strange...

Link to comment
Share on other sites

This altered code

echo $sts_block['cartbox']; 

in sts_display_output.php and replace it with 

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

echo $sts_block['cartbox']; 
}

 

make no difference at all, I can even remove it all and nothing happens. The cart box show up as usual, no change in behaviour.

 

This is how my cart box code looks like(bottom). I have added som a nice table layout that has the same looks as the rest of my shop. It's easy to make the cart disappear just by changing the code:

  $cart_contents_string = '????';

the '????' will show up when the cart is empty. I have removed all the usual box-graphics/tables so it only shows the text '????' so it does the job. The big problem is that I don't know how to add the extra html code for the new tablestructure that resides above and below the PHP-code. The html code shows also show up. I need to merge the html code into the php code I think so that it doesn't show upp when the cart is empty. I've already tried to merge it into the php-code but my php skills aren't really good so the result was not really that good.... Anyone? Regards, Markus!

 

<!-- shopping_cart //-->

       
         <tr>
           <td>
           
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
 <td width="5">
 </td>
 <td>

<table width="100%" border="0" cellpadding="1" cellspacing="0" bgcolor="996666">
       <tr> 
        <td valign="top">

          <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr bgcolor="lightgray"> 
              <td valign="top">
                <table width="100%" border="0" cellpadding="5" cellspacing="0">
              </td>
            </tr> 
              <td><center><a href=shopping_cart.php class="headerNavigation">Varukorg</a><font color="lightgray">|</font></center></td>
            </tr>
          </table>

       </td>
     </tr>
     <tr>
       <td class="main" valign="top" bgcolor="white">
       

<?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>
  </table>
    </td>
 </tr>
</table>
 </td>
</tr>
</table>
           </td>
         </tr>
<!-- shopping_cart_eof //-->

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...