Carbon Posted September 19, 2005 Posted September 19, 2005 Hi, I have searched and googled for the answer to this but to no avail so I'm hoping someone out there can help... The problem... When viewing a product in product_info.php the price is displayed but when you select an attribute that increases the price (eg: add extra ram (+?40) ) OSC doesn't update the price. The solution ?... I found a contribution called "price_updateV3" which should work but it doesn't. I think it was written for an earlier version of OSC as some of the strings are different (in fact I just checked and it would seem that it was written for version 2 and I'm on version 2.2) so I was wondering if anyone is able to update the code? Credits : All to Brian N. Smith Fix by : Kurt Budiarto ([email protected]) Written on : June 17, 2003 Designed by: Brian N. Smith ([email protected]) NuOnce Networks - www.nuonce.net Updated by : Brian N. Smith January 23, 2004 For MS2! ------------------------------------------------------------------------------------------------------------ Fixes: ALWAYS BACKUP BACKUP BACKUP! READ THE INSTALLATION INSTRUCTIONS BELOW. In the part of the showPrice() function below, I just switched the + and - signs around to fix a small glitch. The glitch was that it was not adding the price to the total price in some options, but instead it was subtracting when it was not supposed to. if (myMathProblem == "-") { myTotalPrice = myTotalPrice - myAttributePrice; } else { myTotalPrice = myTotalPrice + myAttributePrice; } } ------------------------------------------------------------------------------------------------------------ This is just a fun little modification. When you add options/attributes to your osCommerce, the price that is displayed on the page never gets updated. This forces customers to add the product to their cart to see what the new price is. Well. That is no longer the case with this modification. It will automatically update the price displayed. You can change the location of where it shows the new price, but I thought that just updating the price that is already displayed would be nicer. To see a demo of this just open up example.html in your web browser. Install instructions (catalog/product_info.php) ------------------------------------------------------------------------------------------------------------ Search for: <link rel="stylesheet" type="text/css" href="stylesheet.css"> After that line, copy in the two Javascript Functions from the option.js ------------------------------------------------------------------------------------------------------------ Search for: <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> Change to: <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onload="showPrice(cart_quantity)"> *** NOTE *** Some browsers do not like the onload. So, one option is to NOT put this part here, but rather use this method instead: Search for: <!-- body_text_eof //--> Add the following lines afterwards: <script language="javascript"> <!-- showPrice(cart_quantity); //--> </script> ------------------------------------------------------------------------------------------------------------ Search for: <td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td> -------------->8------------ THIS BIT LOOKS LIKE IT SHOULD BELONG IN A <FORM> BUT ALTHOUGH PRODUCT_INFO.PHP HAS A </FORM> AT THE END THERE IS NO OPENING DECLARATION (OF COURSE IT COULD BE BURRIED IN ONE OF THE INCLUDES) -------------->8------------ Add the following line afterwards.: <input type="hidden" name="nuPrice" value="<?php echo str_replace("$","",$nuPrice); ?>"> ------------------------------------------------------------------------------------------------------------ -------------->8------------ THE STRING $osC_Currencies IS DIFFERENT IN V2.2 -------------->8------------ Search for: $products_price = '<s>' . $osC_Currencies->displayPrice($product_info['products_price'], $product_info['products_tax_class_id Add the following line afterwards: $nuPrice = $currencies->display_price($new_price, tep_get_tax_rate($product_info_values['products_tax_class_id'])); ------------------------------------------------------------------------------------------------------------ Search for: $products_price = $osC_Currencies->displayPrice($product_info['products_price'], $product_info['products_tax_class_id']); Add the following line afterwards: $nuPrice = $products_price; ------------------------------------------------------------------------------------------------------------ Search for: Underneath the block of code above, you will want to add the following: $products_price = $osC_Currencies->displayPrice($product_info['products_price'], $product_info['products_tax_class_id']); $nuPrice = $products_price; } $nuPrice = str_replace(",", "", $nuPrice); ### Add this line! ------------------------------------------------------------------------------------------------------------ Search For: <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td> Change to: <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute, "onChange='showPrice(this.form);'"); ?></td> ------------------------------------------------------------------------------------------------------------ Search for: <?php $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$_GET['products_id'] . "'"); $reviews = tep_db_fetch_array($reviews_query); Right above it, add: <tr><td><div id="productNEWprice"></div></td></tr> Common Problems: > I also just found out that on my linux browser, it does not show the options > prices and item total UNTIL you click on one for the first time. Do you > think this is a problem on my browser settings or something in the code? It is a problem with JavaScript, and how everyone implements it. I was trying to do it as generic as possible. It could be that the Linux browser does not support "onload" functions in the body. What you can try to do is the following: <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onload="showPrice(cart_quantity)"> On the end of that, notice --> onload="showPrice(cart_quantity) Remove that part. Search for: <!-- body_text_eof //--> It should be near the bottom of the file, and then add the following lines: <script language="javascript"> <!-- showPrice(cart_quantity); //--> </script> I haven't included the javascript because it would make this post a lot longer and I think that javascript is pretty universal, plus it works in the included example in the package archive (interestingly the author uses <form> to create a demo environment). Any help is much appreciated as I'm sure this will be one of many "Why isn't this included by default?" requests ;) Carbon Quote
Guest Posted September 19, 2005 Posted September 19, 2005 Hi, I have searched and googled for the answer to this but to no avail so I'm hoping someone out there can help... The problem... When viewing a product in product_info.php the price is displayed but when you select an attribute that increases the price (eg: add extra ram (+?40) ) OSC doesn't update the price. The solution ?... I found a contribution called "price_updateV3" which should work but it doesn't. I think it was written for an earlier version of OSC as some of the strings are different (in fact I just checked and it would seem that it was written for version 2 and I'm on version 2.2) so I was wondering if anyone is able to update the code? Credits ? ?: All to Brian N. Smith Fix by ? ? : Kurt Budiarto ([email protected]) Written on : June 17, 2003 Designed by: Brian N. Smith ([email protected]) ? ? ? ? ? ? NuOnce Networks - www.nuonce.net Updated by : Brian N. Smith ? ? ? ? ? ? January 23, 2004 ? ? ? ? ? ? For MS2! ------------------------------------------------------------------------------------------------------------ Fixes: ALWAYS BACKUP BACKUP BACKUP! READ THE INSTALLATION INSTRUCTIONS BELOW. In the part of the showPrice() function below, I just switched the + and - signs around to fix a small glitch. The glitch was that it was not adding the price to the total price in some options, but instead it was subtracting when it was not supposed to. if (myMathProblem == "-") ? ? ? ? ?{ ? ? ? ? ? ?myTotalPrice = myTotalPrice - myAttributePrice; ? ? ? ? ?} else { ? ? ? ? ? ?myTotalPrice = myTotalPrice + myAttributePrice; ? ? ? ? ?} } ------------------------------------------------------------------------------------------------------------ This is just a fun little modification. ?When you add options/attributes to your osCommerce, the price that is displayed on the page never gets updated. ?This forces customers to add the product to their cart to see what the new price is. ?Well. ?That is no longer the case with this modification. ?It will automatically update the price displayed. ?You can change the location of where it shows the new price, but I thought that just updating the price that is already displayed would be nicer. To see a demo of this just open up example.html in your web browser. Install instructions (catalog/product_info.php) ------------------------------------------------------------------------------------------------------------ Search for: ?<link rel="stylesheet" type="text/css" href="stylesheet.css"> After that line, copy in the two Javascript Functions from the option.js ------------------------------------------------------------------------------------------------------------ Search for: <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> Change to: <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onload="showPrice(cart_quantity)"> *** NOTE *** Some browsers do not like the onload. ?So, one option is to NOT put this part here, but rather use this method instead: Search for: <!-- body_text_eof //--> Add the following lines afterwards: <script language="javascript"> <!-- ?showPrice(cart_quantity); //--> </script> ------------------------------------------------------------------------------------------------------------ Search for: ?<td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td> -------------->8------------ THIS BIT LOOKS LIKE IT SHOULD BELONG IN A <FORM> BUT ALTHOUGH PRODUCT_INFO.PHP HAS A </FORM> AT THE END THERE IS NO OPENING DECLARATION (OF COURSE IT COULD BE BURRIED IN ONE OF THE INCLUDES) -------------->8------------ ? Add the following line afterwards.: ? <input type="hidden" name="nuPrice" value="<?php echo str_replace("$","",$nuPrice); ?>"> ------------------------------------------------------------------------------------------------------------ -------------->8------------ THE STRING $osC_Currencies IS DIFFERENT IN V2.2 -------------->8------------ Search for: ?$products_price = '<s>' . $osC_Currencies->displayPrice($product_info['products_price'], $product_info['products_tax_class_id Add the following line afterwards: ?$nuPrice = $currencies->display_price($new_price, tep_get_tax_rate($product_info_values['products_tax_class_id'])); ------------------------------------------------------------------------------------------------------------ Search for: ?$products_price = $osC_Currencies->displayPrice($product_info['products_price'], $product_info['products_tax_class_id']); Add the following line afterwards: ?$nuPrice = $products_price; ------------------------------------------------------------------------------------------------------------ Search for: ?Underneath the block of code above, you will want to add the following: ?$products_price = $osC_Currencies->displayPrice($product_info['products_price'], $product_info['products_tax_class_id']); ?$nuPrice = $products_price; } $nuPrice = str_replace(",", "", $nuPrice); ? ?### Add this line! ------------------------------------------------------------------------------------------------------------ Search For: ?<td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] ? ?. ']', $products_options_array, $selected_attribute); ?></td> Change to: ?<td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] ? ?. ']', $products_options_array, $selected_attribute, "onChange='showPrice(this.form);'"); ?></td> ------------------------------------------------------------------------------------------------------------ Search for: <?php ? ?$reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" ? ? ?. (int)$_GET['products_id'] . "'"); ? ?$reviews = tep_db_fetch_array($reviews_query); Right above it, add: ?<tr><td><div id="productNEWprice"></div></td></tr> Common Problems: > I also just found out that on my linux browser, it does not show the options > prices and item total UNTIL you click on one for the first time. ?Do you > think this is a problem on my browser settings or something in the code? It is a problem with JavaScript, and how everyone implements it. ?I was trying to do it as generic as possible. ?It could be that the Linux browser does not support ?"onload" functions in the body. ? What you can try to do is the following: <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onload="showPrice(cart_quantity)"> On the end of that, notice --> onload="showPrice(cart_quantity) Remove that part. Search for: ?<!-- body_text_eof //--> It should be near the bottom of the file, and then add the following lines: <script language="javascript"> <!-- showPrice(cart_quantity); //--> </script> I haven't included the javascript because it would make this post a lot longer and I think that javascript is pretty universal, plus it works in the included example in the package archive (interestingly the author uses <form> to create a demo environment). Any help is much appreciated as I'm sure this will be one of many "Why isn't this included by default?" requests ;) Carbon <{POST_SNAPBACK}> I found this contribution on forums and it worked for me .Make sure you back up first i take no responsibility cause im new to this but as i said it worked for me; open product_info.php and locate this code approx line 137; Code: 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'])) .') '; } then change it to Code: //here is the edited code if ($products_options['price_prefix'] == '+'){ $real_price = ($product_info['products_price']) + ($products_options['options_values_price']); $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price($real_price, tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; }else{ $real_price = ($product_info['products_price']) - ($products_options['options_values_price']); $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price($real_price, tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } // end of code hope its what you are after. jaz Quote
Carbon Posted September 19, 2005 Author Posted September 19, 2005 Thanks for replying Jaz, but your code just modifies the price next to each attribute (inside the pull-down box) to show a total price, which would be fine if the product only had one pull-down attribute box. What I need is this... PRODUCT COST ?100 ATTRIBUTE 1: OPTION 1 (+10) OPTION 2 (+20) OPTION 3 (+30) ATTRIBUTE 2: OPTION 1 (+40) OPTION 2 (+50) OPTION 3 (+60) If the user selects Atrribute 1 with Option 1 and Attribute 2 with Option 3 the Product Cost gets updated and displays the new price of ?170 I hope that makes it clearer. Carbon Quote
mr_biggles Posted September 28, 2005 Posted September 28, 2005 (edited) Thanks for replying Jaz, but your code just modifies the price next to each attribute (inside the pull-down box) to show a total price, which would be fine if the product only had one pull-down attribute box. What I need is this... PRODUCT COST ?100 ATTRIBUTE 1: OPTION 1 (+10) OPTION 2 (+20) OPTION 3 (+30) ATTRIBUTE 2: OPTION 1 (+40) OPTION 2 (+50) OPTION 3 (+60) If the user selects Atrribute 1 with Option 1 and Attribute 2 with Option 3 the Product Cost gets updated and displays the new price of ?170 I hope that makes it clearer. Carbon I too want this feature but cannot get the price to update - it always shows ?0.00 anyone know whats wrong? btw, i am using sts if it makes any difference Edited September 28, 2005 by mr_biggles Quote
higgalls Posted January 3, 2006 Posted January 3, 2006 Hey, I was looking for a fix to this problem too, but I just found this contribution that should work. I will try and install it tonight and see how it goes: http://www.oscommerce.com/community/contri...ch,price+update Cheers, Chris :) Quote
Recommended Posts
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.