Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

problem rearrange the way it display the shopping cart


peteravu

Recommended Posts

Posted

I tried to rearrange the way it display the shopping cart, now it come in the right order, but attribute shows same name on all and the update button mix up the fields.

So I hope somebody can lead me on the right track again.

I try to make each product in one line, in this order quantity box, attribute name, product name, update button and remove.

It would also be nice if “product name” first letter starts strait under each other and same with update buttons

 

 

I change this code

<?php
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  echo '	  <tr>';
  $products_name = '<table border="0" cellspacing="2" cellpadding="2">' .
//					   '  <tr>' .
//					   '	<td align="center"><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) . '</a></td>' .
				   '	<td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>';
  if (STOCK_CHECK == 'true') {
	$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
	if (tep_not_null($stock_check)) {
	  $any_out_of_stock = 1;
	  $products_name .= $stock_check;
	}
  }
  if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
	reset($products[$i]['attributes']);
	while (list($option, $value) = each($products[$i]['attributes'])) {
	  $products_name .= '' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '';
	}
  }
  $products_name .= '' .
// START AUTOUPDATECART
//	   tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']) . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') .
  tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']) . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') . ' <a href="' . tep_draw_hidden_field('products_id[]', $products[$i]['id']) .'   or <a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">remove</a>';
// END AUTOUPDATECART
  $products_name .= '	</td>' .
					'  </tr>' .
					'</table>';
  echo '		<td valign="top">' . $products_name . '</td>' .
	   '		<td align="right" valign="top"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong></td>' .
	   '	  </tr>';
}

to this

<?php
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  echo '	  <tr>';
  $products_name = '<table border="0" cellspacing="0" cellpadding="0"><td >' .
//					   '  <tr>' .
//					   '	<td align="center"><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) . '</a></td>' .
// START AUTOUPDATECART
//	   tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']) . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') .
  tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="2"') . $attributes_values['products_options_values_name'] . ' ';	
// END AUTOUPDATECART
  $products_name .=						'	<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>';
  if (STOCK_CHECK == 'true') {
	$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
	if (tep_not_null($stock_check)) {
	  $any_out_of_stock = 1;
	  $products_name .= $stock_check;
	}
  }
  if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
	reset($products[$i]['attributes']);
	while (list($option, $value) = each($products[$i]['attributes'])) {
	  $products_name .= tep_draw_hidden_field('products_id[]', $products[$i]['id']) . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') . 'or <a href="' . tep_draw_hidden_field('products_id[]', $products[$i]['id']) .'<a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">remove</a>';
	}
  }
  $products_name .= ' ' .
'	</td>' .
					'  </tr>' .
					'</table>';
  echo '		<td valign="top">' . $products_name . '</td>' .
	   '		<td align="right" valign="top"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong></td>' .
	   '	  </tr>';
}
?>

  • 2 weeks later...
Posted

See how the shopping cart looks now via the link below in my signature.

 

1. How to get the right name next to each attribute box?

2. Like to add a plus minus button to each box. But need help.

3.arrange “product name” first letter starts strait under each other and same with update buttons.

Posted

See how the shopping cart looks now via the link below in my signature.

 

1. How to get the right atribute name next to each attribute box?

2. Like to add a plus minus button to each box. But need help.

3. arrange “product name” first letter starts strait under each other and same with update buttons.

4. why the update botton only show on products with atributes?

Posted

See how the shopping cart looks now via the link below in my signature.

 

1. How to get the right atribute name next to each attribute box?

2. Like to add a plus minus button to each box. But need help.

3. arrange “product name” first letter starts strait under each other and same with update buttons.

4. why the update botton only show on products with atributes and dont works correct when has producte without attributes?

Posted

Ok, now I fixed so the update botton works and also the right atributes are now next to the right box.

 

how to get the total amound out to the right again?

how to arrange “product name” first letter starts strait under each other?

Like to add a plus minus button to each box if posible. But need help.

 

 

If have atributes now this show but it also need to show on products that don't have atributes

how to make a if not atribute then

$products_name .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>' . '   <a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">remove product</a>' .
	  '		<align="right"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong>';

 

the code are change now to this

<?php
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  echo '	  <tr>';
  $products_name = '<table border="0" cellspacing="0" cellpadding="0">' .
				   '  <tr>' .
				   '	<td align="center"><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) . '</a></td>' .
				   '	<td valign="top">' . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') . tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="2"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']);

  if (STOCK_CHECK == 'true') {
	$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
	if (tep_not_null($stock_check)) {
	  $any_out_of_stock = 1;
	  $products_name .= $stock_check;
	}
  }
  if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
	reset($products[$i]['attributes']);
	while (list($option, $value) = each($products[$i]['attributes'])) {
	  $products_name .= ' ' . '' . $products[$i][$option]['products_options_values_name'] . ' ';		
 $products_name .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>' . '   <a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">remove product</a>' .
	  '		<align="right"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong>';
	}
  }

  $products_name .= '	</td>' .
					'  </tr>' .
					'</table>';
  echo '		<td valign="top">' . $products_name . '</td>' .

	   '	  </tr>';
}
?>

See how the shopping cart looks now via the link below in my signature.

Posted

Ok, now I fixed so the update botton works and also the right atributes are now next to the right box.

 

how to get the total amound out to the right again?

how to arrange “product name” first letter starts strait under each other?

Like to add a plus minus button to each box if posible. But need help.

 

 

If have atributes now this show but it also need to show on products that don't have atributes

how to make a if not atribute then

$products_name .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>' . '   <a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">remove product</a>' .
	  '		<align="right"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong>';

 

the code are change now to this

<?php
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  echo '	  <tr>';
  $products_name = '<table border="0" cellspacing="0" cellpadding="0">' .
				   '  <tr>' .
				   '	<td align="center"><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) . '</a></td>' .
				   '	<td valign="top">' . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') . tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="2"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']);

  if (STOCK_CHECK == 'true') {
	$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
	if (tep_not_null($stock_check)) {
	  $any_out_of_stock = 1;
	  $products_name .= $stock_check;
	}
  }
  if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
	reset($products[$i]['attributes']);
	while (list($option, $value) = each($products[$i]['attributes'])) {
	  $products_name .= ' ' . '' . $products[$i][$option]['products_options_values_name'] . ' ';		
 $products_name .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>' . '   <a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">remove product</a>' .
	  '		<align="right"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong>';
	}
  }

  $products_name .= '	</td>' .
					'  </tr>' .
					'</table>';
  echo '		<td valign="top">' . $products_name . '</td>' .

	   '	  </tr>';
}
?>

See how the shopping cart looks now via the link below in my signature.

how to make the if product don't have atribute then show

$products_name .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>' . ' <a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">remove product</a>' .

' <align="right"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong>';

  • 3 weeks later...
Posted

Why are the space between the image and the update button different on each line when product has attributes. And why are there a big space when products don't has attributes.

 

You can see the problem via the link in my signature.

 

<table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
echo ' <tr>';
$products_name = '<table border="0" width="100%" cellspacing="0" cellpadding="0" style="border:0px;padding:0.5px;margin:0px;">' .
' <tr>' .
' <li class="left" style="list-style: none; padding-left: 0px; margin: 0px; "><td><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) . '</a></td>' .
' <td>' . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') . tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="2"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']);

if (STOCK_CHECK == 'true') {
$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
if (tep_not_null($stock_check)) {
$any_out_of_stock = 1;
$products_name .= $stock_check;
}
}
if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
reset($products[$i]['attributes']);
while (list($option, $value) = each($products[$i]['attributes'])) {
$products_name .= ' ' . '' . $products[$i][$option]['products_options_values_name'] . ' ';
$products_name .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a></li>' . '  ' .
'<li class="right" style="list-style: none; padding-left: 0px; margin: 0px; "><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong>';
}
}
$products_name .= ' </td></li>' .
' </tr>' .
'</table>';

 

Also product that don't has attributes don't show product name and total price.

How to make an IF NO ATTRIBUTE than show

$products_name .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a></li>' . '  ' .
'<li class="right" style="list-style: none; padding-left: 0px; margin: 0px; "><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong>';

Archived

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

×
×
  • Create New...