Shopp: Custom discount price for products

I’m not sure if anyone will ever have a need for this, but we had a random request from a client regarding price discounts in Shopp. Shopp has a built in discount function that you can set on a product by product basis, but we needed to show a 20% discount automatically based on the list price for each product.

How to:

So the first thing we did was open the product.php template (wp-content > plugins > shopp > core > model > product.php) and create a new case for the product table called “pricediscounted”. This will check the list price of a product and deduct 20%.

case "pricediscounted":
     if (empty($this->prices)) $this->load_data(array('prices'));
     $list_price = $this-> min['price'] + ($this-> min['price']*$taxrate);
     return money($list_price - ($list_price*0.20));

Next we wanted to show the exact amount the user would be saving. So we created another case that would calculate what 20% would amount to.

case "pricepercent":
     if (empty($this->prices)) $this->load_data(array('prices'));
     $list_price = $this->min['price'] + ($this->min['price']*$taxrate);
     return money($list_price - ($list_price*0.80));

Finally, here is an example of how you can display this information on your site. Simply place the following anywhere you are using the product loop.

List Price: <?php shopp('product','price'); ?>
Online Price: <span><?php shopp('product','pricediscounted'); ?>
A savings of: <?php shopp('product','pricepercent'); ?>