[-] FO : #PSCFV-2158 - Add warning message when a product cannot be delivered to an address

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15021 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mDeflotte
2012-05-03 08:10:09 +00:00
parent 0c66c60f1d
commit 513c9be298
9 changed files with 99 additions and 33 deletions
+4
View File
@@ -1124,6 +1124,10 @@ class CarrierCore extends ObjectModel
{
$address = new Address($id_address);
$id_zone = Address::getZoneById($address->id);
// Check the country of the address is activated
if (!Address::isCountryActiveById($address->id))
return array();
}
else
{
+27
View File
@@ -3307,4 +3307,31 @@ class CartCore extends ObjectModel
);
}
}
/**
* Get all the ids of the delivery addresses without carriers
*
* @param bool $return_collection Return a collection
*
* @return array Array of address id or of address object
*/
public function getDeliveryAddressesWithoutCarriers($return_collection = false)
{
$addresses_without_carriers = array();
foreach ($this->getProducts() as $product)
{
if (!in_array($product['id_address_delivery'], $addresses_without_carriers)
&& !count(Carrier::getAvailableCarrierList(new Product($product['id_product']), null, $product['id_address_delivery'])))
$addresses_without_carriers[] = $product['id_address_delivery'];
}
if (!$return_collection)
return $addresses_without_carriers;
else
{
$addresses_instance_without_carriers = array();
foreach ($addresses_without_carriers as $id_address)
$addresses_instance_without_carriers[] = new Address($id_address);
return $addresses_instance_without_carriers;
}
}
}
+5 -2
View File
@@ -146,9 +146,12 @@ abstract class PaymentModuleCore extends Module
foreach ($packageByAddress as $id_package => $package)
{
$product_list = $package['product_list'];
$carrier = new Carrier($package['id_carrier'], $cart->id_lang);
$order = new Order();
$order->id_carrier = (int)$carrier->id;
if (isset($package['id_carrier']))
{
$carrier = new Carrier($package['id_carrier'], $cart->id_lang);
$order->id_carrier = (int)$carrier->id;
}
$order->id_customer = (int)$cart->id_customer;
$order->id_address_invoice = (int)$cart->id_address_invoice;
$order->id_address_delivery = (int)$id_address;