Handle previous orders without coffees assigned
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
cd14c04689
commit
6f3069bee9
@ -152,27 +152,29 @@ function action_wcs_renewal_order_created($order, $subscription)
|
||||
$order_coffees = [];
|
||||
$seen_subscriptions = [];
|
||||
|
||||
// Get the latest coffee seen in each coffee list from the previous order
|
||||
foreach (array_reverse($last_order_coffees) as $last_order_coffee) {
|
||||
if (
|
||||
array_key_exists(
|
||||
$last_order_coffee["coffee_list"]->ID,
|
||||
$seen_subscriptions
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
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 (
|
||||
array_key_exists(
|
||||
$last_order_coffee["coffee_list"]->ID,
|
||||
$seen_subscriptions
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
$position_in_list = array_search(
|
||||
$last_order_coffee["coffee"]->ID,
|
||||
$last_order_coffee["coffee_list"]->coffees
|
||||
);
|
||||
if ($position_in_list === false) {
|
||||
// ignore this, can't find it in list anymore
|
||||
continue;
|
||||
}
|
||||
$seen_subscriptions[
|
||||
$last_order_coffee["coffee_list"]->ID
|
||||
] = $position_in_list;
|
||||
}
|
||||
$position_in_list = array_search(
|
||||
$last_order_coffee["coffee"]->ID,
|
||||
$last_order_coffee["coffee_list"]->coffees
|
||||
);
|
||||
if ($position_in_list === false) {
|
||||
// ignore this, can't find it in list anymore
|
||||
continue;
|
||||
}
|
||||
$seen_subscriptions[
|
||||
$last_order_coffee["coffee_list"]->ID
|
||||
] = $position_in_list;
|
||||
}
|
||||
|
||||
// Process coffee items based on the coffees in the last order
|
||||
|
Loading…
Reference in New Issue
Block a user