Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quantity Price Breaks


jpweber

Recommended Posts

I have just installed Seperate Price Per Customer 420 and SPPC Price Break v1.02 (with updates v1 and 2) and get the following error when adding a product to the shopping cart:

Fatal error: Call to a member function calculate_price() on a non-object in C:\Inetpub\wwwroot\newWaterway\catalog\includes\classes\shopping_cart.php on line 357

 

This error occurs after the text "Sub-Total:", with no values being displayed.

 

I have rechecked all of the mods and files and do not understand this error. I also do not know what other info or code to post here to solve this problem. The error reference is for the calculate() function. Please help as this will be alot of work to remove the mod and I do need it to function.

Link to comment
Share on other sites

Fatal error: Call to a member function calculate_price() on a non-object in C:\Inetpub\wwwroot\newWaterway\catalog\includes\classes\shopping_cart.php on line 357

This is a new function in RC1, found in the class currencies.php. Perhaps you used an older version of 2.2 to add the files of SPPC 4.2.0 where this function is not in the class yet?

Link to comment
Share on other sites

This is a new function in RC1, found in the class currencies.php. Perhaps you used an older version of 2.2 to add the files of SPPC 4.2.0 where this function is not in the class yet?

 

 

Thanks for the quick reply. I have 2.2rc1 installed and installed SPPC 420 without any errors.

This error did not show until Price Break 102 installed.

 

I have since gotten rid of the error by changing this:

$this->total += $currencies->calculate_price($products_price, $products_tax, $qty);

 

to this:

$this->total += tep_add_tax($products_price, $products_tax) * $qty;

which is the code from the Price Break install file in classes/shopping_cart.php

Link to comment
Share on other sites

Maybe I have the same problem....the latest versione of OSC with Price Breaks and Login for Pirce Contributions.

Well everything seems to be working but as i am on the product info page and ad I add the product to the shopping cart in quantity > of 1 using the quantity box, I got a shopping cart page with the quantity always of two.... I don't know where could be the problem....

Link to comment
Share on other sites

Well everything seems to be working but as i am on the product info page and ad I add the product to the shopping cart in quantity > of 1 using the quantity box, I got a shopping cart page with the quantity always of two.... I don't know where could be the problem....

Probably, the code in application_top.php.

Link to comment
Share on other sites

Hi I've added this mod to my store. It works well as price change per product. However, I can't check to see if the updated price per category works as my link to discount_categoried.php does not work. I have added the fiz stated in 1.2.7 and still can not get it to work.

 

Any Ideas?

 

My Store is www.madewithlovebymaria.com

 

Any help is greatly appreciated.

Link to comment
Share on other sites

However, I can't check to see if the updated price per category works as my link to discount_categoried.php does not work. I have added the fiz stated in 1.2.7 and still can not get it to work.

A. Go to your admin and change the url in the address bar of your browser to /youradminfoldername/discount_categories.php ?

B. Check the HTML source of that page to see if in the box where this link is (categories isn't it?) the html is mangled? That will give a clue on to what is wrong in the PHP.

Link to comment
Share on other sites

A. Go to your admin and change the url in the address bar of your browser to /youradminfoldername/discount_categories.php ?

B. Check the HTML source of that page to see if in the box where this link is (categories isn't it?) the html is mangled? That will give a clue on to what is wrong in the PHP.

Jan,

thank you when I got to /youradminfoldername/discount_categories.php ? I get the same error as when I click the link in the admin catalog panel = HTTP:500 internal server error website can not display the page. I reinstalled all changes. this was a fresh install of the mod. only one I had previously was minimum order qty.

 

we made sure the add to the catalog/admin/includes/boxes/catalog.php was included. , we changed teh name of the files with the extension of pbpdc

 

the only one I was unsure of is this one (can you confirm I put in correct place) admin - categories.php around line 284-288

 

if ($action == 'insert_product') {

$insert_sql_data = array('products_id' => $products_id,

'language_id' => $language_id);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);

} elseif ($action == 'update_product') {

tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");

}

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));

 

}

// BOF QPBPP price break per category

$current_discount_category = (int)$_POST['current_discount_cat_id'];

$new_discount_category = (int)$_POST['discount_categories_id'];

$discount_category_result = qpbpp_insert_update_discount_cats($products_id, $current_discount_category, $new_discount_category);

if ($discount_category_result == false) {

$messageStack->add_session(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error');

}

// EOF QPBPP price break per category

 

break;

 

case 'copy_to_confirm':

 

 

I'm not sure why it won't work.

Link to comment
Share on other sites

when I got to /youradminfoldername/discount_categories.php ? I get the same error as when I click the link in the admin catalog panel = HTTP:500 internal server error website can not display the page.

That is a pretty rare error if you ask me. No idea what causes that. Something on the page itself I guess. I have made that page using PHP4 and it still works after I upgraded to PHP5 so I'm baffled.

we changed teh name of the files with the extension of pbpdc
to .php? the pbpdc indicates it is a version for price break per discount category.
the only one I was unsure of is this one (can you confirm I put in correct place) admin - categories.php around line 284-288

No, the idea was to put it above the "cache code":

			if ($action == 'insert_product') {
		  $insert_sql_data = array('products_id' => $products_id,
								   'language_id' => $language_id);

		  $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

		  tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
		} elseif ($action == 'update_product') {
		  tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
		}
	  }

// BOF QPBPP price break per category
	  $current_discount_category = (int)$_POST['current_discount_cat_id'];
	  $new_discount_category = (int)$_POST['discount_categories_id'];
	  $discount_category_result = qpbpp_insert_update_discount_cats($products_id, $current_discount_category, $new_discount_category);
	  if ($discount_category_result == false) {
		$messageStack->add_session(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error');
	  }
// EOF QPBPP price break per category

	  if (USE_CACHE == 'true') {
		tep_reset_cache_block('categories');
		tep_reset_cache_block('also_purchased');
	  }

	  tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
	}
	break;

However, as long as it is before the tep_redirect it should work but where you put it won't because the code will not "run" because the redirect is earlier.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

Hi,

 

I have just installed this mod and have ran into a problem.

 

I am getting Fatal error: Call to undefined method currencies::calculate_price() includes/classes/shopping_cart.php on line 277 whem viewing the cart.

 

277 being $this->total += $currencies->calculate_price($products_price, $products_tax, $qty);

 

Does anyone know how to fix this?

 

Would appreciate it if you did

 

Thanks

 

Paul

Link to comment
Share on other sites

I am getting Fatal error: Call to undefined method currencies::calculate_price() includes/classes/shopping_cart.php on line 277 whem viewing the cart.

 

277 being $this->total += $currencies->calculate_price($products_price, $products_tax, $qty);

 

Does anyone know how to fix this?

This function was added with RC1 (includes/classes/currencies.php), so your installation is not up-to-date:

	function calculate_price($products_price, $products_tax, $quantity = 1) {
  global $currency;

  return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity;
}

More changes than adding that function are necessary. See RC2a->extras->upgrade-22rc1.html

Link to comment
Share on other sites

Once I installed this contrib I noticed that when I preview the product, the price does not show up.

I don't know if this is related to my installation this contrib or if this is just a fact of life.

I have noticed that other things i have added on like a multiple images contrib didn't show up either.

 

Anyone else seen this?

Link to comment
Share on other sites

Once I installed this contrib I noticed that when I preview the product, the price does not show up.

I don't know if this is related to my installation this contrib or if this is just a fact of life.

I have noticed that other things i have added on like a multiple images contrib didn't show up either.

 

Anyone else seen this?

True, that is because in the preview the prices are not added to the database yet. If you edit your product later, you will see the price breaks.

Link to comment
Share on other sites

Hi,

 

Very nice contribution, thank you. The installation instructions were straight forward and easy to follow.

 

I do have one query though regarding the, "Quantity Blocks" option for products. Is it possible to change this to, "Minimum Order Quantity". For example, have a product with Min Qty of 5, so the buyer can purcahse any amount of 5 or more but not necessarily in multiples of 5 (ie; 5, 6, 7, 12 etc... instead of 5, 10, 15, 20, 25...)

 

Thanks again, cheers.

Link to comment
Share on other sites

Jan,

thank you when I got to /youradminfoldername/discount_categories.php ? I get the same error as when I click the link in the admin catalog panel = HTTP:500 internal server error website can not display the page. I reinstalled all changes. this was a fresh install of the mod. only one I had previously was minimum order qty.

 

I encountered the same problem with my /catalog/admin/ directory. Try resetting the login & password information for that directory.

Link to comment
Share on other sites

Is it possible to change this to, "Minimum Order Quantity". For example, have a product with Min Qty of 5, so the buyer can purcahse any amount of 5 or more but not necessarily in multiples of 5 (ie; 5, 6, 7, 12 etc... instead of 5, 10, 15, 20, 25...)

From what I recall you can use/abuse the Quantity Blocks for that after adjusting the function adjustQty accordingly (in includes/classes/PriceFormatter.php):

  function adjustQty($qty) {
// Force QTY_BLOCKS granularity
$qb = $this->getQtyBlocks();
if ($qty < 1)
	$qty = 1;

if ($qb >= 1)
{
	if ($qty < $qb)
		$qty = $qb;
// remove next two lines for minimum order quantity instead of Qty_blocks
/*	if (($qty % $qb) != 0)
		$qty += ($qb - ($qty % $qb)); */
}
return $qty;
 }

Link to comment
Share on other sites

True, that is because in the preview the prices are not added to the database yet. If you edit your product later, you will see the price breaks.

 

 

ah... well that does make sense. Thanks for your help.

Link to comment
Share on other sites

Hello, I have problem with this contributon :( Please help me

 

About my problem:

 

If I am not log in to osc so in product listing is normal price and if I am log in so there is break price

 

1.jpg It is ok!

 

But when I click on info to preview of product so there is not break price:

 

2.jpg

 

Next problem. I can not get to cart item from product info only from product listing.

 

And last problem. When I add item to the cart from product listing and go to cart and change number of items for exmaple 10x so there should be 10x $600 -> $6000 and there is $7900.

 

3.jpg

 

 

Here is product_info.php

<?php
/*
 $Id: product_info.php,v 1.97 2003/07/01 14:34:54 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);

 $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
 $product_check = tep_db_fetch_array($product_check_query);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res
izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,le
ft=150')
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?>


		  <table cellspacing=0 cellpadding=0>
		   <tr><td colspan=3><img src=images/m32.gif width=490 height=43></td></tr>
		  </table>



<table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
 if ($product_check['total'] < 1) {
?>	

  <tr>
	<td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
<?php
 } else {
$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product_info = tep_db_fetch_array($product_info_query);

tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

$pf->loadProduct((int)$HTTP_GET_VARS['products_id'], (int)$languages_id);
$products_price = $pf->getPriceString(); 


  $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
}

if (tep_not_null($product_info['products_model'])) {
  $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
  $products_name = $product_info['products_name'];
}
?>

		   <tr><td height=20 colspan=3></td></tr>								
		   <tr><td width=181 valign=middle align=center>


<!-- display image -->
<?php
if (tep_not_null($product_info['products_image'])) {
?>
	  <table cellspacing="0" cellpadding="2" align="center">
		<tr>
		  <td align="center" class="smallText">
<script language="javascript"><!--
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, ' hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, ' hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>
		  </td>
		</tr>
	  </table>
<?php
}
?>
<!--end display image -->

		   </td>

			  <td width=1><img src=images/m31.gif width=1 height=152></td>
			   <td width=298 valign=top>
				   <table cellspacing=0 cellpadding=0 width=252 align=center>
				   <tr><td class=sc2 colspan=2><?=$products_name?></td></tr>	  
				   <tr><td height=10 colspan=2></td></tr>							 
				   <tr><td height=15 colspan=2></td></tr>
				   <tr><td colspan=2><b>Item #:</b>  <?= $products_id; ?></td></tr>
				   <tr><td colspan=2>		  



<?
if ($product_info['products_date_available'] > date('Y-m-d H:i:s'))
 echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available']));
else 
 echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added']));
?>					 
							 </td></tr>

				   <tr><td height=15 colspan=2></td></tr>
				   <tr><td class=sc2>Price: <font color=#FF0000><?php echo $products_price; ?></font></td>
				   <td><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_BUY_NOW); ?> </td></tr>						  
				   </table>
		   </td></tr>



		   <tr><td height=10 colspan=3></td></tr>								
		   <tr><td colspan=3 align=center><img src=images/m25.gif width=480 height=1></td></tr>
		   <tr><td height=10 colspan=3></td></tr>								
		   <tr><td colspan=3 class=sc1><img src=images/m27.gif width=4 height=7>   ITEM DESCRIPTION</td></tr>
		   <tr><td height=10 colspan=3></td></tr>								
		   <tr><td colspan=3><?php echo stripslashes($product_info['products_description']); ?><br><br>Aenean nonummy hendrerit mauris. Phasellus portauscipit varius mi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla dui. Fusce feugiat malesuada odio. Morbi nunc odio, gravida at, cursus necluctus a, lorem. Maecenas trisLorem ipsum dolor sit amet, consectetuer adipiscing elit.<br><br>Praesent vestibulum molestie lacus. Aenean nonummy hendrerit mauris. Phasellus portauscipit varius mi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla dui. Fusce feugiat malesuada odio. Morbi nunc odio, gravida at, cursus necluctus a, lorem. Maecenas trisLorem ipsum dolor sit amet, consectetuer adipiscing elit.<br><br>Praesent vestibulum molestie lacus. Aenean nonummy hendrerit mauris. Phasellus portauscipit varius mi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla dui. Fusce feugiat malesuada odio. Morbi nunc odio, gravida at, cursus necluctus a, lorem. Maecenas trisLorem ipsum dolor sit amet, consectetuer adipiscing elit.<br><br>Praesent vestibulum molestie lacus. Aenean nonummy hendrerit mauris. Phasellus portauscipit varius mi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla dui. Fusce feugiat malesuada odio. Morbi nunc odio, gravida at, cursus necluctus a, lorem. Maecenas trisLorem ipsum dolor sit amet, consectetuer adipiscing elit.</td></tr>								
		   <tr><td height=20 colspan=3></td></tr>





<!----------------------- Not editable part -------------------------------->

  <tr><td>

<?php
$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
$products_attributes = tep_db_fetch_array($products_attributes_query);
if ($products_attributes['total'] > 0) {
?>
	  <table border="0" cellspacing="0" cellpadding="2">
		<tr>
		  <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td>
		</tr>
<?php
  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
	$products_options_array = array();
	$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
	while ($products_options = tep_db_fetch_array($products_options_query)) {
	  $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
	  if ($products_options['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}

	if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
	  $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
	} else {
	  $selected_attribute = false;
	}
?>
		<tr>
		  <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
		  <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>
		</tr>
<?php
  }
?>
	  </table>
<?php
}
?>
	</td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
$reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
$reviews = tep_db_fetch_array($reviews_query);
if ($reviews['count'] > 0) {
?>
  <tr>
	<td class="main"><?php echo TEXT_CURRENT_REVIEWS . ' ' . $reviews['count']; ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
}

if (tep_not_null($product_info['products_url'])) {
?>
  <tr>
	<td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product_info['products_url']), 'NONSSL', true, false)); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
}

?>
<!--
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
			 <td class="main" align="right">
			  <table border="0" align="right">
				<tr><td align="center">
				  <?php echo TEXT_ENTER_QUANTITY . ":" . tep_draw_input_field('cart_quantity', $pf->adjustQty(1), 'size="6"'); ?>
				</td></tr>
				<tr><td align="center">
				  <?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?>
				</td></tr>
		  </table>
			</td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
-->
  <tr>
	<td>
<?php
/*
if ((USE_CACHE == 'true') && empty($SID)) {
  echo tep_cache_also_purchased(3600);
} else {
  include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
}
*/

?>


  </td></tr>

</table>
</form></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

And here is shopping_cart.php

<?php
/*
 $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shoppingCart {
var $contents, $total, $weight, $cartID, $content_type;

function shoppingCart() {
  $this->reset();
}

function restore_contents() {
  global $customer_id;

  if (!tep_session_is_registered('customer_id')) return false;

// insert current cart contents in database
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $qty = $this->contents[$products_id]['qty'];
	  $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  if (!tep_db_num_rows($product_query)) {
		tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
		if (isset($this->contents[$products_id]['attributes'])) {
		  reset($this->contents[$products_id]['attributes']);
		  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
			tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
		  }
		}
	  } else {
		tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  }
	}
  }

// reset per-session cart contents, but not the database contents
  $this->reset(false);

  $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
  while ($products = tep_db_fetch_array($products_query)) {
	$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);
// attributes
	$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
	while ($attributes = tep_db_fetch_array($attributes_query)) {
	  $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
	}
  }

  $this->cleanup();
}

function reset($reset_database = false) {
  global $customer_id;

  $this->contents = array();
  $this->total = 0;
  $this->weight = 0;
  $this->content_type = false;

  if (tep_session_is_registered('customer_id') && ($reset_database == true)) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
  }

  unset($this->cartID);
  if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
}

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
  global $new_products_id_in_cart, $customer_id;
   global $languages_id;

  $pf = new PriceFormatter;
  $pf->loadProduct($products_id, $languages_id);
  $qty = $pf->adjustQty($qty);

  $products_id = tep_get_uprid($products_id, $attributes);
  if ($notify == true) {
	$new_products_id_in_cart = $products_id;
	tep_session_register('new_products_id_in_cart');
  }

  if ($this->in_cart($products_id)) {
	$this->update_quantity($products_id, $qty, $attributes);
  } else {
	$this->contents[] = array($products_id);
	$this->contents[$products_id] = array('qty' => $qty);
// insert into database
	if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
		$this->contents[$products_id]['attributes'][$option] = $value;
// insert into database
		if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
	  }
	}
  }
  $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
  $this->cartID = $this->generate_cart_id();
}

function update_quantity($products_id, $quantity = '', $attributes = '') {
  global $customer_id;

  if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

  $this->contents[$products_id] = array('qty' => $quantity);
// update database
  if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  $this->contents[$products_id]['attributes'][$option] = $value;
// update database
	  if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");
	}
  }
}

function cleanup() {
  global $customer_id;

  reset($this->contents);
  while (list($key,) = each($this->contents)) {
	if ($this->contents[$key]['qty'] < 1) {
	  unset($this->contents[$key]);
// remove from database
	  if (tep_session_is_registered('customer_id')) {
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
	  }
	}
  }
}

function count_contents() {  // get total number of items in cart 
  $total_items = 0;
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $total_items += $this->get_quantity($products_id);
	}
  }

  return $total_items;
}

function get_quantity($products_id) {
  if (isset($this->contents[$products_id])) {
	return $this->contents[$products_id]['qty'];
  } else {
	return 0;
  }
}

function in_cart($products_id) {
  if (isset($this->contents[$products_id])) {
	return true;
  } else {
	return false;
  }
}

function remove($products_id) {
  global $customer_id;

  unset($this->contents[$products_id]);
// remove from database
  if (tep_session_is_registered('customer_id')) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
  }

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
  $this->cartID = $this->generate_cart_id();
}

function remove_all() {
  $this->reset();
}

function get_product_id_list() {
  $product_id_list = '';
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $product_id_list .= ', ' . $products_id;
	}
  }

  return substr($product_id_list, 2);
}

function calculate() {
global $currencies, $languages_id;
  $this->total = 0;
  $this->weight = 0;
  if (!is_array($this->contents)) return 0;
  $pf = new PriceFormatter;

  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	$qty = $this->contents[$products_id]['qty'];

// products price
	if ($product = $pf->loadProduct($products_id, $languages_id)) {
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	  $products_price = $pf->computePrice($qty);
	  $products_weight = $product['products_weight'];

	  /*$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }*/

	  $this->total += tep_add_tax($products_price, $products_tax) * $qty;
	  $this->weight += ($qty * $products_weight);
	}

// attributes price
	if (isset($this->contents[$products_id]['attributes'])) {
	  reset($this->contents[$products_id]['attributes']);
	  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
		$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
		$attribute_price = tep_db_fetch_array($attribute_price_query);
		if ($attribute_price['price_prefix'] == '+') {
		  $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		} else {
		  $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		}
	  }
	}
  }
}

function attributes_price($products_id) {
  $attributes_price = 0;

  if (isset($this->contents[$products_id]['attributes'])) {
	reset($this->contents[$products_id]['attributes']);
	while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
	  $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
	  $attribute_price = tep_db_fetch_array($attribute_price_query);
	  if ($attribute_price['price_prefix'] == '+') {
		$attributes_price += $attribute_price['options_values_price'];
	  } else {
		$attributes_price -= $attribute_price['options_values_price'];
	  }
	}
  }

  return $attributes_price;
}

function get_products() {
  global $languages_id;

  if (!is_array($this->contents)) return false;
   $pf = new PriceFormatter;

  $products_array = array();
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	if ($products = $pf->loadProduct($products_id, $languages_id)) {
	  $products_price = $pf->computePrice($this->contents[$products_id]['qty']);

	  $products_array[] = array('id' => $products_id,
								'name' => $products['products_name'],
								'description' => $products['products_description'],
								'model' => $products['products_model'],
								'image' => $products['products_image'],
								'price' => $products_price,
								'quantity' => $this->contents[$products_id]['qty'],
								'weight' => $products['products_weight'],
								'final_price' => ($products_price + $this->attributes_price($products_id)),
								'tax_class_id' => $products['products_tax_class_id'],
								'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
	}
  }

  return $products_array;
}

function show_total() {
  $this->calculate();

  return $this->total;
}

function show_weight() {
  $this->calculate();

  return $this->weight;
}

function generate_cart_id($length = 5) {
  return tep_create_random_value($length, 'digits');
}

function get_content_type() {
  $this->content_type = false;

  if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  if (isset($this->contents[$products_id]['attributes'])) {
		reset($this->contents[$products_id]['attributes']);
		while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
		  $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
		  $virtual_check = tep_db_fetch_array($virtual_check_query);

		  if ($virtual_check['total'] > 0) {
			switch ($this->content_type) {
			  case 'physical':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'virtual';
				break;
			}
		  } else {
			switch ($this->content_type) {
			  case 'virtual':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'physical';
				break;
			}
		  }
		}
	  } else {
		switch ($this->content_type) {
		  case 'virtual':
			$this->content_type = 'mixed';

			return $this->content_type;
			break;
		  default:
			$this->content_type = 'physical';
			break;
		}
	  }
	}
  } else {
	$this->content_type = 'physical';
  }

  return $this->content_type;
}

function unserialize($broken) {
  for(reset($broken);$kv=each($broken);) {
	$key=$kv['key'];
	if (gettype($this->$key)!="user function")
	$this->$key=$kv['value'];
  }
}

 }
?>

 

If you need more information to help me. Send me message. Please help me!

 

Thank you very much :)

Link to comment
Share on other sites

  • 2 weeks later...

Hello folks, this is one pretty good contribution, but however I have this silly question to ask you that won't take too much of your time, maybe a minute or two

 

I just set these quantity's for only one of my items, and thats on this link:

http://www.etextremegraphics.com/catalog/p...products_id=118

 

But as you can see its just out of proportions, quantity box is just too big, if you know how to shrink it down and make it look more professionally link this one on this pic below, please let me know

http://img376.imageshack.us/img376/7811/pr...kcatalogut4.gif

 

 

thanks, Ned

Link to comment
Share on other sites

Hello folks, this is one pretty good contribution, but however I have this silly question to ask you that won't take too much of your time, maybe a minute or two

 

I just set these quantity's for only one of my items, and thats on this link:

http://www.etextremegraphics.com/catalog/p...products_id=118

 

But as you can see its just out of proportions, quantity box is just too big, if you know how to shrink it down and make it look more professionally link this one on this pic below, please let me know

http://img376.imageshack.us/img376/7811/pr...kcatalogut4.gif

thanks, Ned

 

 

Ok there's been one small mistake in css file, that I forgot to put in there, now it looks a bit better, but still, my item's text is too far from its name, there's big gap between it, any ideas how to fix it?

Link to comment
Share on other sites

Join the conversation

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

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