コード例 #1
0
 /**
  * Removes all product collections based on a product collection ID list
  * Will also remove the product collection items.
  *
  * @param array $productCollectionIDList array of eZProductCollection IDs
  *
  * @return void
  */
 static function cleanupList($productCollectionIDList)
 {
     $db = eZDB::instance();
     $db->begin();
     // Purge shipping information associated with product collections being removed.
     foreach ($productCollectionIDList as $productCollectionID) {
         eZShippingManager::purgeShippingInfo($productCollectionID);
     }
     eZProductCollectionItem::cleanupList($productCollectionIDList);
     $where = $db->generateSQLINStatement($productCollectionIDList, 'id', false, false, 'int');
     $db->query("DELETE FROM ezproductcollection WHERE {$where}");
     $db->commit();
 }
コード例 #2
0
 function handleShipping($orderID)
 {
     do {
         $order = eZOrder::fetch($orderID);
         if (!$order) {
             break;
         }
         $productCollectionID = $order->attribute('productcollection_id');
         $shippingInfo = eZShippingManager::getShippingInfo($productCollectionID);
         if (!isset($shippingInfo)) {
             break;
         }
         // check if the order item has been added before.
         $orderItems = $order->orderItemsByType('ezcustomshipping');
         // If orderitems allready exists, remove them first.
         if ($orderItems) {
             foreach ($orderItems as $orderItem) {
                 $orderItem->remove();
             }
             $purgeStatus = eZShippingManager::purgeShippingInfo($productCollectionID);
         }
         if (isset($shippingInfo['shipping_items']) and is_array($shippingInfo['shipping_items'])) {
             // Add a new order item for each shipping.
             foreach ($shippingInfo['shipping_items'] as $orderItemShippingInfo) {
                 $orderItem = new eZOrderItem(array('order_id' => $orderID, 'description' => $orderItemShippingInfo['description'], 'price' => $orderItemShippingInfo['cost'], 'vat_value' => $orderItemShippingInfo['vat_value'], 'is_vat_inc' => $orderItemShippingInfo['is_vat_inc'], 'type' => 'ezcustomshipping'));
                 $orderItem->store();
             }
         } else {
             // Made for backwards compability, if the array order_items are not supplied.
             if (!isset($shippingInfo['vat_value'])) {
                 $shippingInfo['vat_value'] = 0;
             }
             if (!isset($shippingInfo['is_vat_inc'])) {
                 $shippingInfo['is_vat_inc'] = 1;
             }
             $orderItem = new eZOrderItem(array('order_id' => $orderID, 'description' => $shippingInfo['description'], 'price' => $shippingInfo['cost'], 'vat' => $shippingInfo['vat_value'], 'is_vat_inc' => $shippingInfo['is_vat_inc'], 'type' => 'ezcustomshipping'));
             $orderItem->store();
         }
     } while (false);
     return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
 }