Jump to content

odd array issues


wmguk

Recommended Posts

Hey,

 

I'm editting some code on an OS Commerce install, For some reason I dont get the various buttons displaying.

Underneath the shopping basket, it is supposed to show a view cart button and a checkout button, but they dont show up.

 

I'm also trying to edit it to use a layout of the stylesheet, Basically if you look at my website, you will see the categories list, these are generated by an <ul><li> code, which puts the background underneath the item name, I would like to do the same thing and limit the charactors in the name to say 50 (so they stay on one line)

 

Can you point me in the right direction to set an <li> on each item in the cart, and change it to UCWORDS, and restrict the charactors please?

 

Any ideas on why the images dont show up on the page?

 

http://tinyurl.com/2f6g2lg

 

This is my code.

<?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 //-->
<?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())
							 );
  //cart buttons start
$info_box_contents[] = array('align' => 'center',
  			     				 'text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image_button ('button_cart_view.gif', IMAGE_BUTTON_CART_VIEW) . '</a>' . '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING) . '">' . tep_image_button ('button_cart_checkout.gif', IMAGE_BUTTON_CART_CHECKOUT) . '</a>' ); 
//cart buttons end

  }

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

Link to comment
Share on other sites

Hi again

 

I've managed to get some of it working, but the code is a right mess, can you help me out please?

 

<table border="0" cellspacing="0" cellpadding="0" width="162">
             <tr>
               <td class="bg4" width="162" height="30">  <span class="tx2"><?=BOX_HEADING_SHOPPING_CART?></span> </td>
             </tr>
             <tr>
               <td><ul><?php
  $cart_contents_string = '';
  if ($cart->count_contents() > 0) {
    $cart_contents_string = '';
    $products = $cart->get_products();
      for ($i=0, $n=sizeof($products); $i<$n; $i++) {
      $cart_contents_string .= '<span align="right">';
      $cart_contents_string .= '<li>' . $products[$i]['quantity'] . ' x <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . $products[$i]['name'] . '</span></a></li>';
  }
    
  } 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()));

//cart buttons start
$info_box_contents[] = array('align' => 'center',
  			     				 'text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image_button ('button_view_cart.gif', IMAGE_BUTTON_CART_VIEW) . '</a>' . ' <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING) . '">' . tep_image_button ('button_checkout1.gif', IMAGE_BUTTON_CART_CHECKOUT) . '</a>' ); 
//cart buttons end
  }

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.