コード例 #1
0
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     if (!$order) {
         $order = new order();
         $shipping_weight = $_SESSION['cart']->show_weight();
     }
     $order_delivery_country = $order->delivery['country'];
     if (MODULE_SHIPPING_TABLE_MODE == 'price') {
         $order_total = $_SESSION['cart']->show_total();
     } else {
         $order_total = $shipping_weight;
     }
     $table_cost = split("[:,]", MODULE_SHIPPING_TABLE_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_TABLE_MODE == 'weight') {
         $shipping = $shipping * $shipping_num_boxes;
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_TABLE_TEXT_WAY, 'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING)));
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = olc_get_tax_rate($this->tax_class, $order_delivery_country['id'], $order->delivery['zone_id']);
     }
     if (olc_not_null($this->icon)) {
         $this->quotes['icon'] = olc_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
function olc_format_price_graduated($price_string, $price_special, $calculate_currencies, $products_tax_class)
{
    if ((int) $price_string == 0) {
        $price_string = EMPTY_STRING;
    } else {
        include DIR_FS_INC . 'olc_get_currency_parameters.inc.php';
        if ($calculate_currencies == TRUE_STRING_S) {
            $price_string = $price_string * CURRENCY_VALUE;
        }
        // add tax
        if ($_SESSION['customers_status']['customers_status_show_price_tax'] != '0') {
            $products_tax = olc_get_tax_rate($products_tax_class);
            $price_string = olc_add_tax($price_string, $products_tax);
        }
        // round price
        $price_string = olc_precision($price_string, CURRENCY_DECIMAL_PLACES);
        if ($price_special == '1') {
            $price_string = number_format($price_string, CURRENCY_DECIMAL_PLACES, CURRENCY_DECIMAL_POINT, CURRENCY_THOUSANDS_POINT);
            $price_string = CURRENCY_SYMBOL_LEFT . $price_string . CURRENCY_SYMBOL_RIGHT;
        }
        //1,00 -> 1,--
        global $is_print_version, $is_pdf;
        if ($is_print_version) {
            if ($is_pdf) {
                $s = CURRENCY_DECIMAL_ZEROES_DASHES_PRINT_PDF;
            } else {
                $s = CURRENCY_DECIMAL_ZEROES_DASHES_PRINT;
            }
        } else {
            $s = CURRENCY_DECIMAL_ZEROES_DASHES;
        }
        $price_string = str_replace(CURRENCY_DECIMAL_ZEROES, $s, $price_string);
    }
    return $price_string;
}
function olc_get_products_attribute_price($attribute_price, $tax_class, $price_special, $quantity, $prefix, $calculate_currencies = TRUE_STRING_S)
{
    if ($_SESSION['customers_status']['customers_status_show_price'] == '1') {
        $attribute_tax = olc_get_tax_rate($tax_class);
        // check if user is allowed to see tax rates
        if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '0') {
            $attribute_tax = '';
        }
        // add tax
        $price_string = olc_add_tax($attribute_price, $attribute_tax) * $quantity;
        if ($_SESSION['customers_status']['customers_status_discount_attributes'] == '0') {
            // format price & calculate currency
            $price_string = olc_format_price($price_string, $price_special, $calculate_currencies);
            if ($price_special == '1') {
                $price_string = BLANK . $prefix . BLANK . $price_string . BLANK;
            }
        } else {
            $discount = $_SESSION['customers_status']['customers_status_discount'];
            $rabatt_string = $price_string - $price_string / 100 * $discount;
            $price_string = olc_format_price($price_string, $price_special, $calculate_currencies);
            $rabatt_string = olc_format_price($rabatt_string, $price_special, $calculate_currencies);
            if ($price_special == '1' && $price_string != $rabatt_string) {
                $price_string = BLANK . $prefix . '<font color="ff0000"><s>' . $price_string . '</s></font> ' . $rabatt_string . BLANK;
            } else {
                $price_string = $rabatt_string;
                if ($price_special == '1') {
                    $price_string = BLANK . $prefix . BLANK . $price_string;
                }
            }
        }
    } else {
        $price_string = '  ' . NOT_ALLOWED_TO_SEE_PRICES;
    }
    return $price_string;
}
コード例 #4
0
 function process()
 {
     global $order, $currencies;
     if (MODULE_ORDER_TOTAL_VERPACKUNG_LOW_ORDER_FEE == TRUE_STRING_S) {
         switch (MODULE_ORDER_TOTAL_VERPACKUNG_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['verpackung_cost'] < MODULE_ORDER_TOTAL_VERPACKUNG_ORDER_UNDER) {
             $tax = olc_get_tax_rate(MODULE_ORDER_TOTAL_VERPACKUNG_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $tax_description = olc_get_tax_description(MODULE_ORDER_TOTAL_VERPACKUNG_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $order->info['tax'] += olc_calculate_tax(MODULE_ORDER_TOTAL_VERPACKUNG_FEE, $tax);
             $order->info['tax_groups']["{$tax_description}"] += olc_calculate_tax(MODULE_ORDER_TOTAL_VERPACKUNG_FEE, $tax);
             $order->info['total'] += MODULE_ORDER_TOTAL_VERPACKUNG_FEE + olc_calculate_tax(MODULE_ORDER_TOTAL_VERPACKUNG_FEE, $tax);
             $this->output[] = array('title' => $this->title . ':', 'text' => $currencies->format(olc_add_tax(MODULE_ORDER_TOTAL_VERPACKUNG_FEE, $tax), true, $order->info['currency'], $order->info['currency_value']), 'value' => olc_add_tax(MODULE_ORDER_TOTAL_VERPACKUNG_FEE, $tax));
         }
     }
 }
コード例 #5
0
 function get_order_total()
 {
     global $order, $cart;
     $order_total = $order->info['total'];
     // Check if gift voucher is in cart and adjust total
     $products = $cart->get_products();
     for ($i = 0; $i < sizeof($products); $i++) {
         $t_prid = olc_get_prid($products[$i]['id']);
         $gv_query = olc_db_query("select products_price, products_tax_class_id, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . APOS);
         $gv_result = olc_db_fetch_array($gv_query);
         if (ereg('^GIFT', addslashes($gv_result['products_model']))) {
             $qty = $cart->get_quantity($t_prid);
             $products_tax = olc_get_tax_rate($gv_result['products_tax_class_id']);
             if ($this->include_tax == FALSE_STRING_S) {
                 $gv_amount = $gv_result['products_price'] * $qty;
             } else {
                 $gv_amount = ($gv_result['products_price'] + olc_calculate_tax($gv_result['products_price'], $products_tax)) * $qty;
             }
             $order_total = $order_total - $gv_amount;
         }
     }
     if ($this->include_tax == FALSE_STRING_S) {
         $order_total = $order_total - $order->info['tax'];
     }
     if ($this->include_shipping == FALSE_STRING_S) {
         $order_total = $order_total - $order->info['shipping_cost'];
     }
     return $order_total;
 }
コード例 #6
0
 function process()
 {
     global $order, $currencies;
     if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == TRUE_STRING_S) {
         $pass = false;
         if ($_SESSION['shipping']['id'] != 'selfpickup_selfpickup') {
             $country = $order->delivery['country_id'];
             switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) {
                 case 'national':
                     if ($country == STORE_COUNTRY) {
                         $pass = true;
                     }
                     break;
                 case 'international':
                     if ($country != STORE_COUNTRY) {
                         $pass = true;
                     }
                     break;
                 case 'both':
                     $pass = true;
                     break;
             }
         }
         if ($pass) {
             if ($order->info['total'] - $order->info['shipping_cost'] < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) {
                 $delivery_country = $order->delivery['country']['id'];
                 $delivery_zone_id = $order->delivery['zone_id'];
                 $tax = olc_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $delivery_country, $delivery_zone_id);
                 $tax_description = olc_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $delivery_country, $delivery_zone_id);
                 $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE;
                 $low_order_fee_tax = olc_calculate_tax($low_order_fee, $tax);
                 $low_order_fee = olc_add_tax($low_order_fee, $tax);
                 if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
                     $order->info['tax'] += $low_order_fee_tax;
                     $order->info['tax_groups'][TAX_ADD_TAX . "{$tax_description}"] += $low_order_fee_tax;
                     $order->info['total'] += $low_order_fee;
                 } else {
                     if ($_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
                         $order->info['tax'] += $low_order_fee_tax;
                         $order->info['tax_groups'][TAX_NO_TAX . "{$tax_description}"] += $low_order_fee_tax;
                     }
                     $order->info['subtotal'] += $low_order_fee;
                     $order->info['total'] += $low_order_fee;
                 }
                 $this->output[] = array('title' => $this->title . ':', 'text' => olc_format_price($low_order_fee, 1, 1, 1), 'value' => $low_order_fee);
             }
         }
     }
 }
コード例 #7
0
 function process()
 {
     global $order, $currencies, $customer_id;
     //      if (MODULE_ORDER_TOTAL_HANDLING_HANDLING == TRUE_STRING_S) {
     $freequery = olc_db_query("SELECT SUM(cb.customers_basket_quantity) AS total FROM " . TABLE_CUSTOMERS_BASKET . " cb LEFT JOIN " . TABLE_PRODUCTS . " p ON cb.products_id = p.products_id WHERE cb.customers_id =  '" . $customer_id . "' AND cb.final_price <  '0.01' AND p.products_price <  '0.01'");
     $freestuff = olc_db_fetch_array($freequery);
     $freeitems = $freestuff['total'];
     $handlingfree = $order->info['subtotal'] / 100 * 0.85;
     $tax = olc_get_tax_rate(MODULE_ORDER_TOTAL_HANDLING_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
     $tax_description = olc_get_tax_description(MODULE_ORDER_TOTAL_HANDLING_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
     $order->info['tax'] += olc_calculate_tax($handlingfree, $tax);
     $order->info['tax_groups']["{$tax_description}"] += olc_calculate_tax($handlingfree, $tax);
     $order->info['total'] += $handlingfree + olc_calculate_tax($handlingfree, $tax);
     $this->output[] = array('title' => $this->title . ':', 'text' => olc_format_price(olc_add_tax($handlingfree, $tax), true, $order->info['currency'], $order->info['currency_value']), 'value' => olc_add_tax($handlingfree, $tax));
 }
コード例 #8
0
 function olcGetPrice($pID, $format = true, $qty, $tax_class, $pPrice, $vpeStatus = 0, $cedit_id = 0, $show_tax = 0)
 {
     // check if group is allowed to see prices
     if ($this->cStatus['customers_status_show_price'] == '0') {
         return $this->olcShowNote($vpeStatus, $vpeStatus);
     }
     // get Tax rate
     if ($cedit_id != 0) {
         $cinfo = olc_oe_customer_infos($cedit_id);
         $products_tax = olc_get_tax_rate($tax_class, $cinfo['country_id'], $cinfo['zone_id']);
     } else {
         $products_tax = $this->TAX[$tax_class];
     }
     if ($show_tax == 0) {
         if ($this->cStatus['customers_status_show_price_tax'] == '0') {
             $products_tax = '';
         }
     }
     // add taxes
     if ($pPrice == 0) {
         $pPrice = $this->getPprice($pID);
     }
     $pPrice = $this->olcAddTax($pPrice, $products_tax);
     // check specialprice
     if ($sPrice = $this->olcCheckSpecial($pID)) {
         return $this->olcFormatSpecial($pID, $this->olcAddTax($sPrice, $products_tax), $pPrice, $format, $vpeStatus);
     }
     // check graduated
     if ($this->cStatus['customers_status_graduated_prices'] == '1') {
         if ($sPrice = $this->olcGetGraduatedPrice($pID, $qty)) {
             return $this->olcFormatSpecialGraduated($pID, $this->olcAddTax($sPrice, $products_tax), $pPrice, $format, $vpeStatus, $pID);
         }
     } else {
         // check Group Price
         if ($sPrice = $this->olcGetGroupPrice($pID, 1)) {
             return $this->olcFormatSpecialGraduated($pID, $this->olcAddTax($sPrice, $products_tax), $pPrice, $format, $vpeStatus, $pID);
         }
     }
     // check Product Discount
     if ($discount = $this->olcCheckDiscount($pID)) {
         return $this->olcFormatSpecialDiscount($pID, $discount, $pPrice, $format, $vpeStatus);
     }
     return $this->olcFormat($pPrice, $format, 0, false, $vpeStatus, $pID);
 }
コード例 #9
0
 function quote($method = '')
 {
     global $order, $total_count;
     if (!$order) {
         $order = new order();
     }
     if (!$shipping_weight) {
         $shipping_weight = $_SESSION['cart']->show_weight();
     }
     $order_delivery_country = $order->delivery['country'];
     $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'] = olc_get_tax_rate($this->tax_class, $order_delivery_country['id'], $order->delivery['zone_id']);
     }
     if (olc_not_null($this->icon)) {
         $this->quotes['icon'] = olc_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
function olc_oe_get_products_attribute_price($attribute_price, $tax_class, $price_special, $quantity, $prefix, $calculate_currencies = TRUE_STRING_S, $customer_status)
{
    $customers_status_query = olc_db_query("select * from " . TABLE_CUSTOMERS_STATUS . " where customers_status_id = '" . $customer_status . "' ");
    $customers_status = olc_db_fetch_array($customers_status_query);
    if ($customers_status['customers_status_show_price'] == '1') {
        $attribute_tax = olc_get_tax_rate($tax_class);
        // check if user is allowed to see tax rates
        if ($customers_status['customers_status_show_price_tax'] == '0') {
            $attribute_tax = '';
        }
        // add tax
        $price_string = olc_add_tax($attribute_price, $attribute_tax) * $quantity;
        if ($customers_status['customers_status_discount_attributes'] == '0') {
            // format price & calculate currency
            $price_string = olc_format_price($price_string, $price_special, $calculate_currencies);
            if ($price_special == '1') {
                $price_string = BLANK . $prefix . BLANK . $price_string . BLANK;
            }
        } else {
            $discount = $customers_status['customers_status_discount'];
            $rabatt_string = $price_string - $price_string / 100 * $discount;
            $price_string = olc_format_price($price_string, $price_special, $calculate_currencies);
            $rabatt_string = olc_format_price($rabatt_string, $price_special, $calculate_currencies);
            if ($price_special == '1' && $price_string != $rabatt_string) {
                $price_string = BLANK . $prefix . '<font color="ff0000"><s>' . $price_string . '</s></font> ' . $rabatt_string . BLANK;
            } else {
                $price_string = $rabatt_string;
                if ($price_special == '1') {
                    $price_string = BLANK . $prefix . BLANK . $price_string;
                }
            }
        }
    } else {
        $price_string = '  ' . NOT_ALLOWED_TO_SEE_PRICES;
    }
    return $price_string;
}
コード例 #11
0
 function process()
 {
     global $order, $currencies, $cod_cost, $cod_country, $shipping;
     if (strtolower(MODULE_ORDER_TOTAL_COD_STATUS) == TRUE_STRING_S) {
         //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
             $shipping_id = $_SESSION['shipping']['id'];
             $split_text = "[:,]";
             if ($shipping_id == 'flat_flat') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_FLAT);
             } elseif ($shipping_id == 'item_item') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_ITEM);
             } elseif ($shipping_id == 'table_table') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_TABLE);
             } elseif ($shipping_id == 'zones_zones') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_ZONES);
             } elseif ($shipping_id == 'ap_ap') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_AP);
             } elseif ($shipping_id == 'dp_dp') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_DP);
             } elseif ($shipping_id == 'dpd_dpd') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_DPD);
             } elseif ($shipping_id == 'ups_ups') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_UPS);
             } elseif ($shipping_id == 'upse_upse') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_UPSE);
             } elseif ($shipping_id == 'freeamountausl_freeamountausl') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_FREEAMOUNTAUSL);
             } elseif ($shipping_id == 'freeamount_freeamount') {
                 $cod_zones = split($split_text, MODULE_ORDER_TOTAL_COD_FEE_FREEAMOUNT);
             }
             $country_iso_code_2 = $order->billing['country']['iso_code_2'];
             for ($i = 0; $i < count($cod_zones); $i++) {
                 if ($cod_zones[$i] == $country_iso_code_2) {
                     $cod_cost = $cod_zones[$i + 1];
                     $cod_country = true;
                     //print('match' . $cod_zones[$i] . ': ' . $cod_cost);
                     break;
                 } elseif ($cod_zones[$i] == '00') {
                     $cod_cost = $cod_zones[$i + 1];
                     $cod_country = true;
                     //print('match' . $i . ': ' . $cod_cost);
                     break;
                 } else {
                     //print('no match');
                 }
                 $i++;
             }
         } else {
             //COD selected, but no shipping module which offers COD
         }
         if ($cod_country) {
             $cod_tax = olc_get_tax_rate(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $cod_tax_description = olc_get_tax_description(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
                 $order->info['tax'] += olc_add_tax($cod_cost, $cod_tax) - $cod_cost;
                 $order->info['tax_groups'][TAX_ADD_TAX . "{$cod_tax_description}"] += olc_add_tax($cod_cost, $cod_tax) - $cod_cost;
                 $order->info['total'] += $cod_cost + (olc_add_tax($cod_cost, $cod_tax) - $cod_cost);
                 $cod_cost_value = olc_add_tax($cod_cost, $cod_tax);
                 $cod_cost = olc_format_price($cod_cost_value, $price_special = 1, $calculate_currencies = true);
             }
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
                 $order->info['tax'] += olc_add_tax($cod_cost, $cod_tax) - $cod_cost;
                 $order->info['tax_groups'][TAX_NO_TAX . "{$cod_tax_description}"] += olc_add_tax($cod_cost, $cod_tax) - $cod_cost;
                 $cod_cost_value = $cod_cost;
                 $cod_cost = olc_format_price($cod_cost, $price_special = 1, $calculate_currencies = true);
                 $order->info['subtotal'] += $cod_cost_value;
                 $order->info['total'] += $cod_cost_value;
             }
             if (!$cod_cost_value) {
                 $cod_cost_value = $cod_cost;
                 $cod_cost = olc_format_price($cod_cost, $price_special = 1, $calculate_currencies = 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' => '');
         }
     }
 }
コード例 #12
0
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     if (!$order) {
         $order = new order();
     }
     if (!$shipping_weight) {
         $shipping_weight = $_SESSION['cart']->show_weight();
     }
     $order_delivery_country = $order->delivery['country'];
     $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 = 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 = 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 = 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 = 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 . LPAREN . $shipping_num_boxes . ' x ' . number_format($shipping_weight, CURRENCY_DECIMAL_PLACES, CURRENCY_DECIMAL_POINT, CURRENCY_THOUSANDS_POINT) . BLANK . MODULE_SHIPPING_CHP_TEXT_UNITS . RPAREN);
     $this->quotes['methods'] = $methods;
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = olc_get_tax_rate($this->tax_class, $order_delivery_country['id'], $order->delivery['zone_id']);
     }
     if (olc_not_null($this->icon)) {
         $this->quotes['icon'] = olc_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = MODULE_SHIPPING_CHP_INVALID_ZONE;
     }
     if (olc_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;
 }
コード例 #13
0
 function process()
 {
     global $order, $currencies;
     $shipping_cost = $order->info['shipping_cost'];
     if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == TRUE_STRING_S) {
         $country_id = $order->delivery['country_id'];
         switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
             case 'national':
                 if ($country_id == STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'international':
                 if ($country_id != STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'both':
                 $pass = true;
                 break;
             default:
                 $pass = false;
                 break;
         }
         if ($pass) {
             $total_ex_ship = $order->info['total'] - $shipping_cost;
             if ($total_ex_ship >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {
                 $shipping_method = $this->title . LPAREN . sprintf(FREE_SHIPPING_DESCRIPTION, olc_format_price(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER, true, true, true)) . RPAREN;
                 $order->info['shipping_method'] = $shipping_method;
                 $order->info['total'] = $total_ex_ship;
                 $shipping_cost = 0;
             }
         }
     }
     if (true or $shipping_cost > 0) {
         $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], UNDERSCORE));
         if (olc_not_null($order->info['shipping_method'])) {
             $tax_class = $GLOBALS[$module]->tax_class;
             $country_id = $order->delivery['country']['id'];
             $zone_id = $order->delivery['zone_id'];
             $shipping_tax = olc_get_tax_rate($tax_class, $country_id, $zone_id);
             $shipping_tax_description = olc_get_tax_description($tax_class, $country_id, $zone_id);
             $new_shipping_cost = olc_add_tax($shipping_cost, $shipping_tax);
             $tax = $new_shipping_cost - $shipping_cost;
             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
                 // price with tax
                 $shipping_cost = $new_shipping_cost;
                 $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_add_tax_ot'] == 1) {
                     $order->info['tax'] += $tax;
                     $order->info['tax_groups'][TAX_NO_TAX . "{$shipping_tax_description}"] += $tax;
                 }
             }
             if (true or $shipping_cost) {
                 $this->output[] = array('title' => $order->info['shipping_method'] . COLON, 'text' => olc_format_price($shipping_cost, true, true, true, true), 'value' => $shipping_cost);
             }
         }
     }
 }
コード例 #14
0
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     if (!$order) {
         $order = new order();
     }
     if (!$shipping_weight) {
         $shipping_weight = $_SESSION['cart']->show_weight();
     }
     $order_delivery_country = $order->delivery['country'];
     $dest_country = $order_delivery_country['iso_code_2'];
     $dest_zone = 0;
     $error = false;
     for ($i = 1; $i <= $this->num_dp; $i++) {
         $countries_table = constant('MODULE_SHIPPING_DP_COUNTRIES_' . $i);
         $country_zones = split("[,]", $countries_table);
         if (in_array($dest_country, $country_zones)) {
             $dest_zone = $i;
             break;
         }
     }
     if ($dest_zone == 0) {
         $error = true;
     } else {
         $shipping = -1;
         $dp_cost = constant('MODULE_SHIPPING_DP_COST_' . $i);
         $dp_table = split("[:,]", $dp_cost);
         for ($i = 0; $i < sizeof($dp_table); $i += 2) {
             if ($shipping_weight <= $dp_table[$i]) {
                 $shipping = $dp_table[$i + 1];
                 $shipping_method = MODULE_SHIPPING_DP_TEXT_WAY . BLANK . $order_delivery_country['title'] . ': ';
                 break;
             }
         }
         if ($shipping == -1) {
             $shipping_cost = 0;
             $shipping_method = MODULE_SHIPPING_DP_UNDEFINED_RATE;
         } else {
             $shipping_cost = $shipping + MODULE_SHIPPING_DP_HANDLING;
         }
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_DP_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => $shipping_method . LPAREN . $shipping_num_boxes . ' x ' . number_format($shipping_weight, CURRENCY_DECIMAL_PLACES, CURRENCY_DECIMAL_POINT, CURRENCY_THOUSANDS_POINT) . BLANK . MODULE_SHIPPING_DP_TEXT_UNITS . RPAREN, 'cost' => $shipping_cost * $shipping_num_boxes)));
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = olc_get_tax_rate($this->tax_class, $order_delivery_country['id'], $order->delivery['zone_id']);
     }
     if (olc_not_null($this->icon)) {
         $this->quotes['icon'] = olc_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = MODULE_SHIPPING_DP_INVALID_ZONE;
     }
     return $this->quotes;
 }
コード例 #15
0
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     if (!$order) {
         $order = new order();
     }
     if (!$shipping_weight) {
         $shipping_weight = $_SESSION['cart']->show_weight();
     }
     $order_delivery_country = $order->delivery['country'];
     $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 = 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 = 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 = 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 = 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 . LPAREN . $shipping_num_boxes . ' x ' . number_format($shipping_weight, CURRENCY_DECIMAL_PLACES, CURRENCY_DECIMAL_POINT, CURRENCY_THOUSANDS_POINT) . BLANK . MODULE_SHIPPING_FEDEXEU_TEXT_UNITS . RPAREN);
     $this->quotes['methods'] = $methods;
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = olc_get_tax_rate($this->tax_class, $order_delivery_country['id'], $order->delivery['zone_id']);
     }
     if (olc_not_null($this->icon)) {
         $this->quotes['icon'] = olc_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = MODULE_SHIPPING_FEDEXEU_INVALID_ZONE;
     }
     if (olc_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;
 }
コード例 #16
0
require_once DIR_FS_INC . 'olc_format_price.inc.php';
$current_product_id = $_POST['current_product_id'];
// I found the easiest way to do this is just delete the current attributes & start over =)
olc_db_query(DELETE_FROM . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . $current_product_id . APOS);
// 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++) {
    $optionValues = $_POST['optionValues'][$i];
    $query = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_values_id = '" . $optionValues . APOS;
    $result = olc_db_query($query);
    $matches = olc_db_num_rows($result);
    while ($line = olc_db_fetch_array($result, olc_db_ASSOC)) {
        $optionsID = $line['products_options_id'];
    }
    $value_price = $_POST[$optionValues . '_price'];
    if (PRICE_IS_BRUTTO == TRUE_STRING_S) {
        $value_price = $value_price / (olc_get_tax_rate(olc_get_tax_class_id($current_product_id)) + 100) * 100;
    }
    $value_price = olc_round($value_price, PRICE_PRECISION);
    $value_prefix = $_POST[$optionValues . '_prefix'];
    $value_sortorder = $_POST[$optionValues . '_sortorder'];
    $value_weight_prefix = $_POST[$optionValues . '_weight_prefix'];
    $value_model = $_POST[$optionValues . '_model'];
    $value_stock = $_POST[$optionValues . '_stock'];
    $value_weight = $_POST[$optionValues . '_weight'];
    $insert_into = INSERT_INTO . TABLE_PRODUCTS_ATTRIBUTES . "(products_id,options_id,options_values_id,options_values_price,price_prefix" . COMMA;
    $comma_blank = "','";
    if ($optionTypeInstalled == '1') {
        $value_type = $_POST[$optionValues . '_type'];
        $value_qty = $_POST[$optionValues . '_qty'];
        $value_order = $_POST[$optionValues . '_order'];
        $value_linked = $_POST[$optionValues . '_linked'];
コード例 #17
0
while ($group_values = olc_db_fetch_array($group_query)) {
    // load data into array
    $i++;
    $group_data[$i] = array('STATUS_NAME' => $group_values['customers_status_name'], 'STATUS_IMAGE' => $group_values['customers_status_image'], 'STATUS_ID' => $group_values['customers_status_id']);
}
echo HTML_BR . '<span class="pageHeading">' . HEADING_PRICES_OPTIONS . '</span>';
?>
<table width="100%" border="0" class="table_bordered" style="border: 1px solid;">
          <tr>
            <td width="15%" class="main"><?php 
echo TEXT_PRODUCTS_PRICE;
?>
</td>
<?php 
// calculate brutto price for display
$tax_rate = (100 + olc_get_tax_rate($pInfo->products_tax_class_id)) / 100;
$is_brutto = PRICE_IS_BRUTTO == TRUE_STRING_S;
$products_price0 = olc_round($pInfo->products_price, PRICE_PRECISION);
$products_price = $products_price0;
if ($is_brutto) {
    $products_price = $products_price * $tax_rate;
}
//$products_price = olc_round($products_price,PRICE_PRECISION);
?>
            <td width="85%" class="main">
<?php 
echo olc_draw_input_field('products_price', str_replace(COMMA, DOT, $products_price));
if ($is_brutto) {
    echo BLANK . TEXT_NETTO . HTML_B_START . olc_format_price($products_price0, '1', '0', '1') . '</b>  ';
}
?>
コード例 #18
0
function olc_oe_products_price($products_id, $price_special, $quantity, $customer_status)
{
    $customers_status_query = olc_db_query("select * from " . TABLE_CUSTOMERS_STATUS . " where customers_status_id = '" . $customer_status . "' ");
    $customers_status = olc_db_fetch_array($customers_status_query);
    // check if customer is allowed to see prices (if not -> no price calculations , show error message)
    if ($customers_status[customers_status_show_price] == '1') {
        // load price data into array for further use!
        $product_price_query = olc_db_query("SELECT   products_price,\n\t\t\t\t\t\t\t\t\t\t\tproducts_discount_allowed,\n\t\t\t\t\t\t\t\t\t\t\tproducts_tax_class_id\n\t\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_PRODUCTS . " \n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\tproducts_id = '" . $products_id . APOS);
        $product_price = olc_db_fetch_array($product_price_query);
        $price_data = array();
        $price_data = array('PRODUCTS_PRICE' => $product_price['products_price'], 'PRODUCTS_DISCOUNT_ALLOWED' => $product_price['products_discount_allowed'], 'PRODUCT_TAX_CLASS_ID' => $product_price['products_tax_class_id']);
        // get tax rate for tax class
        $products_tax = olc_get_tax_rate($price_data['PRODUCT_TAX_CLASS_ID']);
        // check if user is allowed to see tax rates
        if ($customers_status['customers_status_show_price_tax'] == '0') {
            $products_tax = '';
        }
        // end $customers_status['customers_status_show_price_tax'] =='0'
        // check if special price is aviable for product (no product discount on special prices!)
        if ($special_price = olc_get_products_special_price($products_id)) {
            $special_price = olc_add_tax($special_price, $products_tax);
            $price_data['PRODUCTS_PRICE'] = olc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax);
            $price_string = olc_format_special_price($special_price, $price_data['PRODUCTS_PRICE'], $price_special, $calculate_currencies = true, $quantity, $products_tax);
        } else {
            // if ($special_price=olc_get_products_special_price($products_id))
            // Check if there is another price for customers_group (if not, take norm price and calculte discounts (NOTE: no discount on group PRICES(only OT DISCOUNT!)!
            $group_price_query = olc_db_query("SELECT personal_offer\n\t\t\t\t\t\t\t\t\t         FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $customers_status['customers_status_id'] . "\n\t\t\t\t\t\t\t\t\t         WHERE products_id='" . $products_id . APOS);
            $group_price_data = olc_db_fetch_array($group_price_query);
            // if we found a price, everything is ok if not, we will use normal price
            if ($group_price_data['personal_offer'] != '' and $group_price_data['personal_offer'] != '0.0000') {
                $price_string = $group_price_data['personal_offer'];
                // check if customer is allowed to get graduated prices
                if ($customers_status['customers_status_graduated_prices'] == '1') {
                    // check if there are graduated prices in db
                    // get quantity for products
                    // modifikations for new graduated prices
                    $qty = olc_get_qty($products_id);
                    if (!olc_get_qty($products_id)) {
                        $qty = $quantity;
                    }
                    $graduated_price_query = olc_db_query("SELECT max(quantity)\n\t\t\t\t\t\t\t\t\t                      FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $customers_status['customers_status_id'] . "\n\t\t\t\t\t\t\t\t\t                      WHERE products_id='" . $products_id . "'\n\t\t\t\t\t\t\t\t\t                      AND quantity<='" . $qty . APOS);
                    $graduated_price_data = olc_db_fetch_array($graduated_price_query);
                    // get singleprice
                    $graduated_price_query = olc_db_query("SELECT personal_offer\n\t\t\t\t\t                              FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $customers_status['customers_status_id'] . "\n\t\t\t\t\t\t\t\t\t                      WHERE products_id='" . $products_id . "'\n\t\t\t\t\t\t\t\t\t                      AND quantity='" . $graduated_price_data['max(quantity)'] . APOS);
                    $graduated_price_data = olc_db_fetch_array($graduated_price_query);
                    $price_string = $graduated_price_data['personal_offer'];
                }
                // end $_SESSION['customers_status']['customers_status_graduated_prices']=='1'
                $price_string = olc_add_tax($price_string, $products_tax);
                //*$quantity;
            } else {
                // if 	($group_price_data['personal_offer']!='' and $group_price_data['personal_offer']!='0.0000')
                $price_string = olc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax);
                //*$quantity;
                // check if product allows discount
                if ($price_data['PRODUCTS_DISCOUNT_ALLOWED'] != '0.00') {
                    $discount = $price_data['PRODUCTS_DISCOUNT_ALLOWED'];
                    // check if group discount > max. discount on product
                    if ($discount > $customers_status['customers_status_discount']) {
                        $discount = $customers_status['customers_status_discount'];
                    }
                    // calculate price with rabatt
                    $rabatt_string = $price_string - $price_string / 100 * $discount;
                    if ($price_string == $rabatt_string) {
                        $price_string = olc_format_price($price_string * $quantity, $price_special, $calculate_currencies = true);
                    } else {
                        $price_string = olc_format_special_price($rabatt_string, $price_string, $price_special, $calculate_currencies = false, $quantity, $products_tax);
                    }
                    return $price_string;
                    break;
                }
            }
            // format price & calculate currency
            if ($price_string == '0.00') {
                $price_string = TEXT_NO_PRICE;
            } else {
                $price_string = olc_format_price($price_string * $quantity, $price_special, $calculate_currencies = true);
            }
        }
    } else {
        // return message, if not allowed to see prices
        $price_string = NOT_ALLOWED_TO_SEE_PRICES;
    }
    // end ($customers_status['customers_status_show_price'] == '1')
    return $price_string;
}
コード例 #19
0
     $current_value_id_old = $current_value_id;
     $current_value_id = $tempTextID;
     echo '<input type="checkbox" name="optionValuesText[]" value="' . $current_value_id . '"' . $CHECKED . '>&nbsp;&nbsp;' . $current_value_name . '&nbsp;&nbsp;';
     echo '<input type="hidden" name="' . $current_value_id . '_options_id" value="' . $current_product_option_id . '">';
 } else {
     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_STRING_S) {
     $attribute_value_price_calculate = olc_format_price(olc_round($attribute_value_price * ((100 + olc_get_tax_rate(olc_get_tax_class_id($_POST['current_product_id']))) / 100), PRICE_PRECISION), false, false);
 } else {
     $attribute_value_price_calculate = olc_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_STRING_S) {
     echo TEXT_NETTO . HTML_B_START . olc_format_price(olc_round($attribute_value_price, PRICE_PRECISION), true, false) . '</b>  ';
 }
 echo "</td>";
 if ($optionTypeInstalled == '1') {
     extraValues($current_value_id, $_POST['current_product_id']);
     echo "<td class=\"main\" align=\"left\"><input type=\"text\" name=\"" . $current_value_id . "_prefix\" value=\"" . $attribute_prefix . "\" size=\"4\"></td>";
     echo "<td class=\"main\" align=\"left\"><select name=\"" . $current_value_id . "_type\">";
     displayOptionTypes($attribute_type);
     echo "</SELECT></td>";
コード例 #20
0
 function cart($customer_id = EMPTY_STRING)
 {
     global $currencies;
     if ($customer_id == EMPTY_STRING) {
         $customer_id = CUSTOMER_ID;
     }
     $this->content_type = $_SESSION['cart']->get_content_type();
     $customer_address_query = olc_db_query("\n\t\tselect\n\t\tc.customers_firstname,\n\t\tc.customers_cid,\n\t\tc.customers_gender,\n\t\tc.customers_lastname,\n\t\tc.customers_telephone,\n\t\tc.customers_email_address,\n\t\tc.customers_email_type,\n\t\tab.entry_company,\n\t\tab.entry_street_address,\n\t\tab.entry_suburb,\n\t\tab.entry_postcode,\n\t\tab.entry_city,\n\t\tab.entry_zone_id,\n\t\tab.entry_state,\n\t\tz.zone_name,\n\t\tco.countries_id,\n\t\tco.countries_name,\n\t\tco.countries_iso_code_2,\n\t\tco.countries_iso_code_3,\n\t\tco.address_format_id\n\t\tfrom " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab\n\t\tleft join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\t\tleft join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id)\n\t\twhere\n\t\tc.customers_id = '" . $customer_id . "'\n\t\tand ab.customers_id = '" . $customer_id . "'\n\t\tand c.customers_default_address_id = ab.address_book_id");
     $customer_address = olc_db_fetch_array($customer_address_query);
     $shipping_address_query = olc_db_query("\n\t\tselect\n\t\tab.entry_firstname,\n\t\tab.entry_lastname,\n\t\tab.entry_company,\n\t\tab.entry_street_address,\n\t\tab.entry_suburb,\n\t\tab.entry_postcode,\n\t\tab.entry_city,\n\t\tab.entry_zone_id,\n\t\tab.entry_country_id,\n\t\tab.entry_state,\n\t\tz.zone_name,\n\t\tc.countries_id,\n\t\tc.countries_name,\n\t\tc.countries_iso_code_2,\n\t\tc.countries_iso_code_3,\n\t\tc.address_format_id\n\t\tfrom " . TABLE_ADDRESS_BOOK . " ab\n\t\tleft join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\t\tleft join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id)\n\t\twhere\n\t\tab.customers_id = '" . $customer_id . "'\n\t\tand ab.address_book_id = '" . $_SESSION['sendto'] . APOS);
     $shipping_address = olc_db_fetch_array($shipping_address_query);
     $billing_address_query = olc_db_query("\n\t\tselect\n\t\tab.entry_firstname,\n\t\tab.entry_lastname,\n\t\tab.entry_company,\n\t\tab.entry_street_address,\n\t\tab.entry_suburb,\n\t\tab.entry_postcode,\n\t\tab.entry_city,\n\t\tab.entry_zone_id,\n\t\tab.entry_state,\n\t\tab.entry_country_id,\n\t\tz.zone_name,\n\t\tc.countries_id,\n\t\tc.countries_name,\n\t\tc.countries_iso_code_2,\n\t\tc.countries_iso_code_3,\n\t\tc.address_format_id\n\t\tfrom " . TABLE_ADDRESS_BOOK . " ab\n\t\tleft join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\t\tleft join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id)\n\t\twhere ab.customers_id = '" . $customer_id . "'\n\t\tand ab.address_book_id = '" . $_SESSION['billto'] . APOS);
     $billing_address = olc_db_fetch_array($billing_address_query);
     $tax_address_query = olc_db_query("\n\t\tselect\n\t\tab.entry_country_id,\n\t\tab.entry_zone_id\n\t\tfrom " . TABLE_ADDRESS_BOOK . " ab\n\t\tleft join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\t\twhere ab.customers_id = '" . $_SESSION['$customer_id'] . "' and ab.address_book_id = '" . ($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . APOS);
     $tax_address = olc_db_fetch_array($tax_address_query);
     $shipping = $_SESSION['shipping'];
     $shipping_class = $shipping['id'];
     //$shipping_class=$shipping['id'];
     $pos = strpos($shipping_class, UNDERSCORE);
     if ($pos > 0) {
         $shipping_class = substr($shipping_class, 0, $pos);
     }
     $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $_SESSION['currency'], 'currency_value' => $currencies->currencies[$_SESSION['currency']]['value'], 'payment_method' => $_SESSION['payment'], 'cc_type' => $GLOBALS['cc_type'], 'cc_owner' => $GLOBALS['cc_owner'], 'cc_number' => $GLOBALS['cc_number'], 'cc_expires' => $GLOBALS['cc_expires'], 'cc_start' => $GLOBALS['cc_start'], 'cc_issue' => $GLOBALS['cc_issue'], 'cc_cvv' => $GLOBALS['cc_cvv'], 'shipping_class' => $shipping_class, 'shipping_method' => $shipping['title'], 'shipping_cost' => $shipping['cost'], 'comments' => $_SESSION['comments'], 'payment_class' => $_SESSION['payment'], 'customers_order_reference' => $_SESSION['customers_order_reference']);
     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('firstname' => $customer_address['customers_firstname'], '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' => olc_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'], 'email_address' => $customer_address['customers_email_address'], 'email_type' => $customer_address['customers_email_type']);
     $this->delivery = array('firstname' => $shipping_address['entry_firstname'], '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' => olc_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'], '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' => olc_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;
     $tax_country = $tax_address['entry_country_id'];
     $tax_zone = $tax_address['entry_zone_id'];
     $products = $_SESSION['cart']->get_products();
     for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
         $product = $products[$i];
         $quantity = $product['quantity'];
         $products_id = $product['id'];
         $price = olc_get_products_price($products_id, $price_special = 0, $quantity, $price_real);
         $price = abs($price_real);
         $products_attributes = $product['attributes'];
         if ($products_attributes) {
             $attributes_price = $_SESSION['cart']->attributes_price($products_id);
             if ((double) $attributes_price != 0) {
                 $attributes_price = olc_get_products_attribute_price_checkout($attributes_price, 0, 0, 1, EMPTY_STRING, false);
                 $price += $attributes_price;
             }
         }
         $final_price = $price * $quantity;
         $tax_class = $product['tax_class_id'];
         $this->products[$index] = array('qty' => $quantity, 'name' => $product['name'], 'model' => $product['model'], 'tax' => olc_get_tax_rate($tax_class, $tax_country, $tax_zone), 'tax_description' => olc_get_tax_description($tax_class, $tax_country, $tax_zone), 'price' => $price, 'final_price' => $final_price, 'weight' => $product['weight'], 'id' => $products_id, 'auctionid' => $product['auctionid']);
         if ($products_attributes) {
             $subindex = 0;
             reset($products_attributes);
             while (list($option, $value) = each($products_attributes)) {
                 $attributes_query = olc_db_query("\n\t\t\t\t\tselect\n\t\t\t\t\tpopt.products_options_name,\n\t\t\t\t\tpoval.products_options_values_name,\n\t\t\t\t\tpa.options_values_price,\n\t\t\t\t\tpa.price_prefix\n\t\t\t\t\tfrom " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\t\t\t\t\twhere\n\t\t\t\t\tpa.products_id = '" . $products_id . "' and pa.options_id = '" . $option . "'\n\t\t\t\t\tand pa.options_id = popt.products_options_id\n\t\t\t\t\tand pa.options_values_id = '" . $value . "'\n\t\t\t\t\tand pa.options_values_id = poval.products_options_values_id\n\t\t\t\t\tand popt.language_id = '" . SESSION_LANGUAGE_ID . "'\n\t\t\t\t\tand poval.language_id = '" . SESSION_LANGUAGE_ID . APOS);
                 $attributes = olc_db_fetch_array($attributes_query);
                 $attributes_price = $attributes['options_values_price'];
                 if ($attributes_price > 0) {
                     $attributes_price_prefix = $attributes['price_prefix'];
                 } else {
                     $attributes_price_prefix = EMPTY_STRING;
                 }
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'], 'value' => $attributes['products_options_values_name'], 'option_id' => $option, 'value_id' => $value, 'prefix' => $attributes['price_prefix'], 'price' => $attributes_price);
                 $subindex++;
             }
         }
         $subtotal += $final_price;
         $shown_price = $final_price;
         if (CUSTOMER_SHOW_OT_DISCOUNT) {
             $shown_price_tax = $shown_price - $shown_price / 100 * CUSTOMER_OT_DISCOUNT;
         }
         $products_tax = $this->products[$index]['tax'];
         $products_tax_description = $this->products[$index]['tax_description'];
         if (CUSTOMER_SHOW_PRICE_TAX) {
             if (CUSTOMER_SHOW_OT_DISCOUNT) {
                 $shown_price = $shown_price_tax;
             }
             $products_tax_1 = str_replace(DOT, EMPTY_STRING, $products_tax);
             $products_tax_1 = $products_tax < 10 ? "1.0" . $products_tax_1 : "1." . $products_tax_1;
             $this->info['tax'] += $shown_price - $shown_price / $products_tax_1;
             $this->info['tax_groups'][TAX_ADD_TAX . "{$products_tax_description}"] += $shown_price / (100 + $products_tax) * $products_tax;
         } else {
             if (CUSTOMER_SHOW_OT_DISCOUNT) {
                 $shown_price = $shown_price_tax;
             }
             $shown_price = $shown_price / 100 * $products_tax;
             $this->info['tax'] += $shown_price;
             $this->info['tax_groups'][TAX_NO_TAX . $products_tax_description] += $shown_price;
         }
         $index++;
     }
     $this->info['subtotal'] = $subtotal;
     $this->info['total'] = $subtotal + $this->info['shipping_cost'];
     if (CUSTOMER_SHOW_OT_DISCOUNT) {
         $discount = $subtotal * (CUSTOMER_OT_DISCOUNT / 100);
         $this->info['total'] -= $discount;
         $this->info['orders_discount'] = $discount;
     }
 }
コード例 #21
0
 function get_products($use_saved_cart = false)
 {
     if (!is_array($this->contents)) {
         return false;
     }
     //if product is an auction
     $sql0 = SELECT . "\n\t\t\tp.products_id,\n\t\t\tpd.products_name,\n\t\t\tp.products_image,\n\t\t\tp.products_model,\n\t\t\tp.products_min_order_quantity,\n\t\t\tp.products_weight,\n\t\t\tp.products_uvp,\n\t\t\tp.products_tax_class_id,";
     $from = "\n\t\tfrom " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd";
     $where = "\n\t\twhere\n\t\t\tp.products_id = '#' and\n\t\t\tpd.products_id = p.products_id and\n\t\t\tpd.language_id = '" . SESSION_LANGUAGE_ID . APOS;
     //query: also select for auctionid -
     //there might be more than one auction from the same product (same productid) with different prices
     $auction_trailer = "\n\t\tad.auction_endprice" . $from . ", " . TABLE_AUCTION_DETAILS . " ad, " . TABLE_AUCTION_LIST . " al" . $where . "\n\t\tAND ad.auction_id = al.auction_id\n\t\tAND al.product_id=p.products_id\n\t\tAND\tal.auction_id = '" . ATSIGN . APOS;
     //normal shopproduct - normal select
     $normal_trailer = "\n\t\tp.products_price" . $from . $where;
     $sql0_normal = $sql0 . $normal_trailer;
     $sql0_auction = $sql0 . $auction_trailer;
     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $auctionid = $this->contents[$products_id][AUCTION_ID_TEXT];
         if ($auctionid) {
             $sql = str_replace(ATSIGN, $auctionid, $sql0_auction);
         } else {
             $sql = $sql0_normal;
         }
         $sql = str_replace(HASH, olc_get_prid($products_id), $sql);
         $products_query = olc_db_query($sql);
         if ($product = olc_db_fetch_array($products_query)) {
             $product_tax_class_id = $product['products_tax_class_id'];
             //if auction - get right excl. tax price
             if ($auctionid) {
                 //auctionprice is incl. tax - so you have to get the price without tax (because in cart it automatically added)
                 $product_price = $product['auction_endprice'];
                 $product_tax = olc_get_tax_rate($product_tax_class_id);
                 if ($product_tax) {
                     $product_price = $product_price / (1 + $product_tax / 100);
                 }
             } else {
                 //normal price - normal shopproduct
                 $product_price = $product['products_price'];
             }
             //$product_price = abs(olc_get_products_price($products_id, $price_special=0, $quantity=1,$price_real));
             $product_price = olc_get_products_price($products_id, $price_special = 0, $quantity = 1, $price_real);
             $product_price = abs($price_real);
             $products_array[] = array('id' => $products_id, AUCTION_ID_TEXT => $auctionid, 'name' => $product['products_name'], 'model' => $product['products_model'], 'image' => $product['products_image'], 'price' => $product_price, 'discount_allowed' => $max_product_discount, 'quantity' => $this->contents[$products_id]['qty'], 'min_quantity' => $product['products_min_order_quantity'], 'weight' => $product['products_weight'], 'final_price' => $product_price + $this->attributes_price($products_id), 'tax_class_id' => $products_tax_class_id, 'attributes' => $this->contents[$products_id]['attributes']);
         }
     }
     return $products_array;
 }
コード例 #22
0
ファイル: olc.inc.php プロジェクト: severnaya99/Sg-2010
function tep_get_tax_rate($x, $y = -1, $z = -1)
{
    return olc_get_tax_rate($x, $y, $z);
}
コード例 #23
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 = olc_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . olc_get_prid($products_id) . APOS);
         if ($product = olc_db_fetch_array($product_query)) {
             $prid = $product['products_id'];
             $products_tax = olc_get_tax_rate($product['products_tax_class_id']);
             $products_price = $product['products_price'];
             $products_weight = $product['products_weight'];
             $specials_query = olc_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'");
             if (olc_db_num_rows($specials_query)) {
                 $specials = olc_db_fetch_array($specials_query);
                 $products_price = $specials['specials_new_products_price'];
             }
             $this->total += olc_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 = olc_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 . APOS);
                 $attribute_price = olc_db_fetch_array($attribute_price_query);
                 if ($attribute_price['price_prefix'] == '+') {
                     $this->total += $qty * olc_add_tax($attribute_price['options_values_price'], $products_tax);
                 } else {
                     $this->total -= $qty * olc_add_tax($attribute_price['options_values_price'], $products_tax);
                 }
             }
         }
     }
 }
コード例 #24
0
 function calculate_tax_deduction($amount, $od_amount, $method)
 {
     global $order;
     switch ($method) {
         case 'Standard':
             $ratio1 = olc_round($od_amount / $amount, 2);
             $tod_amount = 0;
             reset($order->info['tax_groups']);
             while (list($key, $value) = each($order->info['tax_groups'])) {
                 $tax_rate = olc_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 = olc_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 = olc_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
             $tax_desc = olc_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;
 }
コード例 #25
0
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     if (!$order) {
         $order = new order();
     }
     if (!$shipping_weight) {
         $shipping_weight = $_SESSION['cart']->show_weight();
     }
     $order_delivery_country = $order->delivery['country'];
     $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 = 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 = 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 = 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 = 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 = 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 = 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 . LPAREN . $shipping_num_boxes . ' x ' . $shipping_weight . BLANK . MODULE_SHIPPING_DHL_TEXT_UNITS . RPAREN);
     $this->quotes['methods'] = $methods;
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = olc_get_tax_rate($this->tax_class, $order_delivery_country['id'], $order->delivery['zone_id']);
     }
     if (olc_not_null($this->icon)) {
         $this->quotes['icon'] = olc_image($this->icon, $this->title);
     }
     if ($error == true) {
         $this->quotes['error'] = MODULE_SHIPPING_DHL_INVALID_ZONE;
     }
     if (olc_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;
 }
コード例 #26
0
 function get_order_total()
 {
     global $order, $olPrice;
     $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
     $shipping_tax = olc_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
         $order_total = $order->info['tax'] + $order->info['total'];
     }
     if ($_SESSION['customers_status']['customers_status_show_price_tax'] != 0) {
         $order_total = $order->info['total'];
     }
     if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) {
         $order_total = $order->info['total'];
     }
     // Check if gift voucher is in cart and adjust total
     $products = $_SESSION['cart']->get_products();
     for ($i = 0; $i < sizeof($products); $i++) {
         $t_prid = olc_get_prid($products[$i]['id']);
         $gv_query = olc_db_query("select products_price, products_tax_class_id, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . APOS);
         $gv_result = olc_db_fetch_array($gv_query);
         if (ereg('^GIFT', addslashes($gv_result['products_model']))) {
             $qty = $_SESSION['cart']->get_quantity($t_prid);
             $products_tax = $olPrice->TAX[$gv_result['products_tax_class_id']];
             if ($this->include_tax == FALSE_STRING_S) {
                 $gv_amount = $gv_result['products_price'] * $qty;
             } else {
                 $gv_amount = ($gv_result['products_price'] + $olPrice->calcTax($gv_result['products_price'], $products_tax)) * $qty;
             }
             $order_total = $order_total - $gv_amount;
         }
     }
     if ($this->include_tax == FALSE_STRING_S && !($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0)) {
         $order_total = $order_total - $order->info['tax'];
     }
     if ($this->include_shipping == FALSE_STRING_S) {
         $order_total = $order_total - $order->info['shipping_cost'];
         if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
             $order_total += $order->info['shipping_cost'] / (100 + $shipping_tax) * $shipping_tax;
         }
     }
     // OK thats fine for global coupons but what about restricted coupons
     // where you can only redeem against certain products/categories.
     // and I though this was going to be easy !!!
     $coupon_query = olc_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id='" . $_SESSION['cc_id'] . APOS);
     if (olc_db_num_rows($coupon_query) != 0) {
         $coupon_result = olc_db_fetch_array($coupon_query);
         $coupon_get = olc_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'] . APOS);
         $get_result = olc_db_fetch_array($coupon_get);
         $in_cat = false;
         $in_cart = false;
         if ($get_result['restrict_to_categories']) {
             $cat_ids = split("[,]", $get_result['restrict_to_categories']);
             for ($i = 0; $i < count($cat_ids); $i++) {
                 if (is_array($_SESSION['cart']->contents)) {
                     reset($_SESSION['cart']->contents);
                     while (list($products_id, ) = each($_SESSION['cart']->contents)) {
                         $cat_query = olc_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $products_id . "' and categories_id = '" . $cat_ids[$i] . APOS);
                         if (olc_db_num_rows($cat_query) != 0 && stristr($pr_in_cat, olc_get_prid($products_id)) === FALSE) {
                             $in_cat = true;
                             $pr_in_cat .= ',' . $products_id;
                             $total_price += $this->get_product_price($products_id);
                         }
                     }
                 }
             }
         }
         if ($get_result['restrict_to_products']) {
             $pr_ids = split("[,]", $get_result['restrict_to_products']);
             $products_array = $_SESSION['cart']->get_products();
             for ($i = 0; $i < sizeof($pr_ids); $i++) {
                 for ($ii = 1; $ii <= sizeof($products_array); $ii++) {
                     if (olc_get_prid($products_array[$ii - 1]['id']) == $pr_ids[$i] && stristr($pr_in_cat, olc_get_prid($products_array[$ii - 1]['id'])) === FALSE) {
                         $in_cart = true;
                         $total_price += $this->get_product_price($products_array[$ii - 1]['id']);
                     }
                 }
             }
         }
         if ($in_cat || $in_cart) {
             if ($this->include_shipping == TRUE_STRING_S) {
                 if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
                     if ($this->include_tax == FALSE_STRING_S) {
                         $total_price += $order->info['shipping_cost'];
                     } else {
                         $total_price += olc_add_tax($order->info['shipping_cost'], $shipping_tax);
                         // original code         $total_price += $order->info['shipping_cost'] = olc_add_tax($order->info['shipping_cost'], $shipping_tax);
                     }
                 } else {
                     if ($this->include_tax == FALSE_STRING_S) {
                         $total_price += $order->info['shipping_cost'];
                         if (!($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0)) {
                             $total_price -= $order->info['shipping_cost'] / (100 + $shipping_tax) * $shipping_tax;
                         }
                     } else {
                         $total_price += $order->info['shipping_cost'];
                     }
                 }
             }
             if ($total_price > $order_total) {
                 $total_price = $order_total;
             }
             $order_total = $total_price;
         }
     }
     return $order_total;
 }
コード例 #27
0
                      <td class="dataTableContent"><?php 
        echo $PRODUCTS_id[0];
        ?>
</td>
                      <!--// Adam@CP: Added Model Number and image thumbnail. -->
                      <td class="dataTableContent"><?php 
        echo $PRODUCTS_model[0];
        ?>
</td>

                      <td class="dataTableContent"><?php 
        echo $PRODUCTS_name[0];
        ?>
</td>
                      <td class="dataTableContent"><?php 
        echo $currencies->display_price($PRODUCTS_price[0], olc_get_tax_rate($product_info_values['products_tax_class_id']));
        ?>
</td>
                      <td class="dataTableContent"><select name="<?php 
        echo $PRODUCTS_id[0];
        ?>
">
                          <?php 
        for ($y = 1; $y <= $ordering_size; $y++) {
            echo "<option value=\"{$y}\"";
            if (!strcmp($y, "{$order_PR[$i]}")) {
                echo "SELECTED";
            }
            echo ">{$y}</option>";
        }
        ?>
コード例 #28
0
 function quote()
 {
     global $order, $shipping_weight;
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_CHRONOPOST_TEXT_TITLE, 'methods' => array());
     if (!$order) {
         $order = new order();
     }
     if (!$shipping_weight) {
         $shipping_weight = $_SESSION['cart']->show_weight();
     }
     $order_delivery_country = $order->delivery['country'];
     $dest_country = $order_delivery_country['iso_code_2'];
     if (olc_not_null($this->icon)) {
         $this->quotes['icon'] = olc_image($this->icon, $this->title);
     }
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = olc_get_tax_rate($this->tax_class, $order_delivery_country['id'], $order->delivery['zone_id']);
     }
     $dest_zone = 0;
     for ($i = 1; $i <= $this->num_chronopost; $i++) {
         $countries_table = constant('MODULE_SHIPPING_CHRONOPOST_COUNTRIES_' . $i);
         $country = 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 = 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 . BLANK . $order_delivery_country['title'], 'cost' => $cost + MODULE_SHIPPING_CHRONOPOST_HANDLING + SHIPPING_HANDLING);
     return $this->quotes;
 }
コード例 #29
0
function olc_get_products_price($products_id, $price_special, $quantity, &$price_real)
{
    global $price_data;
    // check if customer is allowed to see prices (if not -> no price calculations , show error message)
    if (CUSTOMER_SHOW_PRICE) {
        // load price data into array for further use!
        $product_price_query = olc_db_query(SELECT . "\n\t  products_price,\n\t\tproducts_discount_allowed,\n\t\tproducts_tax_class_id\n\t\tFROM " . TABLE_PRODUCTS . "\n\t\tWHERE\n\t\tproducts_id = '" . $products_id . APOS);
        $product_price = olc_db_fetch_array($product_price_query);
        $price_real = $product_price['products_price'];
        $price_data = array('PRODUCTS_PRICE' => $price_real, 'PRODUCTS_UVP' => $price_uvp, 'PRODUCTS_DISCOUNT_ALLOWED' => $product_price['products_discount_allowed'], 'PRODUCT_TAX_CLASS_ID' => $product_price['products_tax_class_id']);
        // check if user is allowed to see tax rates
        if (CUSTOMER_SHOW_PRICE_TAX) {
            // get tax rate for tax class
            $products_tax = olc_get_tax_rate($price_data['PRODUCT_TAX_CLASS_ID']);
        } else {
            $products_tax = 0;
        }
        // end !CUSTOMER_SHOW_PRICE_TAX
        $price_data['PRODUCTS_TAX_VALUE'] = $products_tax . ' %';
        // check if special price is aviable for product (no product discount on special prices!)
        //W. Kaiser - AJAX
        $special_price = olc_get_products_special_price($products_id);
        if ($special_price) {
            //W. Kaiser - AJAX
            $special_price = olc_add_tax($special_price, $products_tax);
            $price = olc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax);
            $price_data['PRODUCTS_PRICE'] = $price;
            $price_string = olc_format_special_price($special_price, $price, $price_special, true, $quantity, $products_tax);
        } else {
            // if ($special_price=olc_get_products_special_price($products_id))
            // Check if there is another price for customers_group (if not, take norm price and calculte discounts (NOTE: no discount on group PRICES(only OT DISCOUNT!)!
            $table_personal_offers = TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . CUSTOMER_STATUS_ID;
            $group_price_query = olc_db_query(SELECT . "\n\t\t\tpersonal_offer\n      FROM " . $table_personal_offers . "\n      WHERE products_id='" . $products_id . APOS);
            $group_price_data = olc_db_fetch_array($group_price_query);
            // if we found a price, everything is ok. If not, we will use normal price
            if ($group_price_data['personal_offer'] and $group_price_data['personal_offer'] != '0.0000') {
                $price_string = $group_price_data['personal_offer'];
                // check if customer is allowed to get graduated prices
                if (CUSTOMER_SHOW_GRADUATED_PRICE) {
                    // check if there are graduated prices in db
                    // get quantity for products
                    // modifikations for new graduated prices
                    $qty = olc_get_qty($products_id);
                    if (!olc_get_qty($products_id)) {
                        $qty = $quantity;
                    }
                    $graduated_price_query = olc_db_query(SELECT . "\n\t\t\t\t\t\t\t\tmax(quantity)\n                FROM " . $table_personal_offers . "\n                WHERE products_id='" . $products_id . "'\n                AND quantity<='" . $qty . APOS);
                    $graduated_price_data = olc_db_fetch_array($graduated_price_query);
                    // get singleprice
                    $graduated_price_query = olc_db_query(SELECT . "\n\t\t\t\t\t\tpersonal_offer\n\t          FROM " . $table_personal_offers . "\n            WHERE products_id='" . $products_id . "'\n            AND quantity='" . $graduated_price_data['max(quantity)'] . APOS);
                    $graduated_price_data = olc_db_fetch_array($graduated_price_query);
                    $price_string = $graduated_price_data['personal_offer'];
                }
                $price_string = olc_add_tax($price_string, $products_tax);
                //*$quantity;
            } else {
                // if 	($group_price_data['personal_offer']!=EMPTY_STRING and $group_price_data['personal_offer']!='0.0000')
                $price_string = olc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax);
                //*$quantity;
                // check if product allows discount
                if ($price_data['PRODUCTS_DISCOUNT_ALLOWED'] != '0.00') {
                    $discount = $price_data['PRODUCTS_DISCOUNT_ALLOWED'];
                    // check if group discount > max. discount on product
                    if ($discount > CUSTOMER_DISCOUNT) {
                        $discount = CUSTOMER_DISCOUNT;
                    }
                    // calculate price with rabatt
                    $rabatt_string = $price_string - $price_string / 100 * $discount;
                    if ($price_string == $rabatt_string) {
                        $price_string = olc_format_price($price_string * $quantity, $price_special, true);
                    } else {
                        $price_string = olc_format_special_price($rabatt_string, $price_string, $price_special, false, $quantity, $products_tax);
                    }
                    return $price_string;
                    break;
                }
            }
            // format price & calculate currency
            $price_string = olc_format_price($price_string * $quantity, $price_special, $calculate_currencies = true);
        }
    } else {
        // return message, if not allowed to see prices
        $price_string = NOT_ALLOWED_TO_SEE_PRICES;
    }
    return $price_string;
}
コード例 #30
0
function SendProducts()
{
    global $_GET, $LangID;
    if (defined('SET_TIME_LIMIT')) {
        @set_time_limit(0);
    }
    $schema = '<?xml version="1.0" encoding="' . CHARSET . '"?>' . "\n" . '<PRODUCTS>' . "\n";
    $sql = "select products_id,products_fsk18, products_quantity, products_model, products_image, products_price, " . "products_date_added, products_last_modified, products_date_available, products_weight, " . "products_status, products_tax_class_id, manufacturers_id, products_ordered from " . TABLE_PRODUCTS;
    $from = olc_db_prepare_input($_GET['products_from']);
    $anz = olc_db_prepare_input($_GET['products_count']);
    if (isset($from)) {
        if (!isset($anz)) {
            $anz = 1000;
        }
        $sql .= " limit " . $from . "," . $anz;
    }
    $orders_query = olc_db_query($sql);
    //W. Kaiser
    require_once DIR_FS_INC . 'olc_image.inc.php';
    require_once DIR_FS_INC . 'olc_get_customers_statuses.inc.php';
    $http_catalog = HTTP_SERVER . DIR_WS_CATALOG;
    $deep_link = $http_catalog . $olc_filename['product_info'] . '?products_id=';
    while ($products = olc_db_fetch_array($orders_query)) {
        $products_image = $products['products_image'];
        $products_id = $products['products_id'];
        $schema .= '<PRODUCT_INFO>' . "\n" . '<PRODUCT_DATA>' . "\n" . '<PRODUCT_ID>' . $products_id . '</PRODUCT_ID>' . "\n" . '<PRODUCT_DEEPLINK>' . $deep_link . $products_id . '</PRODUCT_DEEPLINK>' . "\n" . '<PRODUCT_QUANTITY>' . $products['products_quantity'] . '</PRODUCT_QUANTITY>' . "\n" . '<PRODUCT_MODEL>' . htmlspecialchars($products['products_model']) . '</PRODUCT_MODEL>' . "\n" . '<PRODUCT_FSK18>' . htmlspecialchars($products['products_fsk18']) . '</PRODUCT_FSK18>' . "\n" . '<PRODUCT_IMAGE>' . htmlspecialchars($products_image) . '</PRODUCT_IMAGE>' . "\n";
        if ($products_image) {
            //W. Kaiser - pictures-on-the-fly
            /*
            $schema .=
            '<PRODUCT_IMAGE_POPUP>'.
            $http_catalog.DIR_WS_POPUP_IMAGES.$products_image.
            '</PRODUCT_IMAGE_POPUP>'. "\n" .
            '<PRODUCT_IMAGE_SMALL>'.
            $http_catalog.DIR_WS_INFO_IMAGES.$products_image.
            '</PRODUCT_IMAGE_SMALL>'. "\n" .
            '<PRODUCT_IMAGE_THUMBNAIL>'.
            $http_catalog.DIR_WS_THUMBNAIL_IMAGES.$products_image.
            '</PRODUCT_IMAGE_THUMBNAIL>'. "\n" .
            '<PRODUCT_IMAGE_ORIGINAL>'.
            $http_catalog.DIR_WS_ORIGINAL_IMAGES.$products_image.
            '</PRODUCT_IMAGE_ORIGINAL>'. "\n";
            */
            $schema .= '<PRODUCT_IMAGE_ORIGINAL>' . olc_image($http_catalog . DIR_WS_ORIGINAL_IMAGES . $products_image) . '</PRODUCT_IMAGE_ORIGINAL>' . "\n" . '<PRODUCT_IMAGE_SMALL>' . olc_image($http_catalog . DIR_WS_INFO_IMAGES . $products_image) . '</PRODUCT_IMAGE_SMALL>' . "\n" . '<PRODUCT_IMAGE_POPUP>' . olc_image($http_catalog . DIR_WS_POPUP_IMAGES . $products_image) . '</PRODUCT_IMAGE_POPUP>' . "\n" . '<PRODUCT_IMAGE_THUMBNAIL>' . olc_image($http_catalog . DIR_WS_THUMBNAIL_IMAGES . $products_image) . '</PRODUCT_IMAGE_THUMBNAIL>' . "\n";
            //W. Kaiser - pictures-on-the-fly
        }
        $schema .= '<PRODUCT_PRICE>' . $products['products_price'] . '</PRODUCT_PRICE>' . "\n";
        /* Wird von CAO derzeit nicht verwendet !!! */
        $customers_status = olc_get_customers_statuses();
        for ($i = 1, $n = sizeof($customers_status); $i < $n; $i++) {
            if ($customers_status[$i]['id'] != 0) {
                $schema .= "<PRODUCT_GROUP_PRICES ID='" . $customers_status[$i]['id'] . "' NAME='" . $customers_status[$i]['text'] . "'>" . "\n";
                $group_price_query = olc_db_query("SELECT * FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $customers_status[$i]['id'] . " WHERE products_id='" . $products_id . "'");
                while ($group_price_data = olc_db_fetch_array($group_price_query)) {
                    //if ($group_price_data['personal_offer']!='0')
                    //{
                    $schema .= '<PRICE_ID>' . $group_price_data['price_id'] . '</PRICE_ID>';
                    $schema .= '<PRODUCT_ID>' . $group_price_data['products_id'] . '</PRODUCT_ID>';
                    $schema .= '<QTY>' . $group_price_data['quantity'] . '</QTY>';
                    $schema .= '<PRICE>' . $group_price_data['personal_offer'] . '</PRICE>';
                    //}
                }
                $schema .= "</PRODUCT_GROUP_PRICES>\n";
            }
        }
        // products Options
        //W. Kaiser
        $products_attributes = '';
        $products_options_data = array();
        $products_options_array = array();
        $products_attributes_query = olc_db_query("select count(*) as total\n                                               from " . TABLE_PRODUCTS_OPTIONS . "\n                                               popt, " . TABLE_PRODUCTS_ATTRIBUTES . "\n                                               patrib where\n                                               patrib.products_id='" . $products['products_id'] . "'\n                                               and patrib.options_id = popt.products_options_id\n                                               and popt.language_id = '" . $LangID . "'");
        $products_attributes = olc_db_fetch_array($products_attributes_query);
        if ($products_attributes['total'] > 0) {
            $products_options_name_query = olc_db_query("select distinct\n                                                   popt.products_options_id,\n                                                   popt.products_options_name\n                                                   from " . TABLE_PRODUCTS_OPTIONS . "\n                                                   popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib\n                                                   where patrib.products_id='" . $products['products_id'] . "'\n                                                   and patrib.options_id = popt.products_options_id\n                                                   and popt.language_id = '" . $LangID . "' order by popt.products_options_name");
            $row = 0;
            $col = 0;
            $products_options_data = array();
            while ($products_options_name = olc_db_fetch_array($products_options_name_query)) {
                $selected = 0;
                $products_options_array = array();
                $products_options_data[$row] = array('NAME' => $products_options_name['products_options_name'], 'ID' => $products_options_name['products_options_id'], 'DATA' => '');
                $products_options_query = olc_db_query("select\n                                                 pov.products_options_values_id,\n                                                 pov.products_options_values_name,\n                                                 pa.attributes_model,\n                                                 pa.options_values_price,\n                                                 pa.options_values_weight,\n                                                 pa.price_prefix,\n                                                 pa.weight_prefix,\n                                                 pa.attributes_stock,\n                                                 pa.attributes_model\n                                                from " . TABLE_PRODUCTS_ATTRIBUTES . "\n                                                 pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . "\n                                                 pov\n                                                where\n                                                 pa.products_id = '" . $products['products_id'] . "'\n                                                 and pa.options_id = '" . $products_options_name['products_options_id'] . "' and\n                                                 pa.options_values_id = pov.products_options_values_id and\n                                                 pov.language_id = '" . $LangID . "'\n                                                order by pov.products_options_values_name");
                $col = 0;
                while ($products_options = olc_db_fetch_array($products_options_query)) {
                    $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
                    if ($products_options['options_values_price'] != '0') {
                        $products_options_array[sizeof($products_options_array) - 1]['text'] .= ' ' . $products_options['price_prefix'] . ' ' . $products_options['options_values_price'] . ' ' . $_SESSION['currency'];
                    }
                    $price = '';
                    $products_options_data[$row]['DATA'][$col] = array('ID' => $products_options['products_options_values_id'], 'TEXT' => $products_options['products_options_values_name'], 'MODEL' => $products_options['attributes_model'], 'WEIGHT' => $products_options['options_values_weight'], 'PRICE' => $products_options['options_values_price'], 'WEIGHT_PREFIX' => $products_options['weight_prefix'], 'PREFIX' => $products_options['price_prefix']);
                    $col++;
                }
                $row++;
            }
        }
        if (sizeof($products_options_data) != 0) {
            for ($i = 0, $n = sizeof($products_options_data); $i < $n; $i++) {
                $schema .= "<PRODUCT_ATTRIBUTES NAME='" . $products_options_data[$i]['NAME'] . "'>";
                for ($ii = 0, $nn = sizeof($products_options_data[$i]['DATA']); $ii < $nn; $ii++) {
                    $schema .= '<OPTION>';
                    $schema .= '<ID>' . $products_options_data[$i]['DATA'][$ii]['ID'] . '</ID>';
                    $schema .= '<MODEL>' . $products_options_data[$i]['DATA'][$ii]['MODEL'] . '</MODEL>';
                    $schema .= '<TEXT>' . $products_options_data[$i]['DATA'][$ii]['TEXT'] . '</TEXT>';
                    $schema .= '<WEIGHT>' . $products_options_data[$i]['DATA'][$ii]['WEIGHT'] . '</WEIGHT>';
                    $schema .= '<PRICE>' . $products_options_data[$i]['DATA'][$ii]['PRICE'] . '</PRICE>';
                    $schema .= '<WEIGHT_PREFIX>' . $products_options_data[$i]['DATA'][$ii]['WEIGHT_PREFIX'] . '</WEIGHT_PREFIX>';
                    $schema .= '<PREFIX>' . $products_options_data[$i]['DATA'][$ii]['PREFIX'] . '</PREFIX>';
                    $schema .= '</OPTION>';
                }
                $schema .= '</PRODUCT_ATTRIBUTES>';
            }
        }
        /* End Wird zur Zeit nicht verwendet */
        require_once DIR_FS_INC . 'olc_get_tax_rate.inc.php';
        if (SWITCH_MWST == 'true') {
            // switch IDs
            if ($products['products_tax_class_id'] == 1) {
                $products['products_tax_class_id'] = 2;
            } else {
                if ($products['products_tax_class_id'] == 2) {
                    $products['products_tax_class_id'] = 1;
                }
            }
        }
        $schema .= '<PRODUCT_WEIGHT>' . $products['products_weight'] . '</PRODUCT_WEIGHT>' . "\n" . '<PRODUCT_STATUS>' . $products['products_status'] . '</PRODUCT_STATUS>' . "\n" . '<PRODUCT_TAX_CLASS_ID>' . $products['products_tax_class_id'] . '</PRODUCT_TAX_CLASS_ID>' . "\n" . '<PRODUCT_TAX_RATE>' . olc_get_tax_rate($products['products_tax_class_id']) . '</PRODUCT_TAX_RATE>' . "\n" . '<MANUFACTURERS_ID>' . $products['manufacturers_id'] . '</MANUFACTURERS_ID>' . "\n" . '<PRODUCT_DATE_ADDED>' . $products['products_date_added'] . '</PRODUCT_DATE_ADDED>' . "\n" . '<PRODUCT_LAST_MODIFIED>' . $products['products_last_modified'] . '</PRODUCT_LAST_MODIFIED>' . "\n" . '<PRODUCT_DATE_AVAILABLE>' . $products['products_date_available'] . '</PRODUCT_DATE_AVAILABLE>' . "\n" . '<PRODUCTS_ORDERED>' . $products['products_ordered'] . '</PRODUCTS_ORDERED>' . "\n";
        /* Wird von CAO derzeit nicht verwendet !!! */
        $categories_query = olc_db_query("SELECT\n                                     categories_id\n                                    FROM " . TABLE_PRODUCTS_TO_CATEGORIES . "\n                                     where products_id='" . $products['products_id'] . "'");
        $categories = array();
        while ($categories_data = olc_db_fetch_array($categories_query)) {
            $categories[] = $categories_data['categories_id'];
        }
        $categories = implode(',', $categories);
        $schema .= '<PRODUCTS_CATEGORIES>' . $categories . '</PRODUCTS_CATEGORIES>' . "\n";
        /* Ende Wird zur Zeit nicht verwendet */
        $detail_query = olc_db_query("select\n                                   products_id,\n                                   language_id,\n                                   products_name, " . TABLE_PRODUCTS_DESCRIPTION . ".products_description,\n                                   products_short_description,\n                                   products_meta_title,\n                                   products_meta_description,\n                                   products_meta_keywords,\n                                   products_url,\n                                   name as language_name, code as language_code " . "from " . TABLE_PRODUCTS_DESCRIPTION . ", " . TABLE_LANGUAGES . " " . "where " . TABLE_PRODUCTS_DESCRIPTION . ".language_id=" . TABLE_LANGUAGES . ".languages_id " . "and " . TABLE_PRODUCTS_DESCRIPTION . ".products_id=" . $products['products_id']);
        while ($details = olc_db_fetch_array($detail_query)) {
            $schema .= "<PRODUCT_DESCRIPTION ID='" . $details["language_id"] . "' CODE='" . $details["language_code"] . "' NAME='" . $details["language_name"] . "'>\n";
            if ($details["products_name"] != 'Array') {
                $schema .= "<NAME>" . htmlspecialchars($details["products_name"]) . "</NAME>" . "\n";
            }
            $schema .= "<URL>" . htmlspecialchars($details["products_url"]) . "</URL>" . "\n";
            $prod_details = $details["products_description"];
            if ($prod_details != 'Array') {
                $schema .= "<DESCRIPTION>" . htmlspecialchars($details["products_description"]) . "</DESCRIPTION>" . "\n";
                $schema .= "<SHORT_DESCRIPTION>" . htmlspecialchars($details["products_short_description"]) . "</SHORT_DESCRIPTION>" . "\n";
                $schema .= "<META_TITLE>" . htmlspecialchars($details["products_meta_title"]) . "</META_TITLE>" . "\n";
                $schema .= "<META_DESCRIPTION>" . htmlspecialchars($details["products_meta_description"]) . "</META_DESCRIPTION>" . "\n";
                $schema .= "<META_KEYWORDS>" . htmlspecialchars($details["products_meta_keywords"]) . "</META_KEYWORDS>" . "\n";
            }
            $schema .= "</PRODUCT_DESCRIPTION>\n";
        }
        // NEU JP 26.08.2005 Aktionspreise exportieren
        $special_query = "SELECT * from " . TABLE_SPECIALS . " " . "where products_id=" . $products['products_id'] . " limit 0,1";
        $special_result = olc_db_query($special_query);
        while ($specials = olc_db_fetch_array($special_result)) {
            $schema .= '<SPECIAL>' . "\n" . '<SPECIAL_PRICE>' . $specials['specials_new_products_price'] . '</SPECIAL_PRICE>' . "\n" . '<SPECIAL_DATE_ADDED>' . $specials['specials_date_added'] . '</SPECIAL_DATE_ADDED>' . "\n" . '<SPECIAL_LAST_MODIFIED>' . $specials['specials_last_modified'] . '</SPECIAL_LAST_MODIFIED>' . "\n" . '<SPECIAL_DATE_EXPIRES>' . $specials['expires_date'] . '</SPECIAL_DATE_EXPIRES>' . "\n" . '<SPECIAL_STATUS>' . $specials['status'] . '</SPECIAL_STATUS>' . "\n" . '<SPECIAL_DATE_STATUS_CHANGE>' . $specials['date_status_change'] . '</SPECIAL_DATE_STATUS_CHANGE>' . "\n" . '</SPECIAL>' . "\n";
        }
        // Ende Aktionspreise
        $schema .= '</PRODUCT_DATA>' . "\n" . '</PRODUCT_INFO>' . "\n";
    }
    $schema .= '</PRODUCTS>' . "\n\n";
    echo $schema;
}