Skip to content

Commit

Permalink
Use cart's delivery address for customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlavtox committed Aug 2, 2023
1 parent 2c57d4e commit 9cbec33
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions classes/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -6004,6 +6004,9 @@ public static function getAllCustomizedDatas($id_cart, $id_lang = null, $only_in
return false;
}

// Load cart object to get delivery address ID
$cart = new Cart((int) $id_cart);

if ($id_customization === 0) {
// Backward compatibility: check if there are no products in cart with specific `id_customization` before returning false
$product_customizations = (int) Db::getInstance()->getValue('
Expand Down Expand Up @@ -6044,7 +6047,7 @@ public static function getAllCustomizedDatas($id_cart, $id_lang = null, $only_in
// When a module saves a customization programmatically, it should add its ID in the `id_module` column
$row['value'] = Hook::exec('displayCustomization', ['customization' => $row], (int) $row['id_module']);
}
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $row['id_address_delivery']][(int) $row['id_customization']]['datas'][(int) $row['type']][] = $row;
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $cart->id_address_delivery][(int) $row['id_customization']]['datas'][(int) $row['type']][] = $row;
}

if (!$result = Db::getInstance()->executeS(
Expand All @@ -6058,10 +6061,10 @@ public static function getAllCustomizedDatas($id_cart, $id_lang = null, $only_in
}

foreach ($result as $row) {
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $row['id_address_delivery']][(int) $row['id_customization']]['quantity'] = (int) $row['quantity'];
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $row['id_address_delivery']][(int) $row['id_customization']]['quantity_refunded'] = (int) $row['quantity_refunded'];
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $row['id_address_delivery']][(int) $row['id_customization']]['quantity_returned'] = (int) $row['quantity_returned'];
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $row['id_address_delivery']][(int) $row['id_customization']]['id_customization'] = (int) $row['id_customization'];
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $cart->id_address_delivery][(int) $row['id_customization']]['quantity'] = (int) $row['quantity'];
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $cart->id_address_delivery][(int) $row['id_customization']]['quantity_refunded'] = (int) $row['quantity_refunded'];
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $cart->id_address_delivery][(int) $row['id_customization']]['quantity_returned'] = (int) $row['quantity_returned'];
$customized_datas[(int) $row['id_product']][(int) $row['id_product_attribute']][(int) $cart->id_address_delivery][(int) $row['id_customization']]['id_customization'] = (int) $row['id_customization'];
}

return $customized_datas;
Expand Down

0 comments on commit 9cbec33

Please sign in to comment.