示例#1
0
 /**
  * check if all items in the basket can be delivered
  * requires basket full detail
  */
 public function checkDeliveryRestrictions(&$basket, $country_id)
 {
     if (!is_numeric($country_id) || $country_id == 0) {
         return false;
     }
     require_once 'models/ecommerce/ecommerce_delivery_carrier_zone.php';
     $DeliveryZone = new ecommerce_delivery_carrier_zone();
     $delivery_zone_id = $DeliveryZone->getZoneIdByCountry($country_id);
     $products = array();
     foreach ($basket['items'] as &$item) {
         $zones = $item['product']['variety']['limit_to_delivery_zones'];
         if (!empty($zones)) {
             $zones = explode(",", $zones);
             if (is_array($zones)) {
                 if (!in_array($delivery_zone_id, $zones)) {
                     $products[] = $item['product']['name'];
                 }
             }
         }
     }
     if (count($products) > 0) {
         if (!Zend_Registry::isRegistered('ecommerce_delivery:not_deliverable_products_message')) {
             msg("Sorry, we're not able to deliver the following products to your country: " . implode(" ,", $products), 'error');
             Zend_Registry::set('ecommerce_delivery:not_deliverable_products_message', true);
         }
         return false;
     }
     return true;
 }