Jump to content

Percentage sale price...


Guest mrchambers

Recommended Posts

Guest mrchambers

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 :P

Thanks,

Matt

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