Documentation

Add Delivery Date And Time To WooCommerce Print Invoices/Packing Lists By SkyVerge

To add the delivery date and time from WooCommere Delivery Slots to your invoices and packing slips generated by the “WooCommerce Print Invoices/Packing Lists” by SkyVerge, you can use the following code.

To use the code, add it to your child theme’s functions.php file.

/**
 * Adds Delivery date and time slot to the "Shipping Method" section of invoices and packing lists
 * 'Show shipping method' should be enabled for invoices!
 *
 * @param string    $shipping      the shipping method text
 * @param string    $document_type the type of document being viewed
 * @param \WC_Order $order         the order object the document is for
 *
 * @return string the updated shipping string
 */
function iconic_pip_add_delivery_date_shipping( $shipping, $document_type, $order ) {
	// if you want to only add this to invoices, you can add another check for document type
	// if ( 'invoice' !== $document_type ) { 
		return $shipping; 
	}

	// bail if Delivery Slots plugin is not active
	if ( ! class_exists( 'Iconic_WDS' ) ) {
		return $shipping;
	}

	$order_id  = is_callable( array( $order, 'get_id' ) ) ? $order->get_id() : $order->id;
	$date      = get_post_meta( $order_id, 'jckwds_date', true );
	$time_slot = get_post_meta( $order_id, 'jckwds_timeslot', true );

	if ( $date ) {
		$shipping .= '<p>';
		$shipping .= sprintf( __( 'We will try our best to deliver your order on: %s', 'iconic' ), $date );

		if ( $time_slot ) {
			$shipping .= sprintf( ' %s %s', __( 'at', 'iconic' ), $time_slot );
		}

		$shipping .= '</p>';
	}

	return $shipping;
}

add_filter( 'wc_pip_document_shipping_method', 'iconic_pip_add_delivery_date_shipping', 10, 3 );

You will now be able to see the delivery date and time slot on your invoices and packing slips.

delivery date and time slot on invoice

Are you using WooCommerce Delivery Slots yet?

Start your 14-day free trial right now and get instant access to the features described in this article.

or learn more

Was this helpful?

Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.

WooCommerce Delivery Slots

WooCommerce Delivery Slots

Not got the plugin yet? Get instant access right now, free for 14 days.

or learn more

Still need help?

If you haven't found what you're looking for in our documentation, please contact support.

Get Support