Posted on

Woodmart bid input fix

Here is a bit of CSS and PHP that makes Auctions for WooCommerce bid input look a bit better in Woodmart Theme. Code should go to child theme functions.php and style.css

function custom_enqueue_script() {
    $product = wc_get_product( get_the_ID() );
    if ( $product && $product->get_type() == 'auction') {
        wp_add_inline_script( 'wd-woocommerce-quantity', 'jQuery(document).ready(function($) { woodmartThemeModule.$document.off("click", ".plus, .minus"); });');
    }
}
add_action( 'wp_enqueue_scripts', 'custom_enqueue_script', 999 );

add_filter( 'woodmart_ajax_add_to_cart', 'wpi_remove_add_ajax_to_cart', 10 );
function wpi_remove_add_ajax_to_cart ( $data ){
    $product  = wc_get_product( get_the_ID() );
    if ( is_product() ){
        if ( $product && $product->is_type('auction') ){
            return false;
        }
    }
    return $data;
}
form.auction_form.cart {
    margin: 15px 0;
}

.auction_form .quantity .qty {
    width: 250px !important;
}

input.plus {
    left: 250px;
}
input.minus {
    right: 250px;
}

button.bid_button.button.alt {
    flex: unset;
    left: 355px;
}