test for existence of shipping address and use that, otherwise use billing address
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
trav 2024-07-10 19:31:36 -04:00
parent 70886ea67d
commit 45c13bf515

View File

@ -120,9 +120,26 @@ if(!is_user_logged_in()){
<?php <?php
foreach ($_GET["order_ids"] as $order_id) { foreach ($_GET["order_ids"] as $order_id) {
$order = wc_get_order($order_id); $order = wc_get_order($order_id);
$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(); $first_name = $order->get_billing_first_name();
$last_name = $order->get_billing_last_name(); $last_name = $order->get_billing_last_name();
$postcode = $order->get_billing_postcode(); $postcode = $order->get_billing_postcode();
} else {
$first_name = $shipping_first_name;
$last_name = $shipping_last_name;
$postcode = $shipping_postcode;
}
$items = $order->get_items(); $items = $order->get_items();
$total_items = $order->get_item_count(); $total_items = $order->get_item_count();
$roast_date = (new DateTime())->modify("-3 days")->format("d/m/Y"); $roast_date = (new DateTime())->modify("-3 days")->format("d/m/Y");