cinolas Posted April 8, 2015 Share Posted April 8, 2015 Hello, In my installation of osC 2.2.3, if an item is on special, the shopping_cart page only shows the special price, not the regular price. I would like to display the prices of Specials like on the products_info: $24.00 $19.00I've tried modifying the get_products() function in /admin/includes/classes/shopping_cart.php to include reg_price in the returned array: function get_products() { global $languages_id; if (!is_array($this->contents)) return 0; $products_array = array(); reset($this->contents); while (list($products_id, ) = each($this->contents)) { $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='" . (int)tep_get_prid($products_id) . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); if ($products = tep_db_fetch_array($products_query)) { $prid = $products['products_id']; $products_price = $products['products_price']; $products_reg_price = $products['products_price']; $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']; } $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], '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'] : ''), 'reg_price' => $products_reg_price); } } return $products_array; } Then I modified the price display line of /shopping_cart.php from: ' <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>' to: ' <td align="right" valign="top">' . $currencies->display_price($products[$i]['reg_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ' <strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong></td>' but for some reason the reg_price comes out as $0.00I don't know much about php and I'm sure I'm missing the obvious...Your help is greatly appreciated!Thanks Link to comment Share on other sites More sharing options...
clustersolutions Posted April 9, 2015 Share Posted April 9, 2015 OMG...what a mess...changing core codes...just kidding...looks good to me...but this is what I would do.. in your shopping_cart.php file, right after the line that said: $products = $cart->get_products(); do a... print_r($products); look at the array if reg_price is 0 then your problem is in your shopping_cart class file...else it is in your shopping_cart.php file...I think I had encountered something like this b4 the issue could be in the display price method...good luck...Tim Link to comment Share on other sites More sharing options...
cinolas Posted April 9, 2015 Author Share Posted April 9, 2015 Yeah, I know. If only I knew enough to do it properly I would. No time, no budget, no knowledge. Anyway, THANK YOU! You pointed me in the right direction, it likely had to do with the display price method. It even underlined another point I had overlooked: the regular price looks best if it's tallied up after all attribute adjustments. So in the end the get_products function ended up looking more like: $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], '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'] : ''), 'reg_price' => ($products_reg_price + $this->attributes_price($products_id)); and that fed the price in the same format as it was expecting, so it worked. The display of the prices all formatted ended up like this: if ($products[$i]['reg_price'] == $products[$i]['final_price']) { echo ' <strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong>'; }else{ echo ' <s>' . $currencies->display_price($products[$i]['reg_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</s> ' . '<strong><font color="#FF0000">' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</font></strong>'; }; Link to comment Share on other sites More sharing options...
clustersolutions Posted April 9, 2015 Share Posted April 9, 2015 Your welcome! You do have the knowledge and your just like the rest of us store owners--no time and not the budget... Procedural programming is the easy part and I think troubleshooting is always the harder part...I make this change ever time I upgrade OSC...something like this should really be in the core... Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted April 9, 2015 Share Posted April 9, 2015 this has bugged me too a little but not enough to go change it myself :D @@burt any chance this will change in the futur ? KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
burt Posted April 9, 2015 Share Posted April 9, 2015 this has bugged me too a little but not enough to go change it myself :D @@burt any chance this will change in the futur ? In 2.4.x (x = to be decided) we will have a product class...so to display any product info anywhere should be ultra simple... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.