• Resolved viroproject

    (@viroproject)


    Hello, I would like to exclude this wpo_wcpdf_payment_method hook from the Simple layout, but only for a single product (for me product id 1140). Do you think it’s possible?

    Thanks Luciano

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

    (@dpeyou)

    @viroproject,

    Could you explain what you are trying to achieve?
    It might not be clear what you mean by “excluding the hook”. ??

    Thread Starter viroproject

    (@viroproject)

    Hi Darren, Sorry. I want the payment method not to be shown in the invoices that contain a product (in my case, the one with id 1140). I know, it’s a strange request ??

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for providing more details, @viroproject:

    The following code snippet, that I just wrote for you, should do the trick:

    /**
     * PDF Invoices & Packing Slip for WooCommerce:
     * Add custom styles to the PDF documents 
     */
    add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
    
    	$products_ids = array( 1140 ); // Enter here all the allowed product IDs
    
    	if ( $document_type == 'invoice' && ( $order = $document->order ) ) {
    		foreach( $order->get_items() as $item_id => $item ) {
    			if ( in_array( absint( $item['variation_id'] ), $products_ids ) || in_array( absint( $item['product_id'] ), $products_ids ) ) {
    				// Hide payment method in the invoice
    				?>
    				tr.payment-method {
    					display: none;
    				}
    				<?php
    				break;
    			}		
    		}
    	}
    }, 10, 2 );

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Thread Starter viroproject

    (@viroproject)

    WOW! It works perfectly

    Thanks ??

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m glad to hear that,?@viroproject! ??

    If you don’t mind and have the time, do you think you could leave us a review?

    Thanks in advance and do not hesitate to write us again if you have any other question!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude wpo_wcpdf_payment_method for one product’ is closed to new replies.