• Resolved David Wang

    (@blogjunkie)


    I want to hide the “Ship to” Shipping Address when the order’s shipping option is Local Pickup. How can I do this please?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @blogjunkie,

    To achieve what you want, please add this code snippet to your site:

    /**
     * WooCommerce PDF Invoices & Packing Slips:
     * Hide 'Ship To' heading if the shipping method is 'Local pickup'
     */
    add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
    	if ( $document_type == 'invoice' && ( $shipping_methods = $document->order->get_shipping_methods() ) ) {
    		// Check shipping methods
    		if ( $shipping_methods ) {
    			$first_method = array_shift( $shipping_methods );
    			$shipping_method_id = $first_method->get_method_id();
    		}		
    		if ( $shipping_method_id == 'local_pickup' ) {
    		?>
    		.shipping-address h3 {
    			display: none;
    		}
    		<?php
    		}
    	}
    }, 10, 2 );

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

    Let me know if it worked!

    Thread Starter David Wang

    (@blogjunkie)

    Thank you so much for the quick reply! I actually want to hide the shipping address entirely, so I guess I should just use .shipping-address as the selector? Please let me know how I can find the HTML markup for the invoice and I will figure out the CSS myself.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    In your first message you specifically that you only wanted “to hide the “Ship to” Shipping Address when the order’s shipping option is Local Pickup”, that’s why I wrote the code snippet ??

    If you want to hide the shipping address altogether, you don’t need to add any code snippet, but go to WooCommerce?> PDF?Invoices?> Documents?> Invoice, find the Display shipping address setting and choose No.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide shipping address for Local Pickup’ is closed to new replies.