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
It is great that anyone can access if they know the direct URL for the private page.
My issue is the link shows automatically in the post navigation section for logged-in users. I do not want all logged-in users to access private unless they have direct links.
Can someone help on how to remove private page links in post navigation for logged-in users?
]]>Simple and effective plugin, but seems broken since 3.6.1 (or maybe 3.6, didn’t try this for a while)
Kind regards,
V/
It may have caught it some time it was not private, but unlikely. Anyone else have an issue with this?
]]>