Add First Option Sale Prices
If you add a Sale Price to an item (either directly or through Global Updates), that price applies only to the Regular Price of the item. Sale prices do not apply to option prices.
To extend the sale price to the first option price, you can use the following modification. Note that this may result in rounding errors, as the sale price is not a percent, so we have to calculate the percent and then apply it to the option price. Only first option prices are affected by this modification.
-
Open the products_variables.php file in the /enc/ folder.
-
Change the line:
function var_formfields($varpgnm, $varitemid, $varreturn, $varitem, $varcatalog, $varprice, $varunits, $vartax, $vardiscount, $vardescription)
to:
function var_formfields($varpgnm, $varitemid, $varreturn, $varitem, $varcatalog, $varprice, $varorigprice, $varunits, $vartax, $vardiscount, $vardescription)
-
Add the line:
$dispformflds .= "";
just under the line:
$dispformflds .= "";
-
Add the lines:
// GET SALE PERCENTAGE
$salepercent=1;
if(!empty($varsaleprice) AND !empty($varregprice) AND $varsaleprice<$varregprice)
$salepercent=($varsaleprice/$varregprice);
$salepercent=($salepercent>0 AND $salepercent<1)?$salepercent:1;Just under the lines:
function var_pricerange($varchkoptsarr, $varregprice, $varsaleprice)
{
global $Currency; -
Change the line:
$salepricearr[] = number_format(floatval($varsaleprice + $optdetails[1]), 2, '.', '');
to:
$salepricearr[] = number_format(floatval($varsaleprice + ($optdetails[1]*$salepercent)), 2, '.', '');
-
Open the products_detail.php, products_multisingle.php and products_single.php files in the /enc/ folder.
-
In each of these files, change the line:
$display_formflds = var_formfields($pgnm_noext, $searchrow[ID], $Return_URL, $stripitem, $unitinfo, $unitprice, $searchrow[Units], $searchrow[TaxPercent], $searchrow[Wholesale], $display_description);
to:
$display_formflds = var_formfields($pgnm_noext, $searchrow[ID], $Return_URL, $stripitem, $unitinfo, $unitprice, $searchrow[RegPrice], $searchrow[Units], $searchrow[TaxPercent], $searchrow[Wholesale], $display_description);
-
Open the products_options.php file in the /enc/ folder.
-
Add the lines:
// GET SALE PERCENTAGE
$salepercent=1;
if(!empty($searchrow[SalePrice]) AND !empty($searchrow[RegPrice]) AND $searchrow[SalePrice]<$searchrow[RegPrice])
$salepercent=($searchrow[SalePrice]/$searchrow[RegPrice]);
$salepercent=($salepercent>0 AND $salepercent<1)?$salepercent:1;just under the lines:
else
$regprice = ""; -
Change the line:
$newattprice = number_format(floatval($unitprice + $attribute[1]), 2, '.', '');
to:
$newattprice = number_format(floatval($unitprice + ($attribute[1]*$salepercent)), 2, '.', '');
-
Open the order.php file in the /go/ folder.
-
Add the lines:
// GET SALE PRICE PERCENTAGE
if(!empty($price) AND !empty($origprice) AND $price<$origprice)
$salepercent=($price/$origprice);
$salepercent=($salepercent>0 AND $salepercent<1)?$salepercent:1;just above the lines:
// BYPASS COOKIE TAX
-
Change the lines:
if ($attributes[1])
$price = $price + str_replace(",", "", $attributes[1]);to:
// ATTRIBUTE PRICING - INCLUDE SALE PERCENT
if ($attributes[1])
{
$att_price=(float)str_replace(",", "", $attributes[1]);
$price = $price + ($att_price*$salepercent);
} -
Save and reload all files.