Created
February 12, 2013 15:13
-
-
Save TravisBallard/4770528 to your computer and use it in GitHub Desktop.
Causes 500 Internal Server Error after saving a page and clicking 'view page' in the updated notice.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* add discount to logged in users based on available capabilities | |
* | |
* @param mixed $cart | |
*/ | |
function vpm_apply_discount( $cart ) | |
{ | |
if( ! is_user_logged_in() ){ | |
$cart->remove_coupons(); | |
return; | |
} | |
if( current_user_can( 'view_gold' ) ){ | |
if( ! $cart->has_discount( 'VPMGOLD20' ) ){ | |
$cart->add_discount( 'VPMGOLD20' ); | |
} | |
} | |
if( current_user_can( 'view_silver' ) ){ | |
if( ! $cart->has_discount( 'VPMSILVER15' ) ){ | |
$cart->add_discount( 'VPMSILVER15' ); | |
} | |
} | |
if( current_user_can( 'view_bronze' ) ){ | |
if( ! $cart->has_discount( 'VPMBRONZE10' ) ){ | |
$cart->add_discount( 'VPMBRONZE10' ); | |
} | |
} | |
} | |
add_action('woocommerce_before_calculate_totals', 'vpm_apply_discount' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment