Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Added extra price fields, POST variable not working


Mita

Recommended Posts

I have 3 price fields and 3 size fields which I have added into the products table. I display the product description and the drop down list for price on the product listing page, have removed the link to the product-info page. The drop down list looks like this :

Qty Price

100 $50.25

500 $125.50

1000 $200.00

 

I had added some code on the modules/product_ listing page and the classes/shopping_cart page to make the selection from the dropdown list and pick the appropriate price accordingly. I am pasting the code snippets below

 

In the product_listing.php file :

 

case 'PRODUCT_LIST_PRICE':

$lc_align = 'right';

$lc_text = '<form name="WhichPrice" action="$PHP_SELF" method="POST"><select name="price"><option value="prc1">' . $listing['size1'] .'   '. $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</option>';

if ($listing['product_price2'] <> 0) {

$lc_text .= '<option value="prc2">' . $listing['size2'] .'   '. $currencies->display_price($listing['product_price2'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</option>';

}

if ($listing['product_price3'] <> 0) {

$lc_text .= '<option value="prc3">' . $listing['size3'] .'   '. $currencies->display_price($listing['product_price3'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</option>';

}

$lc_text .= '</select></form>';

break;

 

 

In the shopping_cart.php file, calculate function :

 

$product_query = tep_db_query("select products_id, products_price, product_price2, product_price3, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

if ($product = tep_db_fetch_array($product_query)) {

$prid = $product['products_id'];

$products_tax = tep_get_tax_rate($product['products_tax_class_id']);

if ($_POST['price'] == "prc1") {

$products_price = $product['products_price'];

}

elseif($_POST['price'] == "prc2") {

$products_price = $product['product_price2'];

}

elseif($_POST['price'] == "prc3") {

$products_price = $product['product_price3'];

}

 

This code was working fine but something changed in the server configuration and now the variable 'price' is not getting posted, hence the if condition in the shopping_cart file fails and the price displays as 0. I tried posting a simple text variable and echoing it in the shopping_cart file but even that is not working.

 

Anybody has any ideas what may have caused the program to stop working. Any other method I can use to get around this problem? Any help would be greatly appreciated, I needed to get this done yesterday :(

Link to comment
Share on other sites

the shopping cart class does not recognise post values. You need to add them to the session (similar to attributes) and can then access them during calculation - it's a rather dull and lengthy procedure....

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...