Handle previous orders without coffees assigned
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
3wc 2024-07-09 14:17:39 -04:00
parent cd14c04689
commit 6f3069bee9

View File

@ -152,6 +152,7 @@ function action_wcs_renewal_order_created($order, $subscription)
$order_coffees = [];
$seen_subscriptions = [];
if ($last_order_coffees !== false) {
// Get the latest coffee seen in each coffee list from the previous order
foreach (array_reverse($last_order_coffees) as $last_order_coffee) {
if (
@ -174,6 +175,7 @@ function action_wcs_renewal_order_created($order, $subscription)
$last_order_coffee["coffee_list"]->ID
] = $position_in_list;
}
}
// Process coffee items based on the coffees in the last order
process_coffee_items($last_order, $order_coffees, $seen_subscriptions);