Disable Shipping

If you are using any other plugin along with WP Crowdfunding and that requires shipping, then there might be a conflict with the shipping gateway. To avoid that, you can disable the shipping system for WP Crowdfunding products.

You need to add the following snippet in the wp-crowdfunding/includes/woocommerce/Woocommerce.php file. The line number is 55.

add_filter( 'woocommerce_cart_needs_shipping_address', array($this, 'disable_shipping') );
add_filter( 'woocommerce_cart_ready_to_calc_shipping', array($this, 'disable_shipping'), 99);
function disable_shipping() {
    global $woocommerce;
    $has_crowdfunding_product = false;
    $items = $woocommerce->cart->get_cart();
    if( $items) {
        foreach($items as $item => $values) {
            $product = wc_get_product( $values['product_id'] );
            if( $product->get_type() == 'crowdfunding' ){
                $has_crowdfunding_product = true;
            }
        }
    }
    return !$has_crowdfunding_product;
}

Was this helpful?