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

1
2
3
4
5
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));
     break;

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.

1
2
3
4
5
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));
     break;

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.

1
2
3
List Price: <?php shopp('product','price'); ?>
Online Price: <span><?php shopp('product','pricediscounted'); ?>
A savings of: <?php shopp('product','pricepercent'); ?>
Continue Reading...

Thank You Foraker Labs

Today is a little bittersweet for me as this will be my last day at Foraker Labs. About a month ago I accepted an offer at Mapleton Hill Media to jump on board as their Senior Designer/Creative Director. A lot of thought and prayer from both my wife and me went into making this decision, as I have absolutely loved working at Foraker Labs with some of the most talented people I have ever met. It was also a tough decision after having received a few offers late last year, including one from Disney Interactive; I turned them down to stay on board with Foraker Labs, as I felt this was where I needed to be.

Since making the decision to stay, I have enjoyed taking on the challenge of helping shift Foraker Labs into their new direction of primarily being a Ruby on Rails shop and no longer focusing on marketing websites. In this process I was able to help them re-brand and create a new image that would help sell their credibility as a creative and very talented development shop to both their clients and industry peers. I have to say, it has gone beautifully. They have received nothing but good remarks on their new image.

While working at Foraker Labs, I have been able to be a part of creating user interfaces for some amazing web apps, and I am very happy to have been a part of each of them.

Since the

Continue Reading...

Show Related Posts by Term Value

Here’s a another quick tip. I needed to create a simple WordPress query that would find related posts tagged with the same term as the current post. Also, I needed to make sure it wouldn’t include the current post in the return. This worked for me, but feel free to offer suggestions that can make this better.

The Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
global $post;
$terms = get_the_terms( $post->ID , 'taxonomy_slug_goes_here', 'string');  // Insert the slug of the taxonomy in which you would like to check for related terms
$current_post[] = $post->ID;
 
if(!empty($terms)){
    foreach ($terms as $term) {
        query_posts( array(
        'taxonomy_slug_goes_here' => $term->slug,  // Insert the slug of the taxonomy in which you would like to check for related terms
        'showposts' => 3,  // Set how many posts you would like to return
        'caller_get_posts' => 1,
        'post__not_in' => $current_post ) );  // Makes sure to not include the current post
        if(have_posts()){
            while ( have_posts() ) : the_post(); $current_post[] = $post->ID; ?>
            Related post content goes here
            <?php endwhile; wp_reset_query();
        }
    }
}
?>
Continue Reading...

WordPress: Query Posts by Taxonomy Term Value

Here’s a simple way to create a custom query for posts by term value. It’s pretty straight forward but if you see a way to improve it, feel free to let me know.

The Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
// Define the arguments for the query here.
$args=array(
  'taxonomy' => 'taxonomy_slug_here',
  'term' => 'term_slug_here',
  'post_type' => 'custom_post_type_slug_here',
  'posts_per_page' => -1,
  'caller_get_posts'=> 1,
  'orderby'=> 'post_date',
  'order'=> 'ASC',
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
   while ($my_query->have_posts()) : $my_query->the_post(); ?>
    Call the post content here
   <?php endwhile; 
} wp_reset_query(); ?>
Continue Reading...
Older Posts