Lee Willis

Sort variations by price in Easy Digital Downloads

| 3 Comments

A discussion with my two children about pocket money gave me a real life reminder about the concept of anchoring.

Since my new WordPress plugin store has only recently gone live, and I’m still firmly in the tinkering / tweaking / post go-live phase I thought I’d a bit of experimenting with anchoring in the context of licence pricing.

I currently sell three different licence options, the options look like this:

before

I wondered if anchoring might affect people’s perception of value both in terms of overall conversion, and/or upsell from single licence purchases to multi-site licences. So I figured I’d swap the variations around – showing the most expensive option first, and pre-selecting it. In a future experiment I’ll also probably experiment with pre-selecting the middle-price option, or the cheapest while maintaining the order.

My new store uses the Easy Digital Downloads plugin, and fortunately it’s full of handy hooks and filters that let you change default behaviour. So ┬áhere’s a short snippet that you can drop in your theme’s functions.php, or a standalone plugin. It will order your variations by price, highest price first.

/**
 * Custom usort() callback that sorts on the "amount" within the array principally, falling back to "name" if required.
 * @param  array  $a  The first value to compare.
 * @param  array  $b  The first value to compare.
 * @return int        -1 if $a should be sorted before $b, 1 otherwise.
 */
function pblw_edd_purchase_variable_prices_sort( $a, $b ) {
        if ( $a['amount'] == $b['amount'] ) {
                return $a['name'] > $b['name'] ? -1 : 1;
        }
        return $a['amount'] > $b['amount'] ? -1 : 1;
}

/**
 * Sort the variations so that the most expensive is presented first.
 *
 * @param  array  $prices       Array of variations available for purchase.
 * @param  int    $download_id  The download that the variations belong to.
 * @return array                The modified list of variations, sorted on price descending.
 */
function pblw_edd_purchase_variable_prices( $prices, $download_id ) {
        usort( $prices, 'pblw_edd_purchase_variable_prices_sort' );
        return $prices;
}
add_filter( 'edd_purchase_variable_prices', 'pblw_edd_purchase_variable_prices', 10, 2 );

The end result looks like this:

after

I don’t expect that I’ll be able to generate any hugely statistically significant data from this experiment – but I’ll try and revisit it in a month or two and let you know how I get on!

3 Comments

  1. Hi Lee,

    Found your site via GitHub. Interesting concept here and I’d be interested to see the result of this data you’re testing.

    Also browsed your EDD and other plugins. Good stuff you’re doing sir, looks excellent:)

    If you ever want to chat about the plugin business, please don’t hesitate to shoot me an email…

    Adam

    • Hi Adam,

      I actually shelved it as I’m testing a few other things at the minute and changing too much at once never really provides useful information. I am planning on reinstating it at some point though!

  2. Ah I see. You’re right, too many changes at once never solves anything;)

Leave a Reply

Required fields are marked *.