Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', 'custom_remove_add_filters' );
- function custom_remove_add_filters(){
- global $woocommerce_auctions;
- remove_filter( 'woocommerce_is_purchasable', array( $woocommerce_auctions, 'auction_is_purchasable' ), 10 );
- add_filter( 'woocommerce_is_purchasable', 'custom_auction_is_purchasable' , 10, 2 );
- }
- function custom_auction_is_purchasable( $is_purchasable, $object ) {
- $object_type = method_exists( $object, 'get_type' ) ? $object->get_type() : $object->product_type;
- if ( $object_type == 'auction' ) {
- if ( get_option( 'simple_auctions_alow_buy_now', 'yes' ) == 'no' && $object->get_auction_bid_count() != '0' && $object->get_auction_closed() != '2' ) {
- return false;
- }
- if ( ! $object->get_auction_closed() && ! $object->get_auction_closed() && $object->get_price() !== '' ) {
- return true;
- }
- if ( ! is_user_logged_in() ) {
- return false;
- }
- $current_user = wp_get_current_user();
- if ( $current_user->ID != $object->get_auction_current_bider() ) {
- return false;
- }
- if ( ! $object->get_auction_closed() ) {
- return false;
- }
- if ( $object->get_auction_closed() != '2' ) {
- return false;
- }
- if ( $object->get_auction_type() == 'reverse' && get_option( 'simple_auctions_remove_pay_reverse' ) == 'yes' ) {
- return false;
- }
- return true;
- }
- return $is_purchasable;
- }
Advertisement
Add Comment
Please, Sign In to add comment