function calculatePrice($price_column_, $qty_)
{
    $qty_array = getPricesToQty($price_column_);
    $total_price = 0;
    foreach ($qty_array as $price) {
        if ($qty_ >= $price[0]) {
            $total_price = $price[1];
        }
    }
    return $total_price;
}
                ?>

                                                                   </td>

                                                                        <?php 
            }
            ?>

                                                                </tr>

                                                                <?php 
            $count = 0;
            while ($products_size = tep_db_fetch_array($products_sizes_query)) {
                $count++;
                if ($count > 0) {
                    $qty_array = getPricesToQty($products_size['plant_price']);
                }
                ?>

                                                                        <tr class="data">

                                                                                <td class="first">

                                                                                        <?php 
                echo tep_draw_hidden_field('products_id[]', $products_size['products_plant_id']) . tep_draw_input_field('cart_quantity[]', '', 'size="3" class="' . $product_info['products_id'] . '"');
                ?>

                                                                                </td>

                                                                                <td>
Example #3
0
function showPriceTable($product_id, $customer_id, $maat = '*ALL*', $aantal = 1, $table = true)
{
    global $currencies;
    $aboId_query = tep_db_query('SELECT abo_id FROM customers WHERE customers_id = "' . $customer_id . '"');
    $get_model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int) $product_id . "'");
    if (tep_db_num_rows($aboId_query) > 0 && tep_db_num_rows($get_model_query) > 0 && SOAP_SERVER != '') {
        $abo_id = tep_db_fetch_array($aboId_query);
        $get_model = tep_db_fetch_array($get_model_query);
        $Prices = SoapPriceRequest($get_model['products_model'], $abo_id['abo_id'], $maat, $aantal);
        if (is_array($Prices)) {
            $thisCustomersPriceClass = 'Prijs' . $Prices['Klant']['prijsCategorie'];
            if ($table == 'true') {
                $products_sizes_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_PLANT . " WHERE products_model = '" . tep_db_input($get_model['products_model']) . "' ORDER BY plant_sort ASC");
                $products_titles_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_PLANT . " WHERE products_model = '" . tep_db_input($get_model['products_model']) . "' ORDER BY plant_price ASC");
                $products_titles = tep_db_fetch_array($products_titles_query);
                $titles_array = getPricesToQty($products_titles['plant_price']);
                $result = '<table border="0" cellpadding="0" cellspacing="0" class="plantsizes-table" width="100%">';
                //Heading
                if (tep_db_num_rows($products_sizes_query) > 0) {
                    $result .= '<tr class="heading"><td class="first">' . Translate('Aantal') . '</td><td>' . Translate('Maat') . '</td>';
                } else {
                    $result .= '<tr class="heading"><td class="first">' . Translate('Aantal') . '</td>';
                }
                foreach ($Prices['Data']['Basis'] as $class => $data) {
                    if ($class == $thisCustomersPriceClass) {
                        $result .= '<td class="active">' . Translate('Uw prijs') . '</td>';
                    } else {
                        $result .= '<td>' . $class . '</td>';
                    }
                }
                $result .= '</tr>';
                //eof Heading
                $count = 0;
                if (tep_db_num_rows($products_sizes_query) > 0) {
                    while ($products_size = tep_db_fetch_array($products_sizes_query)) {
                        $count++;
                        if ($count > 0) {
                            $result .= '<tr class="data">';
                        }
                        $result .= '<td class="first">';
                        $result .= tep_draw_hidden_field('products_id[]', $products_size['products_plant_id']) . tep_draw_input_field('cart_quantity[]', '', 'size="3" class="' . $product_info['products_id'] . '"');
                        $result .= '</td>';
                        $result .= '<td>';
                        $result .= $products_size['plant_maat'];
                        $result .= '</td>';
                        $data = $Prices['Data']['Basis'];
                        foreach ($Prices['Data'] as $Reeks => $reeksData) {
                            //Data uit de juiste reeks ophalen
                            if (strstr(';' . $Reeks . ';', ';' . $products_size['plant_maat'] . ';')) {
                                $data = $reeksData;
                            }
                        }
                        foreach ($data as $class => $price) {
                            if ($class == $thisCustomersPriceClass) {
                                $result .= '<td class="active">';
                            } else {
                                $result .= '<td class="disabled">';
                            }
                            $result .= $currencies->format($price);
                            $result .= '</td>';
                        }
                        $result .= '</tr>';
                    }
                } else {
                    $result .= '<tr class="data">';
                    $result .= '<td class="first">';
                    $result .= tep_draw_hidden_field('products_id[]', $product_id) . tep_draw_input_field('cart_quantity[]', '', 'size="3"');
                    $result .= '</td>';
                    $data = $Prices['Data']['Basis'];
                    foreach ($data as $class => $price) {
                        if ($class == $thisCustomersPriceClass) {
                            $result .= '<td class="active">';
                        } else {
                            $result .= '<td class="disabled">';
                        }
                        $result .= $currencies->format($price);
                        $result .= '</td>';
                    }
                    $result .= '</tr>';
                }
                $result .= '<tr class="data">';
                $result .= '<td colspan="6">';
                $result .= '<input type="submit" class="button-a" value="' . Translate('Voeg toe aan winkelwagen') . '" />';
                $result .= '</td>';
                $result .= '</tr>';
                $result .= '</table>';
            } else {
                if ($Prices['Data']['Netto']) {
                    $result = $Prices['Data']['Netto'];
                } else {
                    $result = $Prices['Data']['Basis'][$thisCustomersPriceClass];
                }
            }
        } else {
            $result = Translate('Er zijn geen prijzen voor u gevonden. Neem a.u.b. contact met ons op.');
        }
    } else {
        $result = Translate('Er zijn geen prijzen voor u gevonden. Neem a.u.b. contact met ons op.');
    }
    return $result;
}
 function get_products()
 {
     global $languages_id, $_SERVER, $customer_id;
     if (!is_array($this->contents)) {
         return false;
     }
     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         if (USE_PRICES_TO_QTY == 'true') {
             $products_query = tep_db_query("select p.products_id, pp.products_plant_id, pp.plant_price, pp.plant_maat, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_discount, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p JOIN " . TABLE_PRODUCTS_PLANT . " pp USING (products_model), " . TABLE_PRODUCTS_DESCRIPTION . " pd where pp.products_plant_id = '" . (int) $products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int) $languages_id . "'");
             if (tep_db_num_rows($products_query) < 1) {
                 $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int) $products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int) $languages_id . "'");
             }
         } else {
             $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int) $products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int) $languages_id . "'");
         }
         if ($products = tep_db_fetch_array($products_query)) {
             $prid = $products['products_id'];
             if (USE_PRICES_TO_QTY == 'true') {
                 //Calculate products price
                 if (SOAP_STATUS == 'true') {
                     if ($this->contents[$products_id]['price']) {
                         $products_price = $this->contents[$products_id]['price'];
                     } else {
                         $products_price = showPriceTable($prid, $customer_id, $products['plant_maat'], $this->contents[$products_id]['qty'], $table = false);
                         $this->contents[$products_id]['price'] = $products_price;
                     }
                 } else {
                     $products_price = calculatePrice($products['plant_price'], $this->contents[$products_id]['qty']);
                     if (isset($products['products_discount']) && strlen($products['products_discount']) > 2) {
                         if ($tranche = explode(',', $products['products_discount'])) {
                             foreach ($tranche as $cle => $trn) {
                                 if ($qty_px = explode(':', $trn)) {
                                     if ($this->contents[$products_id]['qty'] >= $qty_px[0]) {
                                         $products_price = $qty_px[1];
                                     }
                                 }
                             }
                         }
                     }
                 }
             } else {
                 if (SOAP_STATUS == 'true' && SOAP_PRICE == 'true') {
                     if ($this->contents[$products_id]['price']) {
                         $products_price = $this->contents[$products_id]['price'];
                     } else {
                         $products_price = showCustomerPrice($prid, $customer_id, $this->contents[$products_id]['qty']);
                         $this->contents[$products_id]['price'] = $products_price;
                     }
                 } else {
                     //DISCOUNT
                     $discount_price = tep_get_discountprice($products['products_price'], $customer_id, $customer_group, $products['products_id'], $cPath, $products['manufacturers_id']);
                     if ($discount_price['lowest']['discount'] > 0 || $discount_price['lowest']['price'] > 0 && PRICE_BOOK == 'true') {
                         if ($new_price = tep_get_products_special_price($products['products_id'])) {
                             if ($new_price < $discount_price['lowest']['price']) {
                                 $products_price = $new_price;
                             } else {
                                 $products_price = $discount_price['lowest']['price'];
                             }
                         } else {
                             $products_price = $discount_price['lowest']['price'];
                         }
                     } else {
                         if ($new_price = tep_get_products_special_price($products['products_id'])) {
                             $products_price = $new_price;
                         } else {
                             $products_price = $products['products_price'];
                         }
                     }
                     if (PRICE_BOOK == 'true') {
                         foreach ($discount_price['others'] as $prices) {
                             if ($prices['min_amount'] <= $this->contents[$products_id]['qty'] && $prices['price'] < $products_price) {
                                 $products_price = $prices['price'];
                             }
                         }
                     }
                     //END DISCOUNT
                 }
             }
             if (USE_PRICES_TO_QTY == 'true') {
                 //Lets get all sized
                 $products_sizes_query = tep_db_query("SELECT plant_description, plant_mc FROM " . TABLE_PRODUCTS_PLANT . " WHERE products_plant_id = '" . $products['products_plant_id'] . "'");
                 $products_size = tep_db_fetch_array($products_sizes_query);
                 $qty_array = getPricesToQty($products_size['plant_price']);
                 if ($products['plant_maat'] != '') {
                     $maat = Translate('Maat') . ': ' . $products['plant_maat'];
                     if ($products_size['plant_mc'] == 'hoogte') {
                         $eenheid = ' cm.';
                     } elseif ($products_size['plant_mc'] == 'stamomtrek') {
                         $eenheid = ' stamomtrek';
                     } elseif ($products_size['plant_mc'] == 'diameter') {
                         $eenheid = ' diameter';
                     } else {
                         $eenheid = '';
                     }
                 } else {
                     $maat = '';
                     $eenheid = '';
                 }
                 if ($products_size['plant_description'] != '') {
                     $descr = $products_size['plant_description'];
                 } else {
                     $descr = '';
                 }
                 $products_array[] = array('id' => $prid, 'size_id' => $products['products_plant_id'], 'original_name' => $products['products_name'], 'name' => $products['products_name'], 'description' => '<span style="font-weight: normal;">' . $descr . '</span>', 'maat' => '<span style="font-weight: normal;">' . $maat . $eenheid . '</span>', 'size' => $products['plant_maat'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => $products_price + $this->attributes_price($products_id), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '');
             } else {
                 $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => $products_price + $this->attributes_price($products_id), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '');
             }
         }
     }
     return $products_array;
 }