Support » Plugin: Woo Zap Mirror » Skip item that not in stock, instead of using the ‘Hide Product’ feature

  • Resolved ofirkif

    (@ofirkif)


    Hi Ido,

    First, as I said in my review – thanks for ur great plugin, works perfectly!

    I have a question that I need ur help with products that aren’t in stock in shop, hope u can help me with that.
    I’m trying to automate the get_products() function and to get the stock status from Woo, then to use this value to skip this product programmatically in the function if the product is out of stock, instead of ticking the checkbox ‘Hide Product’ per product.

    I can get the stock status with get_stock_status(), and I believe I need to make this checking in get_products() function, before creating the XML function as I don’t want to send this specific product to the XML.

    Can u help me with the placement of this If statement to achieve this idea in ur code?
    I believe it should be placed near line 523, as I can see ur checking if item is disabled:

    			'meta_query' => array(
    				'relation' => 'OR',
    				array(
    					'key'     	=> '_wc_zap_disable',
    					'value'		=> 'yes',
    					'compare' 	=> '!='
    				),
    				array(
    					'key' 		=> '_wc_zap_disable',
    					'compare' 	=> 'NOT EXISTS'
    				)
    			)

    Thanks a lot!
    Ofir.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Ido Friedlander

    (@idofri)

    Something like that:

    add_filter( 'wc_zap_mirror_wp_query', function( $args ) {
    	$args['meta_query'] = array(
    		'relation' => 'AND',
    		array(
    			'key'     => '_stock_status',
    			'value'   => 'instock',
    			'compare' => '=',
    		),
    		array(
    			'relation' => 'OR',
    			array(
    				'key'     	=> '_wc_zap_disable',
    				'value'		=> 'yes',
    				'compare' 	=> '!='
    			),
    			array(
    				'key' 		=> '_wc_zap_disable',
    				'compare' 	=> 'NOT EXISTS'
    			)
    		)
    	);
    	return $args;
    } );

    Thanks a lot Ido, works great.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Skip item that not in stock, instead of using the ‘Hide Product’ feature’ is closed to new replies.