From a9b655e04f1c0dc93f8684dc095d96d78e18caa2 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Tue, 16 Jul 2024 18:23:05 -0400 Subject: [PATCH] Fix incorrect label generation --- .../themes/mont58-coffee/template-order-label.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-content/themes/mont58-coffee/template-order-label.php b/wp-content/themes/mont58-coffee/template-order-label.php index f81cf00..4ee0ddf 100644 --- a/wp-content/themes/mont58-coffee/template-order-label.php +++ b/wp-content/themes/mont58-coffee/template-order-label.php @@ -141,11 +141,11 @@ if(!is_user_logged_in()){ $order_subscription_coffees = get_field("coffees", $order_id); - $j = 0; - $is_new = false; foreach ($items as $item) { + $j = 0; + // checking if product is a coffee $product_id = $item->get_product_id(); $product_categories = get_the_terms($product_id, "product_cat"); @@ -167,6 +167,9 @@ if(!is_user_logged_in()){ } } } + + $product_name = ''; + $roast = ''; if ($is_coffee || $is_subscription) { $brew_method = $item->get_meta("pa_brew-method"); @@ -197,7 +200,8 @@ if(!is_user_logged_in()){ $quantity = $item->get_quantity(); for ($i = 0; $i < $quantity; $i++) { if ($is_subscription) { - if (is_object($order_subscription_coffees[$i + $j]["coffee"])){ + if (($order_subscription_coffees !== null) + && (is_object($order_subscription_coffees[$i + $j]["coffee"]))){ $coffee = $order_subscription_coffees[$i + $j]["coffee"]; $product_name = $coffee->post_title; $roast = get_field("roast_level", $coffee->ID);