Exemple #1
0
    public static function getParcels($id_order, $id_package_ws = null)
    {
        if ($id_package_ws) {
            $parcels = Db::getInstance()->executeS('
				SELECT `id_parcel`, `content`, `weight`, `height`, `length`, `width`, `number`
				FROM `' . bqSQL(_DB_PREFIX_ . self::$definition['table']) . '`
				WHERE `id_package_ws`=' . (int) $id_package_ws);
            return $parcels;
        }
        $products = DpdPolandParcelProduct::getShippedProducts($id_order);
        $parcels = array();
        $content = '';
        $weight = $height = $length = $width = 0;
        $products_count = count($products);
        if ($products_count == 1) {
            $product = reset($products);
            $height = DpdPoland::convertDimention($product['height']);
            $length = DpdPoland::convertDimention($product['length']);
            $width = DpdPoland::convertDimention($product['width']);
        }
        foreach ($products as $product) {
            $content .= $product['id_product'] . '_' . $product['id_product_attribute'];
            if (--$products_count) {
                $content .= ', ';
            }
            $weight += DpdPoland::convertWeight($product['weight']);
        }
        $parcels[] = array('number' => 1, 'content' => $content, 'weight' => $weight, 'height' => sprintf('%.6f', $height), 'length' => sprintf('%.6f', $length), 'width' => sprintf('%.6f', $width));
        return $parcels;
    }
 private static function extractAndFormatProductData(&$product)
 {
     $id_product = isset($product['product_id']) ? (int) $product['product_id'] : (int) $product['id_product'];
     $id_product_attribute = isset($product['product_attribute_id']) ? (int) $product['product_attribute_id'] : (int) $product['id_product_attribute'];
     $product_name = isset($product['product_name']) ? $product['product_name'] : $product['name'];
     $product_weight = isset($product['product_weight']) ? $product['product_weight'] : $product['weight'];
     if (isset($product['id_parcel'])) {
         $id_parcel = (int) $product['id_parcel'];
     }
     $product = array('id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'name' => $product_name, 'weight' => DpdPoland::convertWeight($product_weight), 'width' => isset($product['width']) ? DpdPoland::convertDimention($product['width']) : null, 'height' => isset($product['height']) ? DpdPoland::convertDimention($product['height']) : null, 'length' => isset($product['height']) ? DpdPoland::convertDimention($product['depth']) : null);
     if (isset($id_parcel)) {
         $product['id_parcel'] = $id_parcel;
     }
 }