• Resolved gprsinformation

    (@gprsinformation)


    I am building a site where a user can buy a downloadable/virtual product, but the product should be single in stock and once purchased shall not be available on the website. How can I achieve this in woocommerce.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi there,

    This is something that will require custom coding, or a plugin.
    I don’t know of a plugin that does this specifically, but others might be able to point you in the right direction.

    For customization, I recommend collaborating with a developer or with someone from our [customizations page](https://woocommerce.com/customizations/).

    I hope this points you in the right direction.

    @gprsinformation

    try this
    Make your product stock only 1 and add this code to functions.php

    add_action( 'pre_get_posts', 'sg_hide_out_of_stock_in_search' );
     
    function sg_hide_out_of_stock_in_search( $query ){
     
    	if( $query->is_search() && $query->is_main_query() ) {
    		$query->set( 'meta_key', '_stock_status' );
    		$query->set( 'meta_value', 'instock' );
    	}
     
    }

    This will hide all product with no stock.

    • This reply was modified 4 years, 2 months ago by Sarankumar.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Single downloadable /virtual product’ is closed to new replies.