コード例 #1
0
ファイル: newpost.php プロジェクト: nomadcomanche/zdorov_shop
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes, $vamPrice;
     if (MODULE_SHIPPING_NEWPOST_MODE == 'price') {
         $order_total = $vamPrice->RemoveCurr($_SESSION['cart']->show_total());
     } else {
         $order_total = $shipping_weight;
     }
     $table_cost = preg_split("/[:,]/", MODULE_SHIPPING_NEWPOST_COST);
     $size = sizeof($table_cost);
     for ($i = 0, $n = $size; $i < $n; $i += 2) {
         if ($order_total <= $table_cost[$i]) {
             $shipping = $table_cost[$i + 1];
             break;
         }
     }
     if (MODULE_SHIPPING_NEWPOST_MODE == 'weight') {
         $shipping = $shipping * $shipping_num_boxes;
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_NEWPOST_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_NEWPOST_TEXT_WAY, 'cost' => $shipping + MODULE_SHIPPING_NEWPOST_HANDLING)));
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
コード例 #2
0
ファイル: sogl.php プロジェクト: nomadcomanche/zdorov_shop
 function quote($method = '')
 {
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_SOGL_TEXT_TITLE);
     $this->quotes['methods'] = array(array('id' => $this->code, 'title' => MODULE_SHIPPING_SOGL_TEXT_WAY, 'cost' => 0));
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
コード例 #3
0
 function process()
 {
     global $order, $vamPrice;
     if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
         switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
             case 'national':
                 if ($order->delivery['country_id'] == STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'international':
                 if ($order->delivery['country_id'] != STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'both':
                 $pass = true;
                 break;
             default:
                 $pass = false;
                 break;
         }
         if ($pass == true && $order->info['total'] - $order->info['shipping_cost'] >= $vamPrice->Format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER, false, 0, true)) {
             $order->info['shipping_method'] = $this->title;
             $order->info['total'] -= $order->info['shipping_cost'];
             $order->info['shipping_cost'] = 0;
         }
     }
     $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
     if (vam_not_null($order->info['shipping_method'])) {
         if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
             // price with tax
             $shipping_tax = vam_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $shipping_tax_description = vam_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $tax = $vamPrice->Format(vam_add_tax($order->info['shipping_cost'], $shipping_tax), false, 0, false) - $order->info['shipping_cost'];
             $tax = $vamPrice->Format($tax, false, 0, true);
             $order->info['shipping_cost'] = vam_add_tax($order->info['shipping_cost'], $shipping_tax);
             $order->info['tax'] += $tax;
             $order->info['tax_groups'][TAX_ADD_TAX . "{$shipping_tax_description}"] += $tax;
             $order->info['total'] += $tax;
         } else {
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
                 $shipping_tax = vam_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                 $shipping_tax_description = vam_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                 $tax = $vamPrice->Format(vam_add_tax($order->info['shipping_cost'], $shipping_tax), false, 0, false) - $order->info['shipping_cost'];
                 $tax = $vamPrice->Format($tax, false, 0, true);
                 $order->info['tax'] = $order->info['tax'] += $tax;
                 $order->info['tax_groups'][TAX_NO_TAX . "{$shipping_tax_description}"] = $order->info['tax_groups'][TAX_NO_TAX . "{$shipping_tax_description}"] += $tax;
             }
         }
         $this->output[] = array('title' => $order->info['shipping_method'] . ':', 'text' => $vamPrice->Format($order->info['shipping_cost'], true, 0, true), 'value' => $vamPrice->Format($order->info['shipping_cost'], false, 0, true));
     }
 }
コード例 #4
0
ファイル: item.php プロジェクト: nomadcomanche/zdorov_shop
 function quote($method = '')
 {
     global $order, $total_count;
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_ITEM_TEXT_WAY, 'cost' => MODULE_SHIPPING_ITEM_COST * $total_count + MODULE_SHIPPING_ITEM_HANDLING)));
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
コード例 #5
0
 function process()
 {
     global $order, $vamPrice;
     //include needed functions
     require_once DIR_FS_INC . 'vam_calculate_tax.inc.php';
     if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == 'true') {
         switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) {
             case 'national':
                 if ($order->delivery['country_id'] == STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'international':
                 if ($order->delivery['country_id'] != STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'both':
                 $pass = true;
                 break;
             default:
                 $pass = false;
                 break;
         }
         if ($pass == true && $order->info['total'] - $order->info['shipping_cost'] < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) {
             $tax = vam_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $tax_description = vam_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
                 $order->info['tax'] += vam_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
                 $order->info['tax_groups'][TAX_ADD_TAX . "{$tax_description}"] += vam_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
                 $order->info['total'] += MODULE_ORDER_TOTAL_LOWORDERFEE_FEE + vam_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
                 $low_order_fee = vam_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
             }
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
                 $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE;
                 $order->info['tax'] += vam_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
                 $order->info['tax_groups'][TAX_NO_TAX . "{$tax_description}"] += vam_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
                 $order->info['subtotal'] += $low_order_fee;
                 $order->info['total'] += $low_order_fee;
             }
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] != 1) {
                 $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE;
                 $order->info['subtotal'] += $low_order_fee;
                 $order->info['total'] += $low_order_fee;
             }
             $this->output[] = array('title' => $this->title . ':', 'text' => $vamPrice->Format($low_order_fee, true), 'value' => $low_order_fee);
         }
     }
 }
コード例 #6
0
function ItemAttributsSetUp($current_product_id)
{
    // I found the easiest way to do this is just delete the current attributes & start over =)
    // download function start
    $delete_sql = vam_db_query("SELECT products_attributes_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . $current_product_id . "'");
    while ($delete_res = vam_db_fetch_array($delete_sql)) {
        $delete_download_sql = vam_db_query("SELECT products_attributes_filename FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id = '" . $delete_res['prducts_attributes_id'] . "'");
        $delete_download_file = vam_db_fetch_array($delete_download_sql);
        vam_db_query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id = '" . $delete_res['products_attributes_id'] . "'");
    }
    // download function end
    vam_db_query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . $current_product_id . "'");
    // Simple, yet effective.. loop through the selected Option Values.. find the proper price & prefix.. insert.. yadda yadda yadda.
    for ($i = 0; $i < sizeof($_POST['optionValues']); $i++) {
        $query = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_values_id = '" . $_POST['optionValues'][$i] . "'";
        $result = vam_db_query($query);
        $matches = vam_db_num_rows($result);
        while ($line = vam_db_fetch_array($result)) {
            $optionsID = $line['products_options_id'];
        }
        $cv_id = $_POST['optionValues'][$i];
        $value_price = $_POST[$cv_id . '_price'];
        if (PRICE_IS_BRUTTO == 'true') {
            $value_price = $value_price / (vam_get_tax_rate(vam_get_tax_class_id($current_product_id)) + 100) * 100;
        }
        $value_price = vam_round($value_price, PRICE_PRECISION);
        $value_prefix = $_POST[$cv_id . '_prefix'];
        $value_sortorder = $_POST[$cv_id . '_sortorder'];
        $value_weight_prefix = $_POST[$cv_id . '_weight_prefix'];
        $value_model = $_POST[$cv_id . '_model'];
        $value_stock = $_POST[$cv_id . '_stock'];
        $value_weight = $_POST[$cv_id . '_weight'];
        vam_db_query("INSERT INTO " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix ,attributes_model, attributes_stock, options_values_weight, weight_prefix,sortorder) VALUES ('" . $current_product_id . "', '" . $optionsID . "', '" . $_POST['optionValues'][$i] . "', '" . $value_price . "', '" . $value_prefix . "', '" . $value_model . "', '" . $value_stock . "', '" . $value_weight . "', '" . $value_weight_prefix . "','" . $value_sortorder . "')") or die(mysql_error());
        $products_attributes_id = vam_db_insert_id();
        if ($_POST[$cv_id . '_download_file'] != '') {
            if (DOWNLOAD_ENABLED == 'true') {
                $value_download_file = $_POST[$cv_id . '_download_file'];
                $value_download_expire = $_POST[$cv_id . '_download_expire'];
                $value_download_count = $_POST[$cv_id . '_download_count'];
                $value_is_pin = $_POST[$cv_id . '_ispin'];
                $products_attributes_is_pin = isset($value_is_pin) ? 1 : 0;
                vam_db_query("INSERT INTO " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " (products_attributes_id, products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount, products_attributes_is_pin) VALUES ('" . $products_attributes_id . "', '" . $value_download_file . "', '" . $value_download_expire . "', '" . $value_download_count . "', '" . $products_attributes_is_pin . "')") or die(mysql_error());
            }
        }
    }
}
コード例 #7
0
 function quote($method = '')
 {
     global $vamPrice;
     if ($vamPrice->RemoveCurr($_SESSION['cart']->show_total()) < MODULE_SHIPPING_FREEAMOUNT_AMOUNT && MODULE_SHIPPING_FREEAMOUNT_DISPLAY == 'False') {
         return;
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_FREEAMOUNT_TEXT_TITLE);
     if ($vamPrice->RemoveCurr($_SESSION['cart']->show_total()) < MODULE_SHIPPING_FREEAMOUNT_AMOUNT) {
         $this->quotes['error'] = sprintf(MODULE_SHIPPING_FREEAMOUNT_TEXT_WAY, $vamPrice->Format(MODULE_SHIPPING_FREEAMOUNT_AMOUNT, true, 0, true));
     } else {
         $this->quotes['methods'] = array(array('id' => $this->code, 'title' => sprintf(MODULE_SHIPPING_FREEAMOUNT_TEXT_WAY, $vamPrice->Format(MODULE_SHIPPING_FREEAMOUNT_AMOUNT, true, 0, true)), 'cost' => 0));
     }
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
コード例 #8
0
 function quote()
 {
     global $order, $shipping_weight;
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_CHRONOPOST_TEXT_TITLE, 'methods' => array());
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     $dest_country = $order->delivery['country']['iso_code_2'];
     $dest_zone = 0;
     for ($i = 1; $i <= $this->num_chronopost; $i++) {
         $countries_table = constant('MODULE_SHIPPING_CHRONOPOST_COUNTRIES_' . $i);
         $country = preg_split("/[,]/", $countries_table);
         if (in_array($dest_country, $country)) {
             $dest_zone = $i;
             break;
         }
     }
     if ($dest_zone == 0) {
         $this->quotes['error'] = MODULE_SHIPPING_CHRONOPOST_INVALID_ZONE;
         return $this->quotes;
     }
     $table = preg_split("/[:,]/", constant('MODULE_SHIPPING_CHRONOPOST_COST_' . $dest_zone));
     $cost = -1;
     for ($i = 0, $n = sizeof($table); $i < $n; $i += 2) {
         if ($shipping_weight <= $table[$i]) {
             $cost = $table[$i + 1] + MODULE_SHIPPING_CHRONOPOST_HANDLING + SHIPPING_HANDLING;
             break;
         }
     }
     if ($cost == -1) {
         $this->quotes['error'] = MODULE_SHIPPING_CHRONOPOST_UNDEFINED_RATE;
         return $this->quotes;
     }
     $this->quotes['methods'][] = array('id' => $this->code, 'title' => MODULE_SHIPPING_CHRONOPOST_TEXT_WAY . ' ' . $order->delivery['country']['title'], 'cost' => $cost + MODULE_SHIPPING_CHRONOPOST_HANDLING + SHIPPING_HANDLING);
     return $this->quotes;
 }
コード例 #9
0
ファイル: spsr.php プロジェクト: nomadcomanche/zdorov_shop
 function quote($method = '')
 {
     global $order, $cart, $shipping_weight, $own_zone_id;
     if ($shipping_weight == 0) {
         $shipping_weight = MODULE_SHIPPING_SPSR_DEFAULT_SHIPPING_WEIGHT;
     }
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     //вытаскиваем Region ID города назначения базы
     $region_id = vam_get_spsr_zone_id($order->delivery['zone_id']);
     //вытаскиваем свой Region ID из базы
     $own_cpcr_id = vam_get_spsr_zone_id($own_zone_id);
     //oscommerce дважды запрашивает цену доставки c cpcr.ru - до подтверждения цены доставки (для показа пользователю) и после подтверждения цены доставки (нажатие кнопки "Продолжить"). Х.з. почему, видимо так работает oscommerce. Чтобы не запрашивать дважды кешируем $cost в hidden поле cost.
     if (!isset($_POST['cost'])) {
         //составление запроса стоимости доставки
         if (isset($_POST['error_tocity'])) {
             $request = 'http://cpcr.ru/cgi-bin/postxml.pl?TariffCompute&FromRegion=' . $own_cpcr_id . '|0&FromCityName=' . iconv("UTF-8", "windows-1251", MODULE_SHIPPING_SPSR_FROM_CITY) . '&Weight=' . $shipping_weight . '&Nature=' . MODULE_SHIPPING_SPSR_NATURE . '&Amount=0&Country=209|0&ToCity=' . iconv("UTF-8", "windows-1251", $_POST['error_tocity']);
         } else {
             $request = 'http://cpcr.ru/cgi-bin/postxml.pl?TariffCompute&FromRegion=' . $own_cpcr_id . '|0&FromCityName=' . iconv("UTF-8", "windows-1251", MODULE_SHIPPING_SPSR_FROM_CITY) . '&Weight=' . $shipping_weight . '&Nature=' . MODULE_SHIPPING_SPSR_NATURE . '&Amount=0&Country=209|0&ToRegion=' . $region_id . '|0&ToCityName=' . iconv("UTF-8", "windows-1251", $order->delivery['city']);
         }
         //проверки связи с сервером
         $server_link = false;
         $file_headers = @get_headers($request);
         if ($file_headers[0] !== 'HTTP/1.1 404 Not Found' && $file_headers !== false) {
             $server_link = true;
         }
         //Запрос стоимости с cpcr.ru
         if ($server_link == true) {
             $xmlstring = simplexml_load_file($request);
         } else {
             $title = "<font color=red>Нет связи с сервером cpcr.ru, стоимость доставки не определена.</font>";
             $cost = 0;
         }
         //получение цены доставки
         if ($xmlstring->PayTariff) {
             $find_symbols = array(chr(160), 'р.', ' ');
             //вместо пробела в стоимости доставки cpcr.ru использует симовл с ascii кодом 160.
             $cost = ceil(str_replace(',', '.', str_replace($find_symbols, '', $xmlstring->Total)));
             $title .= 'Доставка в ' . $order->delivery['city'] . ', ' . $order->delivery['state'];
             if ($cost > 0) {
                 $title .= '<input type="hidden" name="cost" value="' . $cost . '">';
             }
         }
         //если $cost уже был определен
     } else {
         $cost = $_POST['cost'];
         $title .= 'Доставка в ' . $order->delivery['city'] . ', ' . $order->delivery['state'];
         if ($cost > 0) {
             $title .= '<input type="hidden" name="cost" value="' . $cost . '">';
         }
     }
     //Обработка ошибки Город не найден
     if ($xmlstring->Error->ToCity && $server_link == true) {
         $title .= "<font color=red>Ошибка, город \"" . $order->delivery['city'] . "\" не найден. Либо в названии города допущена ошибка, либо в данный город СПСР доставку не производит.</font><br>";
     }
     //Уточнение названия города, для получения City_Id c сервера cpcr.ru
     if (!$xmlstring->Error->ToCity->City->CityName == '') {
         $title .= "<font color=red>Пожалуйста уточните название вашего города:</font><br>";
         if ($xmlstring->Error->ToCity->City) {
             foreach ($xmlstring->Error->ToCity->City as $city_value) {
                 $title .= "<input type=radio name=error_tocity value=\"" . $city_value->City_Id . "|" . $city_value->City_Owner_Id . "\" onChange=\"this.form.submit()\">" . $city_value->CityName . ", " . $city_value->RegionName . "<br>";
                 //начало код для унификации с калькулятором
                 echo "<input type=hidden name=\"" . $city_value->City_Id . "|" . $city_value->City_Owner_Id . "\" value=\"" . $city_value->CityName . ", " . $city_value->RegionName . "\">";
                 //конец код для унификации с калькулятором
             }
         }
     }
     //Обработка ошибки Веса
     if ($xmlstring->Error->Weight) {
         $title .= "<br><font color=red>Ошибка! Неправильный формат веса</font>";
     }
     //Оюработка ошибки Оценочной стоимости
     if ($xmlstring->Error->Amount) {
         $title .= "<br><font color=red>Ошибка! Неправильный формат оценочной стоимости</font>";
     }
     if (!isset($own_cpcr_id)) {
         $title .= "<br><font color=red>Ошибка! Вы не выбрали зону! (Администрирование>Настройки>My store>Zone)</font>";
     }
     //Обработка ошибки Mutex Wait Timeout
     if ($xmlstring->Error['Type'] == 'Mutex' & $xmlstring->Error['SubType'] == 'Wait Timeout') {
         $title .= "<br><font color=red>Ошибка! cpcr.ru не вернул ответ на запрос. Попробуйте обновить страницу.</font>";
     }
     //Обработка ошибки ComputeTariff CalcError
     if ($xmlstring->Error['Type'] == 'ComputeTariff' & $xmlstring->Error['SubType'] == 'CalcError') {
         $title .= "<br><font color=red>Ошибка! Ошибка вычисления стоимости доставки.</font>";
     }
     //Обработка ошибки Command Unknown
     if ($xmlstring->Error['Type'] == 'Command' & $xmlstring->Error['SubType'] == 'Unknown') {
         $title .= "<br><font color=red>Ошибка! Неизвестная команда.</font>";
     }
     //Обработка ошибки Unknown Unknown (прочие ошибки)
     if ($xmlstring->Error['Type']) {
         $title .= "<br><font color=red>Неизвестная ошибка, попробуйте позже.</font>";
     }
     //Отображдение отладочной информации
     if (MODULE_SHIPPING_SPSR_DEBUG == 'True') {
         $title .= "<br>" . '$own_zone_id=' . $own_zone_id . "<br>" . '$order->delivery[\'zone_id\']=' . $order->delivery['zone_id'] . "<br>" . '$own_cpcr_id=' . $own_cpcr_id . "<br>" . 'MODULE_SHIPPING_SPSR_OWN_CITY_DELIVERY=' . MODULE_SHIPPING_SPSR_OWN_CITY_DELIVERY . "<br>" . 'MODULE_SHIPPING_SPSR_OWN_REGION_DELIVERY=' . MODULE_SHIPPING_SPSR_OWN_REGION_DELIVERY . "<br>" . '$shipping_weight=' . $shipping_weight . "<br>" . 'MODULE_SHIPPING_SPSR_NATURE=' . MODULE_SHIPPING_SPSR_NATURE . "<br>" . '$request=' . $request . "<br>" . '$cost=' . $cost . "<br>" . '$_POST[\'cost\']=' . $_POST['cost'];
         '$xmlstring:' . "<br>" . (is_object($xmlstring) ? "<textarea readonly=\"readonly\" rows=\"5\">" . $xmlstring->asXML() . "</textarea>" : '');
     }
     if ($method != '') {
         $title = strip_tags($title);
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_SPSR_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => $title, 'cost' => $cost)));
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
コード例 #10
0
ファイル: dhl.php プロジェクト: nomadcomanche/zdorov_shop
 /**
  * class methods
  */
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     $dest_country = $order->delivery['country']['iso_code_2'];
     $dest_zone = 0;
     $error = false;
     for ($j = 1; $j <= $this->num_dhl; $j++) {
         $countries_table = constant('MODULE_SHIPPING_DHL_COUNTRIES_' . $j);
         $country_zones = preg_split("/[,]/", $countries_table);
         if (in_array($dest_country, $country_zones)) {
             $dest_zone = $j;
             break;
         }
     }
     if ($dest_zone == 0) {
         $error = true;
     } else {
         $shipping = -1;
         $dhl_cost_ecx = @constant('MODULE_SHIPPING_DHL_COST_ECX_' . $j);
         $dhl_cost_dox = @constant('MODULE_SHIPPING_DHL_COST_DOX_' . $j);
         $dhl_cost_wpx = @constant('MODULE_SHIPPING_DHL_COST_WPX_' . $j);
         $dhl_cost_mdx = @constant('MODULE_SHIPPING_DHL_COST_MDX_' . $j);
         $dhl_cost_sdx = @constant('MODULE_SHIPPING_DHL_COST_SDX_' . $j);
         $methods = array();
         $n = 0;
         if ($dhl_cost_ecx != '') {
             $dhl_table_ecx = preg_split("/[:,]/", $dhl_cost_ecx);
             if ($shipping_weight > 10 and $shipping_weight <= 20) {
                 $shipping_ecx = number_format(($shipping_weight - 10) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_ECX_20_' . $j) + $dhl_table_ecx[count($dhl_table_ecx) - 1];
             } elseif ($shipping_weight > 20 and $shipping_weight <= 30) {
                 $shipping_ecx = number_format(($shipping_weight - 20) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_ECX_30_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_ECX_20_' . $j) + $dhl_table_ecx[count($dhl_table_ecx) - 1];
             } elseif ($shipping_weight > 30 and $shipping_weight <= 50) {
                 $shipping_ecx = number_format(($shipping_weight - 30) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_ECX_50_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_ECX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_ECX_30_' . $j) + $dhl_table_ecx[count($dhl_table_ecx) - 1];
             } elseif ($shipping_weight > 50) {
                 $shipping_ecx = number_format(($shipping_weight - 50) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_ECX_51_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_ECX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_ECX_30_' . $j) + 40 * constant('MODULE_SHIPPING_DHL_STEP_ECX_50_' . $j) + $dhl_table_ecx[count($dhl_table_ecx) - 1];
             } else {
                 for ($i = 0; $i < sizeof($dhl_table_ecx); $i += 2) {
                     if ($shipping_weight <= $dhl_table_ecx[$i]) {
                         $shipping_ecx = $dhl_table_ecx[$i + 1];
                         break;
                     }
                 }
             }
             if ($shipping_ecx == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_DHL_UNDEFINED_RATE;
             } else {
                 $shipping_cost_1 = $shipping_ecx + MODULE_SHIPPING_DHL_HANDLING;
             }
             $methods[] = array('id' => 'ECX', 'title' => 'EU Express Service', 'cost' => (MODULE_SHIPPING_DHL_HANDLING + $shipping_cost_1) * $shipping_num_boxes);
             $n++;
         }
         if ($dhl_cost_dox != '') {
             $dhl_table_dox = preg_split("/[:,]/", $dhl_cost_dox);
             if ($shipping_weight > 10 and $shipping_weight <= 20) {
                 $shipping_dox = number_format(($shipping_weight - 10) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_DOX_20_' . $j) + $dhl_table_dox[count($dhl_table_dox) - 1];
             } elseif ($shipping_weight > 20 and $shipping_weight <= 30) {
                 $shipping_dox = number_format(($shipping_weight - 20) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_DOX_30_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_DOX_20_' . $j) + $dhl_table_dox[count($dhl_table_dox) - 1];
             } elseif ($shipping_weight > 30 and $shipping_weight <= 50) {
                 $shipping_dox = number_format(($shipping_weight - 30) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_DOX_50_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_DOX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_DOX_30_' . $j) + $dhl_table_dox[count($dhl_table_dox) - 1];
             } elseif ($shipping_weight > 50) {
                 $shipping_dox = number_format(($shipping_weight - 50) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_DOX_51_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_DOX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_DOX_30_' . $j) + 40 * constant('MODULE_SHIPPING_DHL_STEP_DOX_50_' . $j) + $dhl_table_dox[count($dhl_table_dox) - 1];
             } else {
                 for ($i = 0; $i < sizeof($dhl_table_dox); $i += 2) {
                     if ($shipping_weight <= $dhl_table_dox[$i]) {
                         $shipping_dox = $dhl_table_dox[$i + 1];
                         break;
                     }
                 }
             }
             if ($shipping_dox == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_DHL_UNDEFINED_RATE;
             } else {
                 $shipping_cost_2 = $shipping_dox + MODULE_SHIPPING_DHL_HANDLING;
             }
             $methods[] = array('id' => 'DOX', 'title' => 'Document Express Service', 'cost' => (MODULE_SHIPPING_DHL_HANDLING + $shipping_cost_2) * $shipping_num_boxes);
             $n++;
         }
         if ($dhl_cost_wpx != '') {
             $dhl_table_wpx = preg_split("/[:,]/", $dhl_cost_wpx);
             if ($shipping_weight > 10 and $shipping_weight <= 20) {
                 $shipping_wpx = number_format(($shipping_weight - 10) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_WPX_20_' . $j) + $dhl_table_wpx[count($dhl_table_wpx) - 1];
             } elseif ($shipping_weight > 20 and $shipping_weight <= 30) {
                 $shipping_wpx = number_format(($shipping_weight - 20) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_WPX_30_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_WPX_20_' . $j) + $dhl_table_wpx[count($dhl_table_wpx) - 1];
             } elseif ($shipping_weight > 30 and $shipping_weight <= 50) {
                 $shipping_wpx = number_format(($shipping_weight - 30) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_WPX_50_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_WPX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_WPX_30_' . $j) + $dhl_table_wpx[count($dhl_table_wpx) - 1];
             } elseif ($shipping_weight > 50) {
                 $shipping_wpx = number_format(($shipping_weight - 50) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_WPX_51_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_WPX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_WPX_30_' . $j) + 40 * constant('MODULE_SHIPPING_DHL_STEP_WPX_50_' . $j) + $dhl_table_wpx[count($dhl_table_wpx) - 1];
             } else {
                 for ($i = 0; $i < sizeof($dhl_table_wpx); $i += 2) {
                     if ($shipping_weight <= $dhl_table_wpx[$i]) {
                         $shipping_wpx = $dhl_table_wpx[$i + 1];
                         break;
                     }
                 }
             }
             if ($shipping_wpx == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_DHL_UNDEFINED_RATE;
             } else {
                 $shipping_cost_3 = $shipping_wpx + MODULE_SHIPPING_DHL_HANDLING;
             }
             $methods[] = array('id' => 'WPX', 'title' => 'Waren Express Service', 'cost' => (MODULE_SHIPPING_DHL_HANDLING + $shipping_cost_3) * $shipping_num_boxes);
             $n++;
         }
         if ($dhl_cost_mdx != '') {
             $dhl_table_mdx = preg_split("/[:,]/", $dhl_cost_mdx);
             if ($shipping_weight > 10 and $shipping_weight <= 20) {
                 $shipping_mdx = number_format(($shipping_weight - 10) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_MDX_20_' . $j) + $dhl_table_mdx[count($dhl_table_mdx) - 1];
             } elseif ($shipping_weight > 20 and $shipping_weight <= 30) {
                 $shipping_mdx = number_format(($shipping_weight - 20) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_MDX_30_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_MDX_20_' . $j) + $dhl_table_mdx[count($dhl_table_mdx) - 1];
             } elseif ($shipping_weight > 30 and $shipping_weight <= 50) {
                 $shipping_mdx = number_format(($shipping_weight - 30) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_MDX_50_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_MDX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_MDX_30_' . $j) + $dhl_table_mdx[count($dhl_table_mdx) - 1];
             } elseif ($shipping_weight > 50) {
                 $shipping_mdx = number_format(($shipping_weight - 50) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_MDX_51_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_MDX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_MDX_30_' . $j) + 40 * constant('MODULE_SHIPPING_DHL_STEP_MDX_50_' . $j) + $dhl_table_mdx[count($dhl_table_mdx) - 1];
             } else {
                 for ($i = 0; $i < sizeof($dhl_table_mdx); $i += 2) {
                     if ($shipping_weight <= $dhl_table_mdx[$i]) {
                         $shipping_mdx = $dhl_table_mdx[$i + 1];
                         break;
                     }
                 }
             }
             if ($shipping_mdx == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_DHL_UNDEFINED_RATE;
             } else {
                 $shipping_cost_4 = $shipping_mdx + MODULE_SHIPPING_DHL_HANDLING;
             }
             $methods[] = array('id' => 'MDX', 'title' => 'Mid Day Express Service', 'cost' => (MODULE_SHIPPING_DHL_HANDLING + $shipping_cost_4) * $shipping_num_boxes);
             $n++;
         }
         if ($dhl_cost_sdx != '') {
             $dhl_table_sdx = preg_split("/[:,]/", $dhl_cost_sdx);
             if ($shipping_weight > 10 and $shipping_weight <= 20) {
                 $shipping_sdx = number_format(($shipping_weight - 10) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_SDX_20_' . $j) + $dhl_table_sdx[count($dhl_table_sdx) - 1];
             } elseif ($shipping_weight > 20 and $shipping_weight <= 30) {
                 $shipping_sdx = number_format(($shipping_weight - 20) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_SDX_30_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_SDX_20_' . $j) + $dhl_table_sdx[count($dhl_table_sdx) - 1];
             } elseif ($shipping_weight > 30 and $shipping_weight <= 50) {
                 $shipping_sdx = number_format(($shipping_weight - 30) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_SDX_50_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_SDX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_SDX_30_' . $j) + $dhl_table_sdx[count($dhl_table_sdx) - 1];
             } elseif ($shipping_weight > 50) {
                 $shipping_sdx = number_format(($shipping_weight - 50) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_DHL_STEP_SDX_51_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_SDX_20_' . $j) + 20 * constant('MODULE_SHIPPING_DHL_STEP_SDX_30_' . $j) + 40 * constant('MODULE_SHIPPING_DHL_STEP_SDX_50_' . $j) + $dhl_table_sdx[count($dhl_table_sdx) - 1];
             } else {
                 for ($i = 0; $i < sizeof($dhl_table_sdx); $i += 2) {
                     if ($shipping_weight <= $dhl_table_sdx[$i]) {
                         $shipping_sdx = $dhl_table_sdx[$i + 1];
                         break;
                     }
                 }
             }
             if ($shipping_sdx == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_DHL_UNDEFINED_RATE;
             } else {
                 $shipping_cost_5 = $shipping_sdx + MODULE_SHIPPING_DHL_HANDLING;
             }
             $methods[] = array('id' => 'SDX', 'title' => 'Start Day Express Service', 'cost' => (MODULE_SHIPPING_DHL_HANDLING + $shipping_cost_5) * $shipping_num_boxes);
             $n++;
         }
     }
     $this->quotes = array('id' => $this->code, 'module' => $this->title . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . MODULE_SHIPPING_DHL_TEXT_UNITS . ')');
     $this->quotes['methods'] = $methods;
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = MODULE_SHIPPING_DHL_INVALID_ZONE;
     }
     if (vam_not_null($method) && isset($this->types[$method])) {
         for ($i = 0; $i < sizeof($methods); $i++) {
             if ($method == $methods[$i]['id']) {
                 $methodsc = array();
                 $methodsc[] = array('id' => $methods[$i]['id'], 'title' => $methods[$i]['title'], 'cost' => $methods[$i]['cost']);
                 break;
             }
         }
         $this->quotes['methods'] = $methodsc;
     }
     return $this->quotes;
 }
コード例 #11
0
 function process()
 {
     global $order, $vamPrice, $ps_cost, $ps_country, $shipping;
     $customer_id = $_SESSION['customer_id'];
     if (MODULE_ORDER_TOTAL_PS_FEE_STATUS == 'true') {
         //Will become true, if ps can be processed.
         $ps_country = false;
         //check if payment method is ps. If yes, check if ps is possible.
         $count_query = vam_db_query("select count(*) as count from " . TABLE_CUSTOMERS_BASKET . " cb, " . TABLE_PRODUCTS . " p  where cb.customers_id = '" . $customer_id . "' and cb.products_id = p.products_id and p.products_fsk18 = '1'");
         $num = vam_db_fetch_array($count_query);
         $age = $num['count'];
         if ($age > '0') {
             //process installed shipping modules
             if ($_SESSION['shipping']['id'] == 'flat_flat') {
                 $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_FLAT);
             }
             if ($_SESSION['shipping']['id'] == 'item_item') {
                 $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_ITEM);
             }
             if ($_SESSION['shipping']['id'] == 'table_table') {
                 $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_TABLE);
             }
             if ($_SESSION['shipping']['id'] == 'zones_zones') {
                 $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_ZONES);
             }
             if ($_SESSION['shipping']['id'] == 'ap_ap') {
                 $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_AP);
             }
             if ($_SESSION['shipping']['id'] == 'dp_dp') {
                 $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_DP);
             }
             for ($i = 0; $i < count($ps_zones); $i++) {
                 if ($ps_zones[$i] == $order->billing['country']['iso_code_2']) {
                     $ps_cost = $ps_zones[$i + 1];
                     $ps_country = true;
                     //print('match' . $ps_zones[$i] . ': ' . $ps_cost);
                     break;
                 } elseif ($ps_zones[$i] == '00') {
                     $ps_cost = $ps_zones[$i + 1];
                     $ps_country = true;
                     //print('match' . $i . ': ' . $ps_cost);
                     break;
                 } else {
                     //print('no match');
                 }
                 $i++;
             }
         } else {
             //PS selected, but no shipping module which offers PS
         }
         if ($ps_country) {
             $ps_tax = vam_get_tax_rate(MODULE_ORDER_TOTAL_PS_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $ps_tax_description = vam_get_tax_description(MODULE_ORDER_TOTAL_PS_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
                 $order->info['tax'] += vam_add_tax($ps_cost, $ps_tax) - $ps_cost;
                 $order->info['tax_groups'][TAX_ADD_TAX . "{$ps_tax_description}"] += vam_add_tax($ps_cost, $ps_tax) - $ps_cost;
                 $order->info['total'] += $ps_cost + (vam_add_tax($ps_cost, $ps_tax) - $ps_cost);
                 $ps_cost_value = vam_add_tax($ps_cost, $ps_tax);
                 $ps_cost = $vamPrice->Format($ps_cost_value, true);
             }
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
                 $order->info['tax'] += vam_add_tax($ps_cost, $ps_tax) - $ps_cost;
                 $order->info['tax_groups'][TAX_NO_TAX . "{$ps_tax_description}"] += vam_add_tax($ps_cost, $ps_tax) - $ps_cost;
                 $ps_cost_value = $ps_cost;
                 $ps_cost = $vamPrice->Format($ps_cost, true);
                 $order->info['subtotal'] += $ps_cost_value;
                 $order->info['total'] += $ps_cost_value;
             }
             if (!$ps_cost_value) {
                 $ps_cost_value = $ps_cost;
                 $ps_cost = $vamPrice->Format($ps_cost, true);
                 $order->info['total'] += $ps_cost_value;
             }
             $this->output[] = array('title' => $this->title . ':', 'text' => $ps_cost, 'value' => $ps_cost_value);
         } else {
             //Following pse should be improved if we can't get the shipping modules disabled, who don't allow PS
             // as well as countries who do not have ps
             //          $this->output[] = array('title' => $this->title . ':',
             //                                  'text' => 'No PS for this module.',
             //                                  'value' => '');
         }
     }
 }
コード例 #12
0
    echo TABLE_HEADING_ACTION;
    ?>
&nbsp;</td>
              </tr>
<?php 
    $specials_query_raw = "select p.products_id, pd.products_name,p.products_tax_class_id, p.products_price, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . $_SESSION['languages_id'] . "' and p.products_id = s.products_id order by pd.products_name";
    $specials_split = new splitPageResults($_GET['page'], MAX_DISPLAY_ADMIN_PAGE, $specials_query_raw, $specials_query_numrows);
    $specials_query = vam_db_query($specials_query_raw);
    while ($specials = vam_db_fetch_array($specials_query)) {
        $price = $specials['products_price'];
        $new_price = $specials['specials_new_products_price'];
        if (PRICE_IS_BRUTTO == 'true') {
            $price_netto = vam_round($price, PRICE_PRECISION);
            $new_price_netto = vam_round($new_price, PRICE_PRECISION);
            $price = $price * (vam_get_tax_rate($specials['products_tax_class_id']) + 100) / 100;
            $new_price = $new_price * (vam_get_tax_rate($specials['products_tax_class_id']) + 100) / 100;
        }
        $specials['products_price'] = vam_round($price, PRICE_PRECISION);
        $specials['specials_new_products_price'] = vam_round($new_price, PRICE_PRECISION);
        if ((!$_GET['sID'] || $_GET['sID'] == $specials['specials_id']) && !$sInfo) {
            $products_query = vam_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . $specials['products_id'] . "'");
            $products = vam_db_fetch_array($products_query);
            $sInfo_array = vam_array_merge($specials, $products);
            $sInfo = new objectInfo($sInfo_array);
            $sInfo->specials_new_products_price = $specials['specials_new_products_price'];
            $sInfo->products_price = $specials['products_price'];
        }
        if (is_object($sInfo) && $specials['specials_id'] == $sInfo->specials_id) {
            echo '                  <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . vam_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '\'">' . "\n";
        } else {
            echo '                  <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . vam_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $specials['specials_id']) . '\'">' . "\n";
コード例 #13
0
 function quote($method = '')
 {
     global $order, $cart, $shipping_weight, $own_city_id;
     $calc = new CalculatePriceDeliveryCdek();
     try {
         if ($this->tax_class > 0) {
             $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
         }
         //устанавливаем город-отправитель
         $check_query = vam_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key='MODULE_SHIPPING_SDEK_FROM_CITY'");
         $check = vam_db_fetch_array($check_query);
         $own_city_name = $check['configuration_value'];
         //echo 'Grad:'.$own_city_name.'<br>';
         $city_check_query = vam_db_query("select city_id from city where city_name='" . $own_city_name . "'");
         $city_check = vam_db_fetch_array($city_check_query);
         $own_city_id = $city_check['city_id'];
         $calc->setSenderCityId($own_city_id);
         //echo 'Grad:'.$own_city_id.'<br>';
         //устанавливаем город-получатель
         $city_shipping_to_name = $order->delivery['city'];
         $city_check_query = vam_db_query("select city_id from city where city_name='" . $city_shipping_to_name . "'");
         $city_check = vam_db_fetch_array($city_check_query);
         $city_shipping_id = $city_check['city_id'];
         $calc->setReceiverCityId($city_shipping_id);
         //echo 'Grad primaoca:'.$city_shipping_id.'<br>';
         //устанавливаем дату планируемой отправки
         $shipping_date = date("Y-m-d");
         $calc->setDateExecute($shipping_date);
         //echo 'Datum:'.$shipping_date.'<br>';
         //устанавливаем тариф по-умолчанию
         $calc->setTariffId('1');
         //устанавливаем режим доставки
         $calc->setModeDeliveryId('1');
         //добавляем места в отправление
         if ($shipping_weight == 0) {
             $shipping_weight = MODULE_SHIPPING_SDEK_DEFAULT_SHIPPING_WEIGHT;
             //echo 'Tezina:'.$shipping_weight.'<br>';
         }
         $calc->addGoodsItemBySize($shipping_weight, '40', '50', '60');
         //$calc->addGoodsItemByVolume('0.1', '0.1');
         if ($calc->calculate() === true) {
             $res = $calc->getResult();
         }
         /*
         		echo 'Цена доставки: ' . $res['result']['price'] . 'руб.<br />';
         		echo 'Срок доставки: ' . $res['result']['deliveryPeriodMin'] . '-' . 
         								 $res['result']['deliveryPeriodMax'] . ' дн.<br />';
         		echo 'Планируемая дата доставки: c ' . $res['result']['deliveryDateMin'] . ' по ' . $res['result']['deliveryDateMax'] . '.<br />';
         		echo 'id тарифа, по которому произведён расчёт: ' . $res['result']['tariffId'] . '.<br />';
                 if(array_key_exists('cashOnDelivery', $res['result'])) {
                     echo 'Ограничение оплаты наличными, от (руб): ' . $res['result']['cashOnDelivery'] . '.<br />';
                 }
         	} else {
         		$err = $calc->getError();
         		if( isset($err['error']) && !empty($err) ) {
         			var_dump($err);
         			foreach($err['error'] as $e) {
         				echo 'Код ошибки: ' . $e['code'] . '.<br />';
         				echo 'Текст ошибки: ' . $e['text'] . '.<br />';
         			}
         		}
         	}	*/
     } catch (Exception $e) {
         echo 'Ошибка: ' . $e->getMessage() . "<br />";
     }
     if ($method != '') {
         $title = strip_tags($title);
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_SDEK_TEXT_TITLE);
     $this->quotes['methods'] = array(array('id' => $this->code, 'title' => MODULE_SHIPPING_SDEK_TEXT_NOTE, 'cost' => $res['result']['price']));
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
コード例 #14
0
 function quote($method = '')
 {
     global $order, $shipping_weight, $vamPrice;
     $home = false;
     $dest_country = $order->delivery['country']['iso_code_2'];
     $dest_province = $order->delivery['state'];
     $dest_zone_id;
     $dest_zone = 0;
     $error = false;
     $err_msg;
     //Если страна Россия, то цену смотрим по региону
     //"домашняя" страна.
     if ($dest_country == "RU") {
         $dest_zone_id = $dest_province;
         $home = true;
     } else {
         $error = true;
         $err_msg = MODULE_SHIPPING_RUSSIANPOSTPREPAY_INVALID_ZONE_PF;
     }
     //смотрим нужный регион
     for ($i = 1; $i <= 5; $i++) {
         $zones_table = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_STATES_' . $i);
         $zones = preg_split("/[,]/", $zones_table);
         if (in_array($dest_zone_id, $zones)) {
             $dest_zone = $i;
             break;
         }
     }
     //узнаем посылка или бандероль
     //вес заказа меньше максимального для бандероли
     $need_wr = MODULE_SHIPPING_RUSSIANPOSTPREPAY_WRAPPER_MAXWEIGHT < $shipping_weight ? MODULE_SHIPPING_RUSSIANPOSTPREPAY_WRAPPERS_OR_PARCEL == 'True' ? 1 : 0 : 1;
     //$wrapper = 0 - посылка
     //$wrapper = 1 - бандероль
     #####			$wrapper = (MODULE_SHIPPING_RUSSIANPOSTPREPAY_WRAPPER_STATUS_PF == 'True' && $need_wr) ? $this->is_wrapper($order->products)  : 0;
     $wrapper = MODULE_SHIPPING_RUSSIANPOSTPREPAY_WRAPPER_STATUS_PF == 'True' && $need_wr ? $this->is_wrapper($_SESSION['cart']->get_products()) : 0;
     if ($wrapper == 0 && MODULE_SHIPPING_RUSSIANPOSTPREPAY_PARCEL_STATUS_PF != 'True') {
         return false;
     }
     $mode = $wrapper == 1 ? 'WRAPPER' : 'PARCEL';
     //смотрим запрещённые регионы
     $zones_table = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_LIMITATION_PF');
     $zones = preg_split("/[,]/", $zones_table);
     if (in_array($dest_zone_id, $zones)) {
         return false;
         /*
         					$error = true;
                   			$err_msg = MODULE_SHIPPING_RUSSIANPOSTPREPAY_UNDEFINED_RATE_PF;
         */
     }
     //высчитываем на сколько посылок/бандеролей нужно разбить заказ
     $need_parcel = 1;
     $maxweight = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_MAXWEIGHT');
     if ($shipping_weight > $maxweight) {
         $need_parcel = ceil($shipping_weight / $maxweight);
     }
     if ($dest_zone == 0) {
         $error = true;
         $err_msg = MODULE_SHIPPING_RUSSIANPOSTPREPAY_INVALID_ZONE_PF;
     } else {
         $zones_cost = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_STATES_PRICE_' . $mode . '_' . $dest_zone);
         $cost_table = preg_split("/[:,]/", $zones_cost);
         $shipping = $this->price($cost_table, $shipping_weight, $need_parcel, $maxweight, constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_REG'));
         $shipping_method = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_TEXT_WAY_' . $mode . '_PF') . ' <nobr>(' . $order->delivery['state'] . ' - ' . $shipping_weight . ' ' . MODULE_SHIPPING_RUSSIANPOSTPREPAY_TEXT_UNITS_PF . '</nobr> <nobr>[' . constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_NEED_PF') . $this->om_number($need_parcel, array(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_1_PF'), constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_2_PF'), constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_5_PF'))) . ']</nobr>)';
         if ($shipping == 0) {
             $shipping = -1;
         }
         if ($shipping == -1) {
             $error = true;
             $err_msg = MODULE_SHIPPING_RUSSIANPOSTPREPAY_UNDEFINED_RATE_PF;
         } else {
             /**** Формула подсчёта цены ****/
             /*-- "Риски" магазина --*/
             //РИСКИ МАГАЗИНА
             $burden = 0;
             $burden_data = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_COST');
             if (!empty($burden_data) || $burden_data > 0) {
                 $burden = strpos($burden_data, '%') === false ? $burden_data : substr($burden_data, 0, strpos($burden_data, '%'));
                 $burden_proc = strpos($burden_data, '%') === false ? false : true;
                 //узнаем откуда высчитывать страховку
                 $burden_method = 0;
                 if ($burden_proc) {
                     $bm = substr($burden_data, 0, 1);
                     if ($bm == 'p' || $bm == 'P' || $bm == 'р' || $bm == 'Р') {
                         $burden_method = 'products';
                     } else {
                         if ($bm == 'd' || $bm == 'D') {
                             $burden_method = 'delivery';
                         } else {
                             $burden_method = 'all';
                         }
                     }
                     ###                     		$burden = substr(substr($burden_data, 0, strpos($burden_data, '%')), ((intval($bm) > 0)?0:1), strlen($burden_data)-1);
                     $burden = substr(substr($burden_data, 0, strpos($burden_data, '%')), $bm == '' ? 0 : 1, strlen($burden_data) - 1);
                 }
             }
             if ($burden_method == 'delivery' && $burden_proc) {
                 $delivery = $shipping + $shipping / 100 * $burden;
             } elseif ($burden_method == 'products' && $burden_proc) {
                 $delivery = $shipping + $vamPrice->RemoveCurr($_SESSION['cart']->show_total()) / 100 * $burden;
             } elseif ($burden_method == 'all' && $burden_proc) {
                 $delivery = $shipping + ($shipping + $_SESSION['cart']->show_total()) / 100 * $burden;
             } else {
                 $delivery = $shipping;
             }
             //прибавим страховую сумму магазина (НЕ процент)
             if (!$burden_proc) {
                 $delivery += $burden;
             }
             //доставка + сумма заказа
             $appraisal_price = $delivery + $_SESSION['cart']->show_total();
             //высчитываем страховую стоимость
             $insurance_price = $this->insurance($appraisal_price, intval(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_INSURANCE')));
             //итоговая стоимость доставки = доставка + плата за сбор посылки + страховой процент
             $shipping_cost = $delivery + $insurance_price;
         }
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_RUSSIANPOSTPREPAY_TEXT_TITLE_PF, 'methods' => array(array('id' => $this->code, 'title' => $shipping_method, 'cost' => ceil($shipping_cost))));
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = $err_msg;
     }
     return $this->quotes;
 }
コード例 #15
0
 function quote($method = '')
 {
     global $order, $shipping_weight, $vamPrice;
     $home = false;
     $dest_country = $order->delivery['country']['iso_code_2'];
     $dest_province = $order->delivery['state'];
     $dest_zone_id;
     //Если страна Россия, то цену смотрим по региону
     //"домашняя" страна.
     if ($dest_country == "RU") {
         $dest_zone_id = $dest_province;
         $home = true;
     } else {
         $dest_zone_id = $dest_country;
     }
     $dest_zone = 0;
     $error = false;
     $err_msg;
     //смотрим нужный регион
     if ($home) {
         for ($i = 1; $i <= 5; $i++) {
             $zones_table = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_STATES_' . $i);
             $zones = preg_split("/[,]/", $zones_table);
             if (in_array($dest_zone_id, $zones)) {
                 $dest_zone = $i;
                 break;
             }
         }
     } else {
         $zones_table = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_COUNTRY_1');
         $zones = preg_split("/[,]/", $zones_table);
         if (in_array($dest_zone_id, $zones)) {
             $dest_zone = 21;
         } else {
             $zones_table = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_COUNTRY_2');
             $zones = preg_split("/[,]/", $zones_table);
             if (in_array($dest_zone_id, $zones) || in_array('*', $zones)) {
                 $dest_zone = 22;
             }
         }
     }
     //узнаем посылка или бандероль
     //вес заказа меньше максимального для бандероли
     $need_wr = MODULE_SHIPPING_RUSSIANPOSTPREPAY_WRAPPER_MAXWEIGHT < $shipping_weight ? MODULE_SHIPPING_RUSSIANPOSTPREPAY_WRAPPERS_OR_PARCEL == 'True' ? 1 : 0 : 1;
     //$wrapper = 0 - посылка
     //$wrapper = 1 - бандероль
     $wrapper = MODULE_SHIPPING_RUSSIANPOSTPREPAY_WRAPPER_STATUS == 'True' && $need_wr ? $this->is_wrapper($_SESSION['cart']->get_products()) : 0;
     if ($wrapper == 0 && MODULE_SHIPPING_RUSSIANPOSTPREPAY_PARCEL_STATUS != 'True') {
         return false;
     }
     $mode = $wrapper == 1 ? 'WRAPPER' : 'PARCEL';
     //высчитываем на сколько посылок/бандеролей нужно разбить заказ
     $need_parcel = 1;
     $maxweight = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . ($dest_zone < 20 ? $mode : 'INTER') . '_MAXWEIGHT');
     if ($shipping_weight > $maxweight) {
         $need_parcel = ceil($shipping_weight / $maxweight);
     }
     if ($dest_zone == 0) {
         $error = true;
         $err_msg = MODULE_SHIPPING_RUSSIANPOSTPREPAY_INVALID_ZONE;
     } else {
         //отправление по России
         if ($dest_zone < 20) {
             $shipping = -1;
             $zones_cost = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_STATES_PRICE_' . $mode . '_' . $dest_zone);
             $cost_table = preg_split("/[:,]/", $zones_cost);
             $shipping = $this->price($cost_table, $shipping_weight, $need_parcel, $maxweight, constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . ($dest_zone < 20 ? $mode : 'INTER') . '_REG'));
             $shipping_method = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_TEXT_WAY_' . $mode) . ' <nobr>(' . $order->delivery['state'] . ' - ' . $shipping_weight . ' ' . MODULE_SHIPPING_RUSSIANPOSTPREPAY_TEXT_UNITS . '</nobr> <nobr>[' . constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_NEED') . $this->om_number($need_parcel, array(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_1'), constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_2'), constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_5'))) . ']</nobr>)';
         } else {
             $shipping = -1;
             $zones_cost = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_COUNTRY_PRICE_' . ($dest_zone == '21' ? 1 : 2));
             $cost_table = preg_split("/[:,]/", $zones_cost);
             $shipping = $this->price($cost_table, $shipping_weight, $need_parcel, $maxweight, constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . ($dest_zone < 20 ? $mode : 'INTER') . '_REG'));
             $shipping_method = constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_TEXT_WAY_COUNTRY') . ' <nobr>(' . $order->delivery['country']['title'] . ' - ' . $shipping_weight . ' ' . MODULE_SHIPPING_RUSSIANPOSTPREPAY_TEXT_UNITS . '</nobr> <nobr>[' . constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_INTER_NEED') . $this->om_number($need_parcel, array(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_INTER_1'), constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_INTER_2'), constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_INTER_5'))) . ']</nobr>)';
         }
         if ($shipping == 0) {
             $shipping = -1;
         }
         if ($shipping == -1) {
             $error = true;
             $err_msg = MODULE_SHIPPING_RUSSIANPOSTPREPAY_UNDEFINED_RATE;
         } else {
             /**** Формула подсчёта цены ****/
             //внутренние отправления
             if ($dest_zone < 20) {
                 /*-- Оценочная стоимость в настройках --*/
                 $appraisal = 0;
                 if (constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_INSURANCE_PRICE') != 0) {
                     $appraisal = strpos(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_INSURANCE_PRICE'), '%') === false ? constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_INSURANCE_PRICE') : substr(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_INSURANCE_PRICE'), 0, strpos(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_INSURANCE_PRICE'), '%'));
                     $appraisal_proc = strpos(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_INSURANCE_PRICE'), '%') === false ? false : true;
                 }
                 $appraisal = intval($appraisal);
                 //оценочная стоимость
                 if ($appraisal > 0) {
                     //процент от суммы
                     if ($appraisal_proc) {
                         $appraisal_price = ($shipping + $_SESSION['cart']->show_total() / 100) * $appraisal;
                     } else {
                         $appraisal_price = $appraisal;
                     }
                 } else {
                     //доставка + сумма заказа
                     $appraisal_price = $shipping + $_SESSION['cart']->show_total();
                 }
                 //высчитываем страховую стоимость
                 $insurance_price = $this->insurance($appraisal_price, intval(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_INSURANCE')));
                 //итоговая стоимость доставки = доставка + плата за сбор посылки + страховой процент
                 $shipping_cost = $shipping + $insurance_price;
                 //БЕСПЛАТНАЯ ДОСТАВКА
                 if (intval(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_FREE')) > 0) {
                     if ($_SESSION['cart']->show_total() >= intval(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_' . $mode . '_FREE'))) {
                         $shipping_cost = 0;
                     }
                 }
             } else {
                 //итоговая стоимость доставки = доставка + плата за сбор посылки
                 $shipping_cost = $shipping;
                 //БЕСПЛАТНАЯ ДОСТАВКА
                 if (intval(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_INTER_FREE')) > 0) {
                     if ($_SESSION['cart']->show_total() >= intval(constant('MODULE_SHIPPING_RUSSIANPOSTPREPAY_INTER_FREE'))) {
                         $shipping_cost = 0;
                     }
                 }
             }
         }
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_RUSSIANPOSTPREPAY_TEXT_TITLE_PREPAY, 'methods' => array(array('id' => $this->code, 'title' => $shipping_method, 'cost' => ceil($shipping_cost))));
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = $err_msg;
     }
     return $this->quotes;
 }
コード例 #16
0
ファイル: zones.php プロジェクト: nomadcomanche/zdorov_shop
 /**
  * class methods
  */
 function quote($method = '')
 {
     global $order, $shipping_weight;
     $dest_country = $order->delivery['country']['iso_code_2'];
     $dest_zone = 0;
     $error = false;
     for ($i = 1; $i <= $this->num_zones; $i++) {
         $countries_table = constant('MODULE_SHIPPING_ZONES_COUNTRIES_' . $i);
         $country_zones = preg_split("/[,]/", $countries_table);
         if (in_array($dest_country, $country_zones)) {
             $dest_zone = $i;
             break;
         }
     }
     if ($dest_zone == 0) {
         $error = true;
     } else {
         $shipping = -1;
         $zones_cost = constant('MODULE_SHIPPING_ZONES_COST_' . $dest_zone);
         $zones_table = preg_split("/[:,]/", $zones_cost);
         $size = sizeof($zones_table);
         for ($i = 0; $i < $size; $i += 2) {
             if ($shipping_weight <= $zones_table[$i]) {
                 $shipping = $zones_table[$i + 1];
                 $shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY . ' ' . $dest_country . ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONES_TEXT_UNITS;
                 break;
             }
         }
         if ($shipping == -1) {
             $shipping_cost = 0;
             $shipping_method = MODULE_SHIPPING_ZONES_UNDEFINED_RATE;
         } else {
             $shipping_cost = $shipping + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone);
         }
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => $shipping_method, 'cost' => $shipping_cost)));
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE;
     }
     return $this->quotes;
 }
コード例 #17
0
 function calculate()
 {
     $this->total = 0;
     $this->weight = 0;
     if (!is_array($this->contents)) {
         return 0;
     }
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $qty = $this->contents[$products_id]['qty'];
         // products price
         $product_query = vam_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . vam_get_prid($products_id) . "'");
         if ($product = vam_db_fetch_array($product_query)) {
             $prid = $product['products_id'];
             $products_tax = vam_get_tax_rate($product['products_tax_class_id']);
             $products_price = $product['products_price'];
             $products_weight = $product['products_weight'];
             $specials_query = vam_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'");
             if (vam_db_num_rows($specials_query)) {
                 $specials = vam_db_fetch_array($specials_query);
                 $products_price = $specials['specials_new_products_price'];
             }
             $this->total += vam_add_tax($products_price, $products_tax) * $qty;
             $this->weight += $qty * $products_weight;
         }
         // attributes price
         if ($this->contents[$products_id]['attributes']) {
             reset($this->contents[$products_id]['attributes']);
             while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
                 $attribute_price_query = vam_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $prid . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'");
                 $attribute_price = vam_db_fetch_array($attribute_price_query);
                 if ($attribute_price['price_prefix'] == '+') {
                     $this->total += $qty * vam_add_tax($attribute_price['options_values_price'], $products_tax);
                 } else {
                     $this->total -= $qty * vam_add_tax($attribute_price['options_values_price'], $products_tax);
                 }
             }
         }
     }
 }
コード例 #18
0
     vam_db_query("UPDATE " . TABLE_ORDERS . " SET shipping_method = '" . $shipping['id'] . "' WHERE orders_id = '" . (int) $oID . "'");
 }
 $order = new manualOrder($oID);
 $vamPrice = new vamPrice($order->info['currency'], $order->info['status'], $order->customer['ID']);
 $order->adjust_zones();
 $cart = new manualCart();
 $cart->restore_contents($oID);
 $total_count = $cart->count_contents();
 $total_weight = $cart->show_weight();
 // Get the shipping quotes- if we don't have shipping quotes shipping tax calculation can't happen
 $shipping_modules = new shipping();
 $shipping_quotes = $shipping_modules->quote();
 if (DISPLAY_PRICE_WITH_TAX == 'true') {
     //extract the base shipping cost or the ot_shipping module will add tax to it again
     $module = substr($GLOBALS['shipping']['id'], 0, strpos($GLOBALS['shipping']['id'], '_'));
     $tax = vam_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     $order->info['total'] -= $order->info['shipping_cost'] - $order->info['shipping_cost'] / (1 + $tax / 100);
     $order->info['shipping_cost'] = $order->info['shipping_cost'] / (1 + $tax / 100);
 }
 //this is where we call the order total modules
 require 'order_editor/order_total.php';
 $order_total_modules = new order_total();
 $order_totals = $order_total_modules->process();
 $current_ot_totals_array = array();
 $current_ot_titles_array = array();
 $current_ot_totals_query = vam_db_query("select class, title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int) $oID . "' order by sort_order");
 while ($current_ot_totals = vam_db_fetch_array($current_ot_totals_query)) {
     $current_ot_totals_array[] = $current_ot_totals['class'];
     $current_ot_titles_array[] = strip_tags($current_ot_totals['title']);
 }
 vam_db_query("DELETE FROM " . TABLE_ORDERS_TOTAL . " WHERE orders_id = '" . (int) $oID . "'");
コード例 #19
0
 $result3 = vam_db_query($query3);
 while ($line = vam_db_fetch_array($result3)) {
     $current_value_name = $line['products_options_values_name'];
     // Print the Current Value Name
     echo "<TR class=\"" . $rowClass . "\">";
     echo "<TD class=\"main\">";
     echo "<input type=\"checkbox\" name=\"optionValues[]\" value=\"" . $current_value_id . "\"" . $CHECKED . ">&nbsp;&nbsp;" . $current_value_name . "&nbsp;&nbsp;";
     echo "</TD>";
     echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_sortorder\" value=\"" . $sortorder . "\" size=\"4\"></TD>";
     echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_model\" value=\"" . $attribute_value_model . "\" size=\"15\"></TD>";
     echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_stock\" value=\"" . $attribute_value_stock . "\" size=\"4\"></TD>";
     echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_weight\" value=\"" . $attribute_value_weight . "\" size=\"10\"></TD>";
     echo "<TD class=\"main\" align=\"left\"><SELECT name=\"" . $current_value_id . "_weight_prefix\"><OPTION value=\"+\"" . $posCheck_weight . ">+<OPTION value=\"-\"" . $negCheck_weight . ">-</SELECT></TD>";
     // brutto Admin
     if (PRICE_IS_BRUTTO == 'true') {
         $attribute_value_price_calculate = $vamPrice->Format(vam_round($attribute_value_price * ((100 + vam_get_tax_rate(vam_get_tax_class_id($_POST['current_product_id']))) / 100), PRICE_PRECISION), false);
     } else {
         $attribute_value_price_calculate = vam_round($attribute_value_price, PRICE_PRECISION);
     }
     echo "<TD class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_price\" value=\"" . $attribute_value_price_calculate . "\" size=\"10\">";
     // brutto Admin
     if (PRICE_IS_BRUTTO == 'true') {
         echo TEXT_NETTO . '<b>' . $vamPrice->Format(vam_round($attribute_value_price, PRICE_PRECISION), true) . '</b>  ';
     }
     echo "</TD>";
     echo "<TD class=\"main\" align=\"left\"><SELECT name=\"" . $current_value_id . "_prefix\"> <OPTION value=\"+\"" . $posCheck . ">+<OPTION value=\"-\"" . $negCheck . ">-</SELECT></TD>";
     echo "</TR>";
     // Download function start
     if (DOWNLOAD_ENABLED == 'true') {
         $file_list = vam_array_merge(array('0' => array('id' => '', 'text' => SELECT_FILE)), vam_getFiles(DIR_FS_CATALOG . 'download/'));
         echo "<tr>";
コード例 #20
0
ファイル: chp.php プロジェクト: nomadcomanche/zdorov_shop
 /**
  * class methods
  */
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     $dest_country = $order->delivery['country']['iso_code_2'];
     $dest_zone = 0;
     $error = false;
     for ($j = 1; $j <= $this->num_chp; $j++) {
         $countries_table = constant('MODULE_SHIPPING_CHP_COUNTRIES_' . $j);
         $country_zones = preg_split("/[,]/", $countries_table);
         if (in_array($dest_country, $country_zones)) {
             $dest_zone = $j;
             break;
         }
     }
     if ($dest_zone == 0) {
         $error = true;
     } else {
         $shipping = -1;
         $chp_cost_eco = @constant('MODULE_SHIPPING_CHP_COST_ECO_' . $j);
         $chp_cost_pri = @constant('MODULE_SHIPPING_CHP_COST_PRI_' . $j);
         $chp_cost_urg = @constant('MODULE_SHIPPING_CHP_COST_URG_' . $j);
         $methods = array();
         if ($chp_cost_eco != '') {
             $chp_table_eco = preg_split("/[:,]/", $chp_cost_eco);
             for ($i = 0; $i < sizeof($chp_table_eco); $i += 2) {
                 if ($shipping_weight <= $chp_table_eco[$i]) {
                     $shipping_eco = $chp_table_eco[$i + 1];
                     break;
                 }
             }
             if ($shipping_eco == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_CHP_UNDEFINED_RATE;
             } else {
                 $shipping_cost_1 = $shipping_eco + MODULE_SHIPPING_CHP_HANDLING;
             }
             if ($shipping_eco != 0) {
                 $methods[] = array('id' => 'ECO', 'title' => 'Economy', 'cost' => (MODULE_SHIPPING_CHP_HANDLING + $shipping_cost_1) * $shipping_num_boxes);
             }
         }
         if ($chp_cost_pri != '') {
             $chp_table_pri = preg_split("/[:,]/", $chp_cost_pri);
             for ($i = 0; $i < sizeof($chp_table_pri); $i += 2) {
                 if ($shipping_weight <= $chp_table_pri[$i]) {
                     $shipping_pri = $chp_table_pri[$i + 1];
                     break;
                 }
             }
             if ($shipping_pri == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_CHP_UNDEFINED_RATE;
             } else {
                 $shipping_cost_2 = $shipping_pri + MODULE_SHIPPING_CHP_HANDLING;
             }
             if ($shipping_pri != 0) {
                 $methods[] = array('id' => 'PRI', 'title' => 'Priority', 'cost' => (MODULE_SHIPPING_CHP_HANDLING + $shipping_cost_2) * $shipping_num_boxes);
             }
         }
         if ($chp_cost_urg != '') {
             $chp_table_urg = preg_split("/[:,]/", $chp_cost_urg);
             for ($i = 0; $i < sizeof($chp_table_urg); $i += 2) {
                 if ($shipping_weight <= $chp_table_urg[$i]) {
                     $shipping_urg = $chp_table_urg[$i + 1];
                     break;
                 }
             }
             if ($shipping_urg == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_CHP_UNDEFINED_RATE;
             } else {
                 $shipping_cost_3 = $shipping_urg + MODULE_SHIPPING_CHP_HANDLING;
             }
             if ($shipping_urg != 0) {
                 $methods[] = array('id' => 'URG', 'title' => 'Urgent', 'cost' => (MODULE_SHIPPING_CHP_HANDLING + $shipping_cost_3) * $shipping_num_boxes);
             }
         }
     }
     $this->quotes = array('id' => $this->code, 'module' => $this->title . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . MODULE_SHIPPING_CHP_TEXT_UNITS . ')');
     $this->quotes['methods'] = $methods;
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = MODULE_SHIPPING_CHP_INVALID_ZONE;
     }
     if (vam_not_null($method) && isset($this->types[$method])) {
         for ($i = 0; $i < sizeof($methods); $i++) {
             if ($method == $methods[$i]['id']) {
                 $methodsc = array();
                 $methodsc[] = array('id' => $methods[$i]['id'], 'title' => $methods[$i]['title'], 'cost' => $methods[$i]['cost']);
                 break;
             }
         }
         $this->quotes['methods'] = $methodsc;
     }
     return $this->quotes;
 }
コード例 #21
0
ファイル: fedexeu.php プロジェクト: nomadcomanche/zdorov_shop
 /**
  * class methods
  */
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     $dest_country = $order->delivery['country']['iso_code_2'];
     $dest_zone = 0;
     $error = false;
     for ($j = 1; $j <= $this->num_fedexeu; $j++) {
         $countries_table = constant('MODULE_SHIPPING_FEDEXEU_COUNTRIES_' . $j);
         $country_zones = preg_split("/[,]/", $countries_table);
         if (in_array($dest_country, $country_zones)) {
             $dest_zone = $j;
             break;
         }
     }
     if ($dest_zone == 0) {
         $error = true;
     } else {
         $shipping = -1;
         $fedexeu_cost_env = @constant('MODULE_SHIPPING_FEDEXEU_COST_ENV_' . $j);
         $fedexeu_cost_pak = @constant('MODULE_SHIPPING_FEDEXEU_COST_PAK_' . $j);
         $fedexeu_cost_box = @constant('MODULE_SHIPPING_FEDEXEU_COST_BOX_' . $j);
         $methods = array();
         if ($fedexeu_cost_pak != '') {
             $fedexeu_table_pak = preg_split("/[:,]/", $fedexeu_cost_pak);
             for ($i = 0; $i < sizeof($fedexeu_table_pak); $i += 2) {
                 if ($shipping_weight <= $fedexeu_table_pak[$i]) {
                     $shipping_pak = $fedexeu_table_pak[$i + 1];
                     break;
                 }
             }
             if ($shipping_pak == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_FEDEXEU_UNDEFINED_RATE;
             } else {
                 $shipping_cost_1 = $shipping_pak + MODULE_SHIPPING_FEDEXEU_HANDLING;
             }
             if ($shipping_pak != 0) {
                 $methods[] = array('id' => 'PAK', 'title' => 'FedEx Pak', 'cost' => (MODULE_SHIPPING_FEDEXEU_HANDLING + $shipping_cost_1) * $shipping_num_boxes);
             }
         }
         if ($fedexeu_cost_env != '') {
             $fedexeu_table_env = preg_split("/[:,]/", $fedexeu_cost_env);
             for ($i = 0; $i < sizeof($fedexeu_table_env); $i += 2) {
                 if ($shipping_weight <= $fedexeu_table_env[$i]) {
                     $shipping_env = $fedexeu_table_env[$i + 1];
                     break;
                 }
             }
             if ($shipping_env == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_FEDEXEU_UNDEFINED_RATE;
             } else {
                 $shipping_cost_1 = $shipping_env + MODULE_SHIPPING_FEDEXEU_HANDLING;
             }
             if ($shipping_env != 0) {
                 $methods[] = array('id' => 'ENV', 'title' => 'FedEx Envelope', 'cost' => (MODULE_SHIPPING_FEDEXEU_HANDLING + $shipping_cost_1) * $shipping_num_boxes);
             }
         }
         if ($fedexeu_cost_box != '') {
             $fedexeu_table_box = preg_split("/[:,]/", $fedexeu_cost_box);
             if ($shipping_weight > 10 and $shipping_weight <= 20) {
                 $shipping_box = number_format(($shipping_weight - 10) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_FEDEXEU_STEP_BOX_20_' . $j) + $fedexeu_table_box[count($fedexeu_table_box) - 1];
             } elseif ($shipping_weight > 20 and $shipping_weight <= 40) {
                 $shipping_box = number_format(($shipping_weight - 20) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_FEDEXEU_STEP_BOX_40_' . $j) + 20 * constant('MODULE_SHIPPING_FEDEXEU_STEP_BOX_20_' . $j) + $fedexeu_table_box[count($fedexeu_table_box) - 1];
             } elseif ($shipping_weight > 40 and $shipping_weight <= 70) {
                 $shipping_box = number_format(($shipping_weight - 40) * 2 + 0.5, 0) * constant('MODULE_SHIPPING_FEDEXEU_STEP_BOX_70_' . $j) + 20 * constant('MODULE_SHIPPING_FEDEXEU_STEP_BOX_20_' . $j) + 40 * constant('MODULE_SHIPPING_FEDEXEU_STEP_BOX_40_' . $j) + $fedexeu_table_box[count($fedexeu_table_box) - 1];
             } else {
                 for ($i = 0; $i < sizeof($fedexeu_table_box); $i += 2) {
                     if ($shipping_weight <= $fedexeu_table_box[$i]) {
                         $shipping_box = $fedexeu_table_box[$i + 1];
                         break;
                     }
                 }
             }
             if ($shipping_box == -1) {
                 $shipping_cost = 0;
                 $shipping_method = MODULE_SHIPPING_FEDEXEU_UNDEFINED_RATE;
             } else {
                 $shipping_cost_2 = $shipping_box + MODULE_SHIPPING_FEDEXEU_HANDLING;
             }
             if ($shipping_box != 0) {
                 $methods[] = array('id' => 'BOX', 'title' => 'FedEx Box', 'cost' => (MODULE_SHIPPING_FEDEXEU_HANDLING + $shipping_cost_2) * $shipping_num_boxes);
             }
         }
     }
     $this->quotes = array('id' => $this->code, 'module' => $this->title . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . MODULE_SHIPPING_FEDEXEU_TEXT_UNITS . ')');
     $this->quotes['methods'] = $methods;
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = MODULE_SHIPPING_FEDEXEU_INVALID_ZONE;
     }
     if (vam_not_null($method) && isset($this->types[$method])) {
         for ($i = 0; $i < sizeof($methods); $i++) {
             if ($method == $methods[$i]['id']) {
                 $methodsc = array();
                 $methodsc[] = array('id' => $methods[$i]['id'], 'title' => $methods[$i]['title'], 'cost' => $methods[$i]['cost']);
                 break;
             }
         }
         $this->quotes['methods'] = $methodsc;
     }
     return $this->quotes;
 }
コード例 #22
0
ファイル: ot_gv.php プロジェクト: nomadcomanche/zdorov_shop
 function calculate_tax_deduction($amount, $od_amount, $method)
 {
     global $order;
     switch ($method) {
         case 'Standard':
             $ratio1 = number_format($od_amount / $amount, 2);
             $tod_amount = 0;
             reset($order->info['tax_groups']);
             while (list($key, $value) = each($order->info['tax_groups'])) {
                 $tax_rate = vam_get_tax_rate_from_desc($key);
                 $total_net += $tax_rate * $order->info['tax_groups'][$key];
             }
             if ($od_amount > $total_net) {
                 $od_amount = $total_net;
             }
             reset($order->info['tax_groups']);
             while (list($key, $value) = each($order->info['tax_groups'])) {
                 $tax_rate = vam_get_tax_rate_from_desc($key);
                 $net = $tax_rate * $order->info['tax_groups'][$key];
                 if ($net > 0) {
                     $god_amount = $order->info['tax_groups'][$key] * $ratio1;
                     $tod_amount += $god_amount;
                     $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;
                 }
             }
             $order->info['tax'] -= $tod_amount;
             $order->info['total'] -= $tod_amount;
             break;
         case 'Credit Note':
             $tax_rate = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $tax_desc = vam_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $tod_amount = $this->deduction / (100 + $tax_rate) * $tax_rate;
             $order->info['tax_groups'][$tax_desc] -= $tod_amount;
             //          $order->info['total'] -= $tod_amount;   //// ????? Strider
             break;
         default:
     }
     return $tod_amount;
 }
コード例 #23
0
ファイル: ups.php プロジェクト: nomadcomanche/zdorov_shop
 /**
  * class methods
  */
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     $dest_country = $order->delivery['country']['iso_code_2'];
     $dest_zone = 0;
     $error = false;
     $freeship = false;
     $lowship = false;
     for ($i = 1; $i <= $this->num_ups; $i++) {
         $countries_table = constant('MODULE_SHIPPING_UPS_COUNTRIES_' . $i);
         $country_zones = preg_split("/[,]/", $countries_table);
         if (in_array($dest_country, $country_zones)) {
             $dest_zone = $i;
             break;
         }
     }
     if ($dest_zone == 0) {
         $error = true;
     } elseif ($dest_zone == 1 && round($_SESSION['cart']->show_total()) >= MODULE_SHIPPING_UPS_FREEAMOUNT) {
         $freeship = true;
         $shipping = 0;
         $shipping_method = MODULE_SHIPPING_UPS_TEXT_WAY . ' ' . $dest_country . ': ';
     } elseif ($dest_zone > 1 && round($_SESSION['cart']->show_total()) >= MODULE_SHIPPING_UPS_FREEAMOUNT) {
         $lowship = true;
         $shipping = -1;
         $ups_cost = constant('MODULE_SHIPPING_UPS_COST_' . $i);
         $ups_table = preg_split("/[:,]/", $ups_cost);
         for ($i = 0; $i < sizeof($ups_table); $i += 2) {
             if ($shipping_weight <= $ups_table[$i]) {
                 $shipping = $ups_table[$i + 1];
                 $shipping_method = MODULE_SHIPPING_UPS_TEXT_WAY . ' ' . $dest_country . ': ';
                 break;
             }
         }
         $i = 1;
         $ups_cost = constant('MODULE_SHIPPING_UPS_COST_' . $i);
         $ups_table = preg_split("/[:,]/", $ups_cost);
         for ($i = 0; $i < sizeof($ups_table); $i += 2) {
             if ($shipping_weight <= $ups_table[$i]) {
                 $diff = $ups_table[$i + 1];
                 break;
             }
         }
         $shipping = $shipping - $diff;
     } else {
         $shipping = -1;
         $ups_cost = constant('MODULE_SHIPPING_UPS_COST_' . $i);
         $ups_table = preg_split("/[:,]/", $ups_cost);
         for ($i = 0; $i < sizeof($ups_table); $i += 2) {
             if ($shipping_weight <= $ups_table[$i]) {
                 $shipping = $ups_table[$i + 1];
                 $shipping_method = MODULE_SHIPPING_UPS_TEXT_WAY . ' ' . $dest_country . ': ';
                 break;
             }
         }
     }
     if ($shipping == -1) {
         $shipping_cost = 0;
         $shipping_method = MODULE_SHIPPING_UPS_UNDEFINED_RATE;
     } else {
         $shipping_cost = $shipping + MODULE_SHIPPING_UPS_HANDLING;
     }
     if ($freeship == true) {
         $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_UPS_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => $shipping_method . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . MODULE_SHIPPING_UPS_TEXT_UNITS . ')<br>' . MODULE_SHIPPING_UPS_TEXT_FREE, 'cost' => $shipping_cost * $shipping_num_boxes)));
     } elseif ($lowship == true) {
         $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_UPS_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => $shipping_method . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . MODULE_SHIPPING_UPS_TEXT_UNITS . ')<br>' . MODULE_SHIPPING_UPS_TEXT_LOW, 'cost' => $shipping_cost * $shipping_num_boxes)));
     } else {
         $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_UPS_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => $shipping_method . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' ' . MODULE_SHIPPING_UPS_TEXT_UNITS . ')', 'cost' => $shipping_cost * $shipping_num_boxes)));
     }
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = MODULE_SHIPPING_UPS_INVALID_ZONE;
     }
     //	if ($lowship == true) $this->quotes['error'] = $ups_cost;
     return $this->quotes;
 }
コード例 #24
0
 function calculate_tax_deduction($amount, $od_amount, $method)
 {
     global $order;
     $coupon_query = vam_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $_SESSION['cc_id'] . "'");
     if (vam_db_num_rows($coupon_query) != 0) {
         $coupon_result = vam_db_fetch_array($coupon_query);
         $coupon_get = vam_db_query("select coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type from " . TABLE_COUPONS . " where coupon_code = '" . $coupon_result['coupon_code'] . "'");
         $get_result = vam_db_fetch_array($coupon_get);
         if ($get_result['coupon_type'] != 'S') {
             //RESTRICTION--------------------------------
             if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) {
                 // What to do here.
                 // Loop through all products and build a list of all product_ids, price, tax class
                 // at the same time create total net amount.
                 // then
                 // for percentage discounts. simply reduce tax group per product by discount percentage
                 // or
                 // for fixed payment amount
                 // calculate ratio based on total net
                 // for each product reduce tax group per product by ratio amount.
                 $products = $_SESSION['cart']->get_products();
                 $valid_product = false;
                 for ($i = 0; $i < sizeof($products); $i++) {
                     $valid_product = false;
                     $t_prid = vam_get_prid($products[$i]['id']);
                     $cc_query = vam_db_query("select products_tax_class_id from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
                     $cc_result = vam_db_fetch_array($cc_query);
                     if ($get_result['restrict_to_products']) {
                         $pr_ids = preg_split("/[,]/", $get_result['restrict_to_products']);
                         for ($p = 0; $p < sizeof($pr_ids); $p++) {
                             if ($pr_ids[$p] == $t_prid) {
                                 $valid_product = true;
                             }
                         }
                     }
                     if ($get_result['restrict_to_categories']) {
                         // v5.13a Tanaka 2005-4-30:  New code, this correctly identifies valid products in subcategories
                         $cat_ids = preg_split("/[,]/", $get_result['restrict_to_categories']);
                         $my_path = vam_get_product_path($t_prid);
                         $sub_cat_ids = preg_split("/[_]/", $my_path);
                         for ($iii = 0; $iii < count($sub_cat_ids); $iii++) {
                             for ($ii = 0; $ii < count($cat_ids); $ii++) {
                                 if ($sub_cat_ids[$iii] == $cat_ids[$ii]) {
                                     $valid_product = true;
                                     continue 2;
                                 }
                             }
                         }
                     }
                     if ($valid_product) {
                         $price_excl_vat = $products[$i]['final_price'] * $products[$i]['quantity'];
                         $price_incl_vat = $this->product_price($t_prid);
                         $valid_array[] = array('product_id' => $t_prid, 'products_price' => $price_excl_vat, 'products_tax_class' => $cc_result['products_tax_class_id']);
                         $total_price += $price_excl_vat;
                     }
                 }
                 if (sizeof($valid_array) > 0) {
                     // if ($valid_product) {
                     if ($get_result['coupon_type'] == 'P') {
                         $ratio = $get_result['coupon_amount'] / 100;
                     } else {
                         $ratio = $od_amount / $total_price;
                     }
                     if ($get_result['coupon_type'] == 'S') {
                         $ratio = 1;
                     }
                     if ($method == 'Credit Note') {
                         $tax_rate = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                         $tax_desc = vam_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                         if ($get_result['coupon_type'] == 'P') {
                             $tod_amount = $od_amount / (100 + $tax_rate) * $tax_rate;
                         } else {
                             $tod_amount = $order->info['tax_groups'][$tax_desc] * $od_amount / 100;
                         }
                         $order->info['tax_groups'][$tax_desc] -= $tod_amount;
                         $order->info['total'] -= $tod_amount;
                         $order->info['tax'] -= $tod_amount;
                     } else {
                         for ($p = 0; $p < sizeof($valid_array); $p++) {
                             $tax_rate = vam_get_tax_rate($valid_array[$p]['products_tax_class'], $order->delivery['country']['id'], $order->delivery['zone_id']);
                             $tax_desc = vam_get_tax_description($valid_array[$p]['products_tax_class'], $order->delivery['country']['id'], $order->delivery['zone_id']);
                             if ($tax_rate > 0) {
                                 $tod_amount = $valid_array[$p]['products_price'] * $tax_rate / 100 * $ratio;
                                 $order->info['tax_groups'][$tax_desc] -= $valid_array[$p]['products_price'] * $tax_rate / 100 * $ratio;
                                 $order->info['total'] -= $valid_array[$p]['products_price'] * $tax_rate / 100 * $ratio;
                                 $order->info['tax'] -= $valid_array[$p]['products_price'] * $tax_rate / 100 * $ratio;
                             }
                         }
                     }
                 }
                 //NO RESTRICTION--------------------------------
             } else {
                 if ($get_result['coupon_type'] == 'F') {
                     $tod_amount = 0;
                     if ($method == 'Credit Note') {
                         $tax_rate = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                         $tax_desc = vam_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                         $tod_amount = $od_amount / (100 + $tax_rate) * $tax_rate;
                         $order->info['tax_groups'][TAX_ADD_TAX . $tax_desc] -= $tod_amount;
                     } else {
                         reset($order->info['tax_groups']);
                         while (list($key, $value) = each($order->info['tax_groups'])) {
                             $ratio1 = $od_amount / ($amount - $order->info['tax_groups'][$key]);
                             $tax_rate = vam_get_tax_rate_from_desc(str_replace(TAX_ADD_TAX, "", $key));
                             $net = $tax_rate * $order->info['tax_groups'][$key];
                             if ($net > 0) {
                                 $god_amount = $od_amount * $tax_rate / (100 + $tax_rate);
                                 $tod_amount += $god_amount;
                                 $order->info['tax_groups'][$key] -= $god_amount;
                             }
                         }
                     }
                     $order->info['total'] -= $tod_amount;
                     $order->info['tax'] -= $tod_amount;
                 }
                 if ($get_result['coupon_type'] == 'P') {
                     $tod_amount = 0;
                     if ($method == 'Credit Note') {
                         $tax_desc = vam_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                         $tod_amount = $order->info['tax_groups'][$tax_desc] * $od_amount / 100;
                         $order->info['tax_groups'][TAX_ADD_TAX . $tax_desc] -= $tod_amount;
                     } else {
                         reset($order->info['tax_groups']);
                         while (list($key, $value) = each($order->info['tax_groups'])) {
                             $god_amout = 0;
                             $tax_rate = vam_get_tax_rate_from_desc(str_replace(TAX_ADD_TAX, "", $key));
                             $net = $tax_rate * $order->info['tax_groups'][$key];
                             if ($net > 0) {
                                 $god_amount = $order->info['tax_groups'][$key] * $get_result['coupon_amount'] / 100;
                                 $tod_amount += $god_amount;
                                 $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;
                             }
                         }
                     }
                     $order->info['tax'] -= $tod_amount;
                 }
             }
         }
     }
     return $tod_amount;
 }
コード例 #25
0
ファイル: general.php プロジェクト: nomadcomanche/zdorov_shop
function vam_draw_products_pull_down($name, $parameters = '', $exclude = '')
{
    global $currencies;
    if ($exclude == '') {
        $exclude = array();
    }
    $select_string = '<select name="' . $name . '"';
    if ($parameters) {
        $select_string .= ' ' . $parameters;
    }
    $select_string .= '>';
    $products_query = vam_db_query("select p.products_id, pd.products_name,p.products_tax_class_id, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . $_SESSION['languages_id'] . "' order by products_name");
    while ($products = vam_db_fetch_array($products_query)) {
        if (!vam_in_array($products['products_id'], $exclude)) {
            //brutto admin:
            if (PRICE_IS_BRUTTO == 'true') {
                $products['products_price'] = vam_round($products['products_price'] * ((100 + vam_get_tax_rate($products['products_tax_class_id'])) / 100), PRICE_PRECISION);
            }
            $select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . ' (' . vam_round($products['products_price'], PRICE_PRECISION) . ')</option>';
        }
    }
    $select_string .= '</select>';
    return $select_string;
}
コード例 #26
0
 function process()
 {
     global $order, $vamPrice, $cod_cost, $cod_country, $shipping;
     if (MODULE_ORDER_TOTAL_COD_FEE_STATUS == 'true') {
         //Will become true, if cod can be processed.
         $cod_country = false;
         //check if payment method is cod. If yes, check if cod is possible.
         if ($_SESSION['payment'] == 'cod') {
             //process installed shipping modules
             if ($_SESSION['shipping']['id'] == 'flat_flat') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FLAT);
             }
             if ($_SESSION['shipping']['id'] == 'item_item') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ITEM);
             }
             if ($_SESSION['shipping']['id'] == 'table_table') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_TABLE);
             }
             if ($_SESSION['shipping']['id'] == 'zones_zones') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ZONES);
             }
             if ($_SESSION['shipping']['id'] == 'ap_ap') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_AP);
             }
             if ($_SESSION['shipping']['id'] == 'dp_dp') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DP);
             }
             // module chp
             if ($_SESSION['shipping']['id'] == 'chp_ECO') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP);
             }
             if ($_SESSION['shipping']['id'] == 'chp_PRI') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP);
             }
             if ($_SESSION['shipping']['id'] == 'chp_URG') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP);
             }
             // module chronopost
             if ($_SESSION['shipping']['id'] == 'chronopost_chronopost') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHRONOPOST);
             }
             // module DHL
             if ($_SESSION['shipping']['id'] == 'dhl_ECX') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
             }
             if ($_SESSION['shipping']['id'] == 'dhl_DOX') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
             }
             if ($_SESSION['shipping']['id'] == 'dhl_SDX') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
             }
             if ($_SESSION['shipping']['id'] == 'dhl_MDX') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
             }
             if ($_SESSION['shipping']['id'] == 'dhl_WPX') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
             }
             // UPS
             if ($_SESSION['shipping']['id'] == 'ups_ups') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPS);
             }
             if ($_SESSION['shipping']['id'] == 'upse_upse') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPSE);
             }
             // Free Shipping
             if ($_SESSION['shipping']['id'] == 'free_free') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREE);
             }
             if ($_SESSION['shipping']['id'] == 'freeamount_freeamount') {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_FREEAMOUNT_FREE);
             }
             for ($i = 0; $i < count($cod_zones); $i++) {
                 if ($cod_zones[$i] == $order->delivery['country']['iso_code_2']) {
                     $cod_cost = $cod_zones[$i + 1];
                     $cod_country = true;
                     break;
                 } elseif ($cod_zones[$i] == '00') {
                     $cod_cost = $cod_zones[$i + 1];
                     $cod_country = true;
                     break;
                 } else {
                 }
                 $i++;
             }
         } else {
             //COD selected, but no shipping module which offers COD
         }
         if ($cod_country) {
             $cod_tax = vam_get_tax_rate(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $cod_tax_description = vam_get_tax_description(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
                 $order->info['tax'] += vam_add_tax($cod_cost, $cod_tax) - $cod_cost;
                 $order->info['tax_groups'][TAX_ADD_TAX . "{$cod_tax_description}"] += vam_add_tax($cod_cost, $cod_tax) - $cod_cost;
                 $order->info['total'] += $cod_cost + (vam_add_tax($cod_cost, $cod_tax) - $cod_cost);
                 $cod_cost_value = vam_add_tax($cod_cost, $cod_tax);
                 $cod_cost = $vamPrice->Format($cod_cost_value, true);
             }
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
                 $order->info['tax'] += vam_add_tax($cod_cost, $cod_tax) - $cod_cost;
                 $order->info['tax_groups'][TAX_NO_TAX . "{$cod_tax_description}"] += vam_add_tax($cod_cost, $cod_tax) - $cod_cost;
                 $cod_cost_value = $cod_cost;
                 $cod_cost = $vamPrice->Format($cod_cost, true);
                 $order->info['subtotal'] += $cod_cost_value;
                 $order->info['total'] += $cod_cost_value;
             }
             if (!$cod_cost_value) {
                 $cod_cost_value = $cod_cost;
                 $cod_cost = $vamPrice->Format($cod_cost, true);
                 $order->info['total'] += $cod_cost_value;
             }
             $this->output[] = array('title' => $this->title . ':', 'text' => $cod_cost, 'value' => $cod_cost_value);
         } else {
             //Following code should be improved if we can't get the shipping modules disabled, who don't allow COD
             // as well as countries who do not have cod
             //          $this->output[] = array('title' => $this->title . ':',
             //                                  'text' => 'No COD for this module.',
             //                                  'value' => '');
         }
     }
 }
コード例 #27
0
ファイル: order.php プロジェクト: nomadcomanche/zdorov_shop
 function cart()
 {
     global $currencies, $vamPrice;
     $this->content_type = $_SESSION['cart']->get_content_type();
     $customer_address_query = vam_db_query("select c.payment_unallowed,c.customers_id,c.shipping_unallowed,c.customers_firstname,c.customers_secondname,c.customers_cid, c.customers_gender,c.customers_lastname, c.customers_telephone, c.customers_email_address, c.orig_reference, c.login_reference, c.customers_personal_discount, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . $_SESSION['customer_id'] . "' and ab.customers_id = '" . $_SESSION['customer_id'] . "' and c.customers_default_address_id = ab.address_book_id");
     $customer_address = vam_db_fetch_array($customer_address_query);
     $shipping_address_query = vam_db_query("select ab.entry_firstname, ab.entry_secondname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . $_SESSION['customer_id'] . "' and ab.address_book_id = '" . $_SESSION['sendto'] . "'");
     $shipping_address = vam_db_fetch_array($shipping_address_query);
     $billing_address_query = vam_db_query("select ab.entry_firstname, ab.entry_secondname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . $_SESSION['customer_id'] . "' and ab.address_book_id = '" . $_SESSION['billto'] . "'");
     $billing_address = vam_db_fetch_array($billing_address_query);
     $tax_address_query = vam_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . $_SESSION['customer_id'] . "' and ab.address_book_id = '" . ($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . "'");
     $tax_address = vam_db_fetch_array($tax_address_query);
     $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $_SESSION['currency'], 'currency_value' => $vamPrice->currencies[$_SESSION['currency']]['value'], 'payment_method' => $_SESSION['payment'], 'cc_type' => isset($_SESSION['payment']) == 'cc' && isset($_SESSION['ccard']['cc_type']) ? $_SESSION['ccard']['cc_type'] : '', 'cc_owner' => isset($_SESSION['payment']) == 'cc' && isset($_SESSION['ccard']['cc_owner']) ? $_SESSION['ccard']['cc_owner'] : '', 'cc_number' => isset($_SESSION['payment']) == 'cc' && isset($_SESSION['ccard']['cc_number']) ? $_SESSION['ccard']['cc_number'] : '', 'cc_expires' => isset($_SESSION['payment']) == 'cc' && isset($_SESSION['ccard']['cc_expires']) ? $_SESSION['ccard']['cc_expires'] : '', 'cc_start' => isset($_SESSION['payment']) == 'cc' && isset($_SESSION['ccard']['cc_start']) ? $_SESSION['ccard']['cc_start'] : '', 'cc_issue' => isset($_SESSION['payment']) == 'cc' && isset($_SESSION['ccard']['cc_issue']) ? $_SESSION['ccard']['cc_issue'] : '', 'cc_cvv' => isset($_SESSION['payment']) == 'cc' && isset($_SESSION['ccard']['cc_cvv']) ? $_SESSION['ccard']['cc_cvv'] : '', 'shipping_method' => $_SESSION['shipping']['title'], 'shipping_cost' => $_SESSION['shipping']['cost'], 'comments' => $_SESSION['comments'], 'shipping_class' => $_SESSION['shipping']['id'], 'payment_class' => $_SESSION['payment']);
     if (isset($_SESSION['payment']) && is_object($_SESSION['payment'])) {
         $this->info['payment_method'] = $_SESSION['payment']->title;
         $this->info['payment_class'] = $_SESSION['payment']->title;
         if (isset($_SESSION['payment']->order_status) && is_numeric($_SESSION['payment']->order_status) && $_SESSION['payment']->order_status > 0) {
             $this->info['order_status'] = $_SESSION['payment']->order_status;
         }
     }
     $this->customer = array('id' => $customer_address['customers_id'], 'firstname' => $customer_address['customers_firstname'], 'secondname' => $customer_address['customers_secondname'], 'lastname' => $customer_address['customers_lastname'], 'csID' => $customer_address['customers_cid'], 'gender' => $customer_address['customers_gender'], 'company' => $customer_address['entry_company'], 'street_address' => $customer_address['entry_street_address'], 'suburb' => $customer_address['entry_suburb'], 'city' => $customer_address['entry_city'], 'postcode' => $customer_address['entry_postcode'], 'state' => vam_not_null($customer_address['entry_state']) ? $customer_address['entry_state'] : $customer_address['zone_name'], 'zone_id' => $customer_address['entry_zone_id'], 'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']), 'format_id' => $customer_address['address_format_id'], 'telephone' => $customer_address['customers_telephone'], 'payment_unallowed' => $customer_address['payment_unallowed'], 'shipping_unallowed' => $customer_address['shipping_unallowed'], 'email_address' => $customer_address['customers_email_address'], 'personal_discount' => $customer_address['customers_personal_discount'], 'orig_reference' => $customer_address['orig_reference'], 'login_reference' => $customer_address['login_reference']);
     //*******
     $this->delivery = array('firstname' => $shipping_address['entry_firstname'], 'secondname' => $shipping_address['entry_secondname'], 'lastname' => $shipping_address['entry_lastname'], 'company' => $shipping_address['entry_company'], 'street_address' => $shipping_address['entry_street_address'], 'suburb' => $shipping_address['entry_suburb'], 'city' => $shipping_address['entry_city'], 'postcode' => $shipping_address['entry_postcode'], 'state' => vam_not_null($shipping_address['entry_state']) ? $shipping_address['entry_state'] : $shipping_address['zone_name'], 'zone_id' => $shipping_address['entry_zone_id'], 'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']), 'country_id' => $shipping_address['entry_country_id'], 'format_id' => $shipping_address['address_format_id']);
     $this->billing = array('firstname' => $billing_address['entry_firstname'], 'secondname' => $billing_address['entry_secondname'], 'lastname' => $billing_address['entry_lastname'], 'company' => $billing_address['entry_company'], 'street_address' => $billing_address['entry_street_address'], 'suburb' => $billing_address['entry_suburb'], 'city' => $billing_address['entry_city'], 'postcode' => $billing_address['entry_postcode'], 'state' => vam_not_null($billing_address['entry_state']) ? $billing_address['entry_state'] : $billing_address['zone_name'], 'zone_id' => $billing_address['entry_zone_id'], 'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']), 'country_id' => $billing_address['entry_country_id'], 'format_id' => $billing_address['address_format_id']);
     $index = 0;
     $products = $_SESSION['cart']->get_products();
     for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
         $products_price = $vamPrice->GetPrice($products[$i]['id'], $format = false, $products[$i]['quantity'], $products[$i]['tax_class_id'], '') + $vamPrice->Format($_SESSION['cart']->attributes_price($products[$i]['id']), false);
         $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax_class_id' => $products[$i]['tax_class_id'], 'tax' => vam_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => vam_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products_price, 'final_price' => $products_price * $products[$i]['quantity'], 'shipping_time' => $products[$i]['shipping_time'], 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id'], 'image' => $products[$i]['image']);
         if ($products[$i]['attributes']) {
             $subindex = 0;
             reset($products[$i]['attributes']);
             while (list($option, $value) = each($products[$i]['attributes'])) {
                 $attributes_query = vam_db_query("select popt.products_options_name, popt.products_options_type, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $products[$i]['id'] . "' and pa.options_id = '" . $option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $_SESSION['languages_id'] . "' and poval.language_id = '" . $_SESSION['languages_id'] . "'");
                 $attributes = vam_db_fetch_array($attributes_query);
                 if ($attributes['products_options_type'] == '2' || $attributes['products_options_type'] == '3') {
                     $attr_value = $products[$i]['attributes_values'][$option];
                 } else {
                     $attr_value = $attributes['products_options_values_name'];
                 }
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'], 'value' => $attr_value, 'option_id' => $option, 'value_id' => $value, 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']);
                 $subindex++;
             }
         }
         $shown_price = $this->products[$index]['final_price'];
         $this->info['subtotal'] += $shown_price;
         if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == 1) {
             $shown_price_tax = $shown_price - $shown_price / 100 * $_SESSION['customers_status']['customers_status_ot_discount'];
         }
         $products_tax = $this->products[$index]['tax'];
         $products_tax_description = $this->products[$index]['tax_description'];
         if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '1') {
             if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == 1) {
                 $this->info['tax'] += $shown_price_tax - $shown_price_tax / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax));
                 $this->info['tax_groups'][TAX_ADD_TAX . "{$products_tax_description}"] += $shown_price_tax / (100 + $products_tax) * $products_tax;
             } else {
                 $this->info['tax'] += $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax));
                 $this->info['tax_groups'][TAX_ADD_TAX . "{$products_tax_description}"] += $shown_price / (100 + $products_tax) * $products_tax;
             }
         } else {
             if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == 1) {
                 $this->info['tax'] += $shown_price_tax / 100 * $products_tax;
                 $this->info['tax_groups'][TAX_NO_TAX . "{$products_tax_description}"] += $shown_price_tax / 100 * $products_tax;
             } else {
                 $this->info['tax'] += $shown_price / 100 * $products_tax;
                 $this->info['tax_groups'][TAX_NO_TAX . "{$products_tax_description}"] += $shown_price / 100 * $products_tax;
             }
         }
         $index++;
     }
     //$this->info['shipping_cost']=0;
     if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '0') {
         $this->info['total'] = $this->info['subtotal'] + $vamPrice->Format($this->info['shipping_cost'], false, 0, true);
         if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == '1') {
             $this->info['total'] -= $this->info['subtotal'] / 100 * $_SESSION['customers_status']['customers_status_ot_discount'];
         }
     } else {
         $this->info['total'] = $this->info['subtotal'] + $vamPrice->Format($this->info['shipping_cost'], false, 0, true);
         if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == '1') {
             $this->info['total'] -= $this->info['subtotal'] / 100 * $_SESSION['customers_status']['customers_status_ot_discount'];
         }
     }
 }
コード例 #28
0
 function quote($method = '')
 {
     global $order, $shipping_weight, $total_count;
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_RUSSIANPOSTEMS_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_RUSSIANPOSTEMS_TEXT_NOTE)));
     if (vam_not_null($this->icon)) {
         $this->quotes['icon'] = vam_image($this->icon, $this->title);
     }
     $urlCities = "http://emspost.ru/api/rest?method=ems.get.locations&type=cities&plain=true";
     $urlWeight = "http://emspost.ru/api/rest?method=ems.get.max.weight";
     // create curl resource
     //$ch = curl_init();
     //return the transfer as a string
     //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // set url
     //curl_setopt($ch, CURLOPT_URL, $urlWeight);
     //$outWeight = curl_exec($ch);
     $outWeight = Curl_Page($urlWeight);
     $WeightList = json_decode($outWeight, true);
     foreach ($WeightList as $weight) {
         $max_weight = $weight['max_weight'];
         if ($shipping_weight > $max_weight) {
             $this->quotes['error'] = 'Превышен максимально возможный вес одного отправления. Разбейте заказ на несколько частей.';
             return $this->quotes;
         }
     }
     //Получаем список городов и регионов
     $urlRussia = "http://emspost.ru/api/rest?method=ems.get.locations&type=russia&plain=true";
     // create curl resource
     //$ch = curl_init();
     //return the transfer as a string
     //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     // set url
     //curl_setopt($ch, CURLOPT_URL, $urlRussia);
     //$outRussia = curl_exec($ch);
     $outRussia = Curl_Page($urlRussia);
     //print 'outRussia';
     //print_r($outRussia);
     //Вытягиваем регион магазина
     $zones_shop = STORE_ZONE;
     $zones_zones = vam_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where (zone_id='{$zones_shop}')");
     $zones_id = vam_db_fetch_array($zones_zones);
     $zonesshop = $zones_id['zone_name'];
     //echo $zones_id['zone_name'];
     //Вытягиваем город получателя
     $tocity = $order->delivery['city'];
     //print $tocity;
     //Вытягиваем регион получателя
     $tostate_id = $order->delivery['state'];
     $tostate_tostate = vam_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where (zone_name='{$tostate_id}')");
     //print_r($tostate_tostate['zone_id']);
     $tostate_tostate_id = vam_db_fetch_array($tostate_tostate);
     $tostate = $tostate_tostate_id['zone_name'];
     //print($tostate)."<br><br>";
     //проверяем город/регион отправителя/получателя
     $RussiaList = json_decode($outRussia, true);
     foreach ($RussiaList['rsp']['locations'] as $russia) {
         //print mb_convert_case($russia['name'], MB_CASE_UPPER, "UTF-8")."<br>";
         //		print
         $str = MODULE_SHIPPING_RUSSIANPOSTEMS_CITY;
         //print $str;
         //print "АПП".mb_convert_case($str, MB_CASE_UPPER, "UTF-8");
         $mode = MB_CASE_UPPER;
         $conv = "UTF-8";
         $rus01 = mb_convert_case($russia['name'], MB_CASE_UPPER, "UTF-8");
         $rus02 = mb_convert_case($str, MB_CASE_UPPER, "UTF-8");
         //print "rus01".$rus02."<br>";
         if ($rus01 == $rus02) {
             //print "rus01".$rus01."== rus02".$rus02."<br>";
             //$from = $rus01;
             $from = $russia['value'];
             //print "from1 ".$from."<br>";
         }
         if ($from === null) {
             if (mb_convert_case($russia['name'], $mode, $conv) == mb_convert_case($zonesshop, $mode, $conv)) {
                 //print mb_convert_case($russia['name'],$mode,$conv). "==". mb_convert_case($zonesshop,$mode,$conv)."<br>";
                 $from = $russia['value'];
                 //print "from2 ".$from."<br>";
             }
         }
         if (mb_convert_case($russia['name'], $mode, $conv) == mb_convert_case($tocity, $mode, $conv)) {
             //print mb_convert_case($russia['name'],$mode,$conv) ."==". mb_convert_case($tocity,$mode,$conv)."<br>";
             $to = $russia['value'];
             $tomessag = 'город: ' . $russia['name'];
             //print "To 1".$tomessag;
         }
         if ($to === null) {
             if (mb_convert_case($russia['name'], $mode, $conv) == mb_convert_case($tostate, $mode, $conv)) {
                 //print mb_convert_case($russia['name'],$mode,$conv) ."==". mb_convert_case($tostate,$mode,$conv)."<br>";
                 $to = $russia['value'];
                 $tomessag = 'регион: ' . $russia['name'];
                 //print "To 2".$tomessag;
             }
         }
     }
     //echo "russ list";
     //print_r($RussiaList);
     // Если вдруг ничего не нашлось
     if ($from === null) {
         $this->quotes['error'] = 'Доставка из города:  ' . MODULE_SHIPPING_RUSSIANPOSTEMS_CITY . ' не производится! Возможно Вы допустили ошибку в адресе.';
         return $this->quotes;
     } else {
         if ($to === null) {
             $this->quotes['error'] = 'Доставка в город:  ' . $tocity . ' не производится! Возможно Вы допустили ошибку в адресе.';
             return $this->quotes;
         }
     }
     //----
     $url = "http://emspost.ru/api/rest?method=ems.calculate&from=" . $from . "&to=" . $to . "&weight=" . $shipping_weight;
     //print "calculaded".$url;
     //curl_setopt($ch, CURLOPT_URL, $url);
     //$output = curl_exec($ch);
     $output = Curl_Page($url);
     // close curl resource to free up system resources
     //curl_close($ch);
     $contents = $output;
     $contents = $contents;
     $results = json_decode($contents, true);
     if ($results['rsp']['stat'] == 'fail') {
         $this->quotes['error'] = 'Ошибка: ' . $results['rsp']['err']['msg'];
         return $this->quotes;
     }
     $shPrice = $results['rsp']['price'];
     if (MODULE_SHIPPING_RUSSIANPOSTEMS_DCVAL_PERCENT > 0) {
         $shPrice += $order->info['subtotal'] * MODULE_SHIPPING_RUSSIANPOSTEMS_DCVAL_PERCENT / 100;
     }
     $this->quotes['methods'][key($this->quotes['methods'])]['cost'] = $shPrice + MODULE_SHIPPING_RUSSIANPOSTEMS_HANDLING;
     $this->quotes['methods'][key($this->quotes['methods'])]['title'] = 'Доставка в ' . $tomessag . '. ';
     $dlvr_min = $results['rsp']['term']['min'];
     $dlvr_max = $results['rsp']['term']['max'];
     if ($dlvr_min > 0 and $dlvr_max > 0) {
         if ($dlvr_min == $dlvr_max) {
             $this->quotes['methods'][key($this->quotes['methods'])]['title'] .= '(<i>Срок доставки ' . $dlvr_max;
         } else {
             $this->quotes['methods'][key($this->quotes['methods'])]['title'] .= '(<i>Срок доставки ' . $dlvr_min . ' - ' . $dlvr_max;
         }
         if ($dlvr_max == 1) {
             $this->quotes['methods'][key($this->quotes['methods'])]['title'] .= ' день';
         } else {
             if ($dlvr_max > 1 and $dlvr_max < 5) {
                 $this->quotes['methods'][key($this->quotes['methods'])]['title'] .= ' дня';
             } else {
                 $this->quotes['methods'][key($this->quotes['methods'])]['title'] .= ' дней';
             }
         }
         $this->quotes['methods'][key($this->quotes['methods'])]['title'] .= '</i>)';
     }
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = vam_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     return $this->quotes;
 }
コード例 #29
0
ファイル: cod.php プロジェクト: nomadcomanche/zdorov_shop
 function selection()
 {
     global $vamPrice, $order;
     if (MODULE_ORDER_TOTAL_COD_FEE_STATUS == 'true') {
         $cod_country = false;
         //process installed shipping modules
         if ($_SESSION['shipping']['id'] == 'flat_flat') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FLAT);
         }
         if ($_SESSION['shipping']['id'] == 'item_item') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ITEM);
         }
         if ($_SESSION['shipping']['id'] == 'table_table') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_TABLE);
         }
         if ($_SESSION['shipping']['id'] == 'zones_zones') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ZONES);
         }
         if ($_SESSION['shipping']['id'] == 'ap_ap') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_AP);
         }
         if ($_SESSION['shipping']['id'] == 'dp_dp') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DP);
         }
         if ($_SESSION['shipping']['id'] == 'chp_ECO') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP);
         }
         if ($_SESSION['shipping']['id'] == 'chp_PRI') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP);
         }
         if ($_SESSION['shipping']['id'] == 'chp_URG') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP);
         }
         if ($_SESSION['shipping']['id'] == 'chronopost_chronopost') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHRONOPOST);
         }
         if ($_SESSION['shipping']['id'] == 'dhl_ECX') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
         }
         if ($_SESSION['shipping']['id'] == 'dhl_DOX') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
         }
         if ($_SESSION['shipping']['id'] == 'dhl_SDX') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
         }
         if ($_SESSION['shipping']['id'] == 'dhl_MDX') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
         }
         if ($_SESSION['shipping']['id'] == 'dhl_WPX') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);
         }
         if ($_SESSION['shipping']['id'] == 'ups_ups') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPS);
         }
         if ($_SESSION['shipping']['id'] == 'upse_upse') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPSE);
         }
         if ($_SESSION['shipping']['id'] == 'free_free') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREE);
         }
         if ($_SESSION['shipping']['id'] == 'freeamount_freeamount') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_FREEAMOUNT_FREE);
         }
         for ($i = 0; $i < count($cod_zones); $i++) {
             if ($cod_zones[$i] == $order->delivery['country']['iso_code_2']) {
                 $cod_cost = $cod_zones[$i + 1];
                 $cod_country = true;
                 break;
             } elseif ($cod_zones[$i] == '00') {
                 $cod_cost = $cod_zones[$i + 1];
                 $cod_country = true;
                 break;
             } else {
             }
             $i++;
         }
     } else {
         //COD selected, but no shipping module which offers COD
     }
     if ($cod_country) {
         $cod_tax = vam_get_tax_rate(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
         $cod_tax_description = vam_get_tax_description(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
         if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
             $cod_cost_value = vam_add_tax($cod_cost, $cod_tax);
             $cod_cost = $vamPrice->Format($cod_cost_value, true);
         }
         if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
             $cod_cost_value = $cod_cost;
             $cod_cost = $vamPrice->Format($cod_cost, true);
         }
         if (!$cod_cost_value) {
             $cod_cost_value = $cod_cost;
             $cod_cost = $vamPrice->Format($cod_cost, true);
         }
         $this->cost = '+ ' . $cod_cost;
     }
     return array('id' => $this->code, 'module' => $this->title, 'description' => $this->info, 'module_cost' => $this->cost);
 }
コード例 #30
0
                 $maxcount[$option_id] = $download['products_attributes_maxcount'];
             }
             //end if (vam_db_num_rows($download_query) > 0) {
         }
         //end if (DOWNLOAD_ENABLED == 'true') {
         //end downloads
     }
     //end foreach($_POST['add_product_options'] as $option_id => $option_value_id) {
 }
 //end if (isset($_POST['add_product_options'])) {
 // Get Product Info
 $product_query = vam_db_query("select p.products_model, p.products_price, pd.products_name, p.products_tax_class_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on pd.products_id = p.products_id where p.products_id = '" . (int) $add_product_products_id . "'");
 $product = vam_db_fetch_array($product_query);
 $country_id = oe_get_country_id($order->delivery["country"]);
 $zone_id = oe_get_zone_id($country_id, $order->delivery['state']);
 $products_tax = vam_get_tax_rate($product['products_tax_class_id'], $country_id, $zone_id);
 // 2.1.3  Pull specials price from db if there is an active offer
 $special_price = vam_db_query("\n\t\t\tSELECT specials_new_products_price \n\t\t\tFROM " . TABLE_SPECIALS . " \n\t\t\tWHERE products_id =" . $add_product_products_id . " \n\t\t\tAND status");
 $new_price = vam_db_fetch_array($special_price);
 if ($new_price) {
     $product['products_price'] = $new_price['specials_new_products_price'];
 }
 // Спец. цена
 //Modified 4 VAM
 //$product['products_price']=b2b_display_price($add_product_products_id,$product['products_price']);
 $products_price = $vamPrice->GetPrice($add_product_products_id, $format = true, 1, $product['products_tax_class_id'], $product['products_price'], 1);
 $product['products_price'] = $products_price['plain'];
 //End mod 4 VAM
 // Спец. цена - скидка
 //Modified 4 VAM
 //            if ($new_price =