• The following code extends plugin functionality to WooCommerce, so visitors can ‘add to cart’ private products.

    // ------------------------------------------------------
    // Provide add to cart/checkout to private products
    // ------------------------------------------------------
    
    add_filter( 'woocommerce_is_purchasable', 'sp_is_purchasable', 10, 2 );
    
    function sp_is_purchasable( $purchasable, $product ) {
        if ( ! $purchasable && $product->product_type != 'grouped' && $product->product_type != 'external' ) {
            if ( 'private' === $product->post->post_status ) {
                $purchasable = true;
            }
    
        }
        return $purchasable;
    }

    Cheers,
    Gabriel

    https://www.ads-software.com/plugins/show-private/

  • The topic ‘WooCommerce integration’ is closed to new replies.