Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

I downloaded Shopping Cart Dropdown (contributions,2315

 

And now I need some help to get the total price to show at the bottom of the drop down menu...

Like this:

=== In My Cart ===

A product

Another product

=== Total Price ===

1000:-

 

Hope you understand :D

 

this is the code right now:

<?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;
 }

$prodname_array = array();

$prodname_array[] = array('id' => '9999999', 'text' => 'In My Cart');

for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$products_temp_name = $products[$i]['name'];
$products_name = ((strlen($products_temp_name) > '10') ? substr($products_temp_name, 0, '10') . '..' : $products_temp_name);
$products_id =  $products[$i]['id'];
$prodname_array[] = array('id' => $products_id,
					  'text' => $products_name);
}

$info_box_contents = array();
if ($cart->count_contents() > 0) {
$info_box_contents[] = array('text' => tep_draw_separator());
$info_box_contents[] = array('form' => tep_draw_form('prodname', tep_href_link(FILENAME_PRODUCT_INFO, '', 'NONSSL', false), 'get'),
'text' => tep_draw_pull_down_menu('products_id', $prodname_array,'9999999', 'onChange="this.form.submit();"') . tep_hide_session_id());
}

 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);
?>

 

Ty. B)

Posted

yeay i fixed it me self now :D

 

I have never used PHP before but abit of ASP so I understand some parts of the PHP code...

And now when i checked my first post i saw how to fix this problem of mine B)

I just added this 2 lines in to the code:

$prodname_array[] = array('text' => '=== Total Price ===');
$prodname_array[] = array('text' => $currencies->format($cart->show_total()));

for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$products_temp_name = $products[$i]['name'];
$products_name = ((strlen($products_temp_name) > '10') ? substr($products_temp_name, 0, '10') . '..' : $products_temp_name);
$products_id = $products[$i]['id'];
$prodname_array[] = array('id' => $products_id,
'text' => $products_name);
}

$prodname_array[] = array('text' => '=== Total Price ===');
$prodname_array[] = array('text' => $currencies->format($cart->show_total()));

$info_box_contents = array();
if ($cart->count_contents() > 0) {
$info_box_contents[] = array('text' => tep_draw_separator());
$info_box_contents[] = array('form' => tep_draw_form('prodname', tep_href_link(FILENAME_PRODUCT_INFO, '', 'NONSSL', false), 'get'),
'text' => tep_draw_pull_down_menu('products_id', $prodname_array,'9999999', 'onChange="this.form.submit();"') . tep_hide_session_id());
}

 

Just told this if some one else have the same problem as i did B)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...