• Resolved carmolim

    (@carmolim)


    Hello, I just installed the plugin and I found it awesome, but in some tests I did the plugin shows products (gift wraps) that aren’t in stock. I also have checked the option to not show out of stock products in the woocommerce configuration but they are still appearing.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Little Package

    (@littlepackage)

    Hello, and sorry for the delay. I am on sabbatical until mid November and so cannot address this until then. If you find solutions before then, please share and I will integrate. I’d love to help now but am traveling without a computer. Thank you.

    freeaanzee

    (@freeaanzee)

    Hi,

    I ran into the same problem. A quick fix is to add a meta_query for the stock status to the get_giftwrapped_products() function in woocommerce-gift-wrapper.php (L280):

    $args = array(
    	'post_type' => 'product',
    	'post_status' => 'publish',
    	'posts_per_page' => '-1',
    	'tax_query' => array(
    		array(
    			'taxonomy' => 'product_cat',
    			'field' => 'slug',
    			'terms' =>  $giftwrap_category_slug->slug
    		)
    	),
    	'meta_query' => array(
    		array(
    			'key' => '_stock_status',
    			'value' => 'instock'
    		)
    	),
    );

    It would be better to use the new WooCommerce 3.0 product getters, and include some extra checks on e.g. backorders, but this does the trick :).

    Thumbs up for the nice plugin, by the way!

    • This reply was modified 7 years ago by freeaanzee.
    Little Package

    (@littlepackage)

    Hello @freeaanzee,

    Those are places I will be headed with this when I return later this month. Thank you for offering this stopgap solution. I completely endorse this code, and if there was an easy way to integrate it from where I am, I’d just do it. But you’re right it’s definitely needing other updates. Thank you very much.

    freeaanzee

    (@freeaanzee)

    You’re welcome, enjoy the sabbatical! Code is never finished :P.

    Little Package

    (@littlepackage)

    This is resolved with version 2.0.6

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Showing optins withou stock’ is closed to new replies.