• Resolved asteptoofar

    (@asteptoofar)


    Hello! Once again thanks for allowing me to do this in English.

    I would like to exclude products from the .yml file if they don’t have a weight. I have tried playing around with me_exclude_post and has_weight but I can’t seem to get anything to work. Any ideas would be much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter asteptoofar

    (@asteptoofar)

    EDIT: Appear to have figured it out with the following code adapted from your answer regarding excluding categories:

    add_filter( 'me_exclude_post', 'me_exclude_product', 10, 3 );
    function me_exclude_product( $exclude, $post, $product ) {
    	$has_weight = $product->has_weight();
    
    	if ( $has_weight !== true ) {
    		$exclude = true;
    	}
    
    	return $exclude;
    }

    Not sure what wasn’t working before but that does the trick. If it’s not the best way, please do let me know.

    Plugin Author Anton Vanyukov

    (@vanyukov)

    Hi @asteptoofar ,

    Sorry for the late reply. Yes, the above example is the correct way to do it.

    Best regards,
    Anton

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude products which don’t have a weight’ is closed to new replies.