Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Sure, the following code should do that for you (tested on my own site):

    add_filter( 'wpo_wcpdf_listing_actions', 'wpo_wcpdf_disable_ps_for_downloads', 20, 2 );
    function wpo_wcpdf_disable_ps_for_downloads ( $listing_actions, $order ) {
    	// get items from order
    	$items = $order->get_items();
    	// loop through items to check for downloadable items
    	foreach ($items as $item_id => $item) {
    		$product = $order->get_product_from_item( $item );
    
    		// unset packing-slip & break out of loop if downloadable or virtual product
    		if ( $product->is_downloadable() || $product->is_virtual() ) {
    			unset( $listing_actions['packing-slip'] );
    			break;
    		}
    	}
    
    	return $listing_actions;
    }

    Note that this does increase processing time of the orders page!
    Let me know if that works for you!
    Ewout

    Thread Starter TTM-ES

    (@ttm-es)

    Where do you put this filter?

    Thanks for your help?

    Plugin Contributor Ewout

    (@pomegranate)

    in your theme’s functions.php

    Thread Starter TTM-ES

    (@ttm-es)

    Are not working correctly to me. Some orders dissapear and other are at the list but don’t have invoice botton. But its true that all the dowload orders don’t have packing slips.

    Plugin Contributor Ewout

    (@pomegranate)

    That is very odd because the filter does not remove the invoice button (orders disappearing is even stranger). Here’s a version with a few more checks to make sure that it doesn’t try to access data that’s not there. If that doesn’t work, send an email to [email protected] and I’ll see what I can do for you!

    add_filter( 'wpo_wcpdf_listing_actions', 'wpo_wcpdf_disable_ps_for_downloads', 20, 2 );
    function wpo_wcpdf_disable_ps_for_downloads ( $listing_actions, $order ) {
    	// get items from order
    	$items = $order->get_items();
    	// loop through items to check for downloadable items
    
    	if( sizeof( $items ) > 0 ) {
    		foreach ($items as $item_id => $item) {
    			$product = $order->get_product_from_item( $item );
    
    			// unset packing-slip & break out of loop if downloadable or virtual product
    			if ( !empty($product) && ( $product->is_downloadable() || $product->is_virtual() ) ) {
    				unset( $listing_actions['packing-slip'] );
    				break;
    			}
    		}
    	}
    
    	return $listing_actions;
    }

    Ewout

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘NO Packing Slips to digital items’ is closed to new replies.