I've figured out a way to do this with a bit of code editing. I use the plugin register_plus (or you can use any other plugin that adds custom usermeta at the registration form). I created a custom field called "member-discount".
I can give a code to various members (eg: members of clubs, members of forums, etc) and they enter this code when they register to give them a discount on feature ads.
All the editing is done in form/step-functions.php
At the very top of this page (after all the comments), add the following line:
$discountcodes = array('club1','forum2', 'halfprice'); //edit this array to add in all the discount coupons you want to give out
Then you need to edit 2 functions. First look for the "cp_calc_ad_cost" function. At the start of this function, add:
global $current_user, $discountcodes;
get_currentuserinfo();
This grabs the metadata of the current user, as well as the array of discountcodes specified at the top of the step-functions.php file.
Then look for this line:
// calculate the total cost for the ad.
$totalcost_out = $adlistingfee + $featuredprice;
After that, add:
//check for a discount code
$membercode = strtolower(get_usermeta($current_user->ID, 'member-discount'));
//this gets the current users discount code that they entered at registration (metadata added by register-plus)
if(in_array($membercode, $discountcodes)) {
$totalcost_out = $totalcost_out / 2;
}
The above code divides the total cost by 2... (half price member discount). You can change the sum to be whatever you want... it could be $totalcost_out = $totalcost_out - 5 ($5 discount) as an example.
You also need to edit the function "cp_show_review" to change the price displayed on the page. In this function, the first 2 lines will need to look like this:
global $wpdb, $current_user, $discountcodes
get_currentuserinfo();
(I think there is already a global in the existing code, so you just need to add $current_user and $discountcodes to this, to get the array of codes and the current users metadata).
Look for "<label><?php _e('Total Amount Due','cp');?>:</label>". Go down about 4 lines to the </strong>. After the </strong>, add the following code:
<?php //check for a discount code
$membercode = strtolower(get_usermeta($current_user->ID, 'member-discount'));
if ($postvals['featured_ad']){
if(in_array($membercode, $discountcodes)) {
echo ' (after 50% member discount).';
}
} ?>
The above code only applies the discount to Feature Ads (as I have free normal ads). If you want to apply the discount to normal ads (and you charge for normal ads), just remove the if ($postvals['featured_ad']){ and the last } from that last bit of code.
Cheers,
Kim