Guest mrchambers Posted October 22, 2009 Share Posted October 22, 2009 Hey all, I have a client who has requested the ability to enter a percentage price into the 'Sale Price' input box on the product edit/add page. I thought it would be best if I gave them the option to either put in a set price (as normal) or put in a percentage - IE: If you wanted to create a sale price that is 10% off the current price, enter 90% into the 'Sale Price' box. Following is the code to make it happen! Open admin/sources/products/index.inc.php Around line 211, find the code; ## Generate product code if (empty($_POST['productCode'])) { $chars = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N", "O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3", "4","5","6","7","8","9","0"); and insert ABOVE that code the following; // start mod: Percentage Sale Input - matthewianchambers.com if (strpos($_POST['sale_price'], '%') != false) { // do we have a percent symbol? $_POST['sale_price'] += 0; // make var an integer $record['sale_price'] = ($_POST['price']/100) * $_POST['sale_price']; // do percentage calculation on price and replace sale price } // end mod: Bingo - percentage sale prices in an instant! It's not supported, it's in no way supported but it is free Thanks, Matt Quote Link to comment Share on other sites More sharing options...
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.