Hide shipping address for Local Pickup

[ad_1]

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!

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.

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.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer