From 45c13bf515f692f0df4417574fb2e39cd08c5a49 Mon Sep 17 00:00:00 2001 From: trav Date: Wed, 10 Jul 2024 19:31:36 -0400 Subject: [PATCH] test for existence of shipping address and use that, otherwise use billing address --- .../mont58-coffee/template-order-label.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/wp-content/themes/mont58-coffee/template-order-label.php b/wp-content/themes/mont58-coffee/template-order-label.php index 7a76934..cdaa967 100644 --- a/wp-content/themes/mont58-coffee/template-order-label.php +++ b/wp-content/themes/mont58-coffee/template-order-label.php @@ -120,9 +120,26 @@ if(!is_user_logged_in()){ get_billing_first_name(); - $last_name = $order->get_billing_last_name(); + $first_name = $order->get_shipping_first_name(); + $last_name = $order->get_s_last_name(); $postcode = $order->get_billing_postcode(); + + // Check if shipping details exist + $shipping_first_name = $order->get_shipping_first_name(); + $shipping_last_name = $order->get_shipping_last_name(); + $shipping_postcode = $order->get_shipping_postcode(); + + // If any shipping detail is empty, use billing details + if (empty($shipping_first_name) || empty($shipping_last_name) || empty($shipping_postcode)) { + $first_name = $order->get_billing_first_name(); + $last_name = $order->get_billing_last_name(); + $postcode = $order->get_billing_postcode(); + } else { + $first_name = $shipping_first_name; + $last_name = $shipping_last_name; + $postcode = $shipping_postcode; + } + $items = $order->get_items(); $total_items = $order->get_item_count(); $roast_date = (new DateTime())->modify("-3 days")->format("d/m/Y");