Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Load Checkout Override
- * @version 1.0
- */
- add_action( 'after_setup_theme', 'mycred_pro_setup_woo_mycred_checkout', 120 );
- function mycred_pro_setup_woo_mycred_checkout() {
- if ( ! function_exists( 'mycred' ) || ! is_user_logged_in() ) return;
- remove_filter( 'woocommerce_available_payment_gateways', 'mycred_woo_available_gateways' );
- add_filter( 'woocommerce_available_payment_gateways', 'mycred_pro_woo_checkout_limit' );
- }
- /**
- * Limit Checkout Gateways
- * Removes the myCRED gateway if a user has less then 5000 points
- * @version 1.0
- */
- function mycred_pro_woo_checkout_limit( $gateway ) {
- // prep
- $user_id = get_current_user_id();
- $mycred = mycred();
- // user is excluded
- if ( $mycred->exclude_user( $user_id ) ) {
- unset( $gateways['mycred'] );
- return $gateways;
- }
- // balance check
- $balance = $mycred->get_users_balance( $user_id );
- if ( $balance < 5000 ) {
- unset( $gateways['mycred'] );
- return $gateways;
- }
- return $gateways;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement