Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Show shipping in cart infobox


pstrid

Recommended Posts

I have made some changes to my shopping_cart infobox to display the amount left to spend for free shipping but would also like to show the shipping cost and total cost in the box as well, instead of just a subtotal. Currently we only have one shipping option at a falt rate for all orders. Was going to try and hack through the "shipping estimator" contribution but seemed like it does more than i need.

 

My shopping_cart code is below and my LIVE shop is My Webpage if you want to check out how it looks so far.

 

As always, all help/suggestioons are greatly appreciated.

 

<?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
*/
?>
<tr>
<td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART);

 new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL'));

 $cart_contents_string = '';
 if ($cart->count_contents() > 0) {
   $cart_contents_string = '	<table border="0" width="100%">
   <tr>
	 <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	 <tr class="header_store_info_title">
  	 <td>Qty</td>
  	 <td>Item</td>
  	 <td>Total</td>
   </tr>';
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
     $cart_contents_string .= '
   <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">';
     }
     $cost = ($products[$i]['final_price'] * $products[$i]['quantity']). '';
     $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'];
     $cart_contents_string .= '<td align="right" valign="top" class="infoBoxContents">';
     $cart_contents_string .= $currencies->format($cost);
     $cart_contents_string .= '</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></td>
 </tr>
</table>';
 } else {
   $cart_contents_string .= BOX_SHOPPING_CART_EMPTY;
 }


// Bof Shopping Cart Box Enhancement
$showcheckoutbutton = 0; // set to 1: show checkout button (default); set to 0: never show checkout button
$showhowmuchmore = 1;    // set to 1: show how much more to spend for free shipping (default); set to 0: don't show

$cart_show_string = '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>' . tep_draw_separator('pixel_trans.gif', '100%', '4') . '</td></tr>';

if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') { 
   if (($cart->show_total()) < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {
      if (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION == 'both') {
               $cart_show_string .= '<tr><td class="shopping_cart" align="center">' . sprintf(TEXT_ADD_TO_GET_FREE_SHIPPING, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER - ($cart->show_total()))) . '</td></tr>'; 
      }
      else if (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION == 'international') {
          $cart_show_string .= '<tr><td class="shopping_cart" align="center">' . sprintf(TEXT_FREE_SHIPPING_LIMIT_INTERNATIONAL, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER),tep_get_country_name(STORE_COUNTRY));       
      }
      else {
               $cart_show_string .= '<tr><td class="shopping_cart" align="center">' . sprintf(TEXT_ADD_TO_GET_FREE_SHIPPING, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER - ($cart->show_total()))) . '</td></tr>'; 
      }
      $cart_show_string .='</td></tr>';
   }
   if ((($cart->show_total()) >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)&&($showhowmuchmore)) {
      if (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION == 'both') {    
        $cart_show_string .= '<tr><td class="shopping_cart" align="center">' . TEXT_FREE_SHIPPING_RECEIVED . '</td></tr>';
      }
      else if (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION == 'international') {
        $cart_show_string .= '<tr><td class="shopping_cart" align="center">' . sprintf(TEXT_FREE_SHIPPING_RECEIVED_INTERNATIONAL, tep_get_country_name(STORE_COUNTRY)) . '</td></tr>';       }
      else {
        $cart_show_string .= '<tr><td class="shopping_cart" align="center">' . sprintf(TEXT_FREE_SHIPPING_RECEIVED_NATIONAL, tep_get_country_name(STORE_COUNTRY)) . '</td></tr>';              
      }
   }
}

if (($showcheckoutbutton==1) && ($cart->count_contents() > 0) && (substr(basename($PHP_SELF), 0, 8) != 'checkout')) {
 $cart_show_string .= '<tr><td>' . tep_draw_separator('pixel_trans.gif', '100%', '7') . '</td></tr><tr><td align="center"><a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a></td></tr>';  
}
$cart_show_string .= '</table>';
$info_box_contents = array();
$info_box_contents[] = array('text' => $cart_show_string); 
$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()) .
                ' <tr><td align="center" class="infoBoxContents">                         
               <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a>
             </td> </tr>' );
 }

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

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...