spivurno
12/8/2013 - 2:17 PM

Gravity Perks: Limit Choices // Display unavailable message for choices when limit is reached

Gravity Perks: Limit Choices // Display unavailable message for choices when limit is reached

<?php

/**
* Display unavailable message for choices when limit is reached
* http://gravitywiz.com/gravity-perks/
*/

add_filter( 'gplc_remove_choices', '__return_false' );

add_filter( 'gwlc_pre_render_choice', 'my_add_unavailable_message', 10, 2 );
function my_add_unavailable_message($choice, $exceeded_limit) {
    
    if(!$exceeded_limit)
        return $choice;
    
    $unavailable_message = '<span style="font-style:italic;font-weight:normal;">' .
        'Sorry, this class is full. Please <a href="mailto:david@ounceoftalent.com">contact us</a> to be put on a waiting list.' .
        '</span>';
        
    $choice['text'] = $choice['text'] . "<br />$unavailable_message";
    
    return $choice;
}