function process() { global $order, $xtPrice; //include needed functions require_once DIR_FS_INC . 'xtc_calculate_tax.inc.php'; if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == 'true') { switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) { case 'national': if ($order->delivery['country_id'] == STORE_COUNTRY) { $pass = true; } break; case 'international': if ($order->delivery['country_id'] != STORE_COUNTRY) { $pass = true; } break; case 'both': $pass = true; break; default: $pass = false; break; } if ($pass == true && $order->info['total'] - $order->info['shipping_cost'] < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) { $tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); $tax_description = xtc_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) { $order->info['tax'] += xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $order->info['tax_groups'][TAX_ADD_TAX . "{$tax_description}"] += xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $order->info['total'] += MODULE_ORDER_TOTAL_LOWORDERFEE_FEE + xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $low_order_fee = xtc_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE; $order->info['tax'] += xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $order->info['tax_groups'][TAX_NO_TAX . "{$tax_description}"] += xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $order->info['subtotal'] += $low_order_fee; $order->info['total'] += $low_order_fee; } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] != 1) { $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE; $order->info['subtotal'] += $low_order_fee; $order->info['total'] += $low_order_fee; } $this->output[] = array('title' => $this->title . ':', 'text' => $xtPrice->xtcFormat($low_order_fee, true), 'value' => $low_order_fee); } } }
if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0) { $quotes[$i]['tax'] = ''; } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0) { $quotes[$i]['tax'] = 0; } //BOF - DokuMan - 2012-05-31 - fix undefined index 'tax' //$quotes[$i]['methods'][$j]['price'] = $xtPrice->xtcFormat(xtc_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax']), true, 0, true); $quotes[$i]['methods'][$j]['price'] = $xtPrice->xtcFormat(xtc_add_tax($quotes[$i]['methods'][$j]['cost'], isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : ''), true, 0, true); //EOF - DokuMan - 2012-05-31 - fix undefined index 'tax' $quotes[$i]['methods'][$j]['radio_field'] = xtc_draw_hidden_field('act_shipping', 'true') . xtc_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked, 'onclick="this.form.submit();"'); } else { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0) { $quotes[$i]['tax'] = 0; } $quotes[$i]['methods'][$j]['price'] = $xtPrice->xtcFormat(xtc_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax']), true, 0, true) . xtc_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); } $radio_buttons++; } } } $module_smarty->assign('module_content', $quotes); } $module_smarty->caching = 0; $shipping_block = $module_smarty->fetch(CURRENT_TEMPLATE . '/module/checkout_shipping_block.html'); } if ($order->info['total'] > 0) { if (isset($_GET['payment_error']) && is_object(${$_GET['payment_error']}) && ($error = ${$_GET['payment_error']}->get_error())) { $smarty->assign('error', encode_htmlspecialchars($error['error'])); } $selection = $payment_modules->selection();
function selection() { global $xtPrice, $order; if (MODULE_ORDER_TOTAL_COD_FEE_STATUS == 'true') { $cod_country = false; //process installed shipping modules // BOF - Hetfield - 2009-08-18 - replaced deprecated function split with preg_split to be ready for PHP >= 5.3 if ($_SESSION['shipping']['id'] == 'flat_flat') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FLAT); } if ($_SESSION['shipping']['id'] == 'item_item') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ITEM); } if ($_SESSION['shipping']['id'] == 'table_table') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_TABLE); } if ($_SESSION['shipping']['id'] == 'zones_zones') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ZONES); } if ($_SESSION['shipping']['id'] == 'ap_ap') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_AP); } if ($_SESSION['shipping']['id'] == 'dp_dp') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DP); } if ($_SESSION['shipping']['id'] == 'chp_ECO') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP); } if ($_SESSION['shipping']['id'] == 'chp_PRI') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP); } if ($_SESSION['shipping']['id'] == 'chp_URG') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP); } if ($_SESSION['shipping']['id'] == 'chronopost_chronopost') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHRONOPOST); } if ($_SESSION['shipping']['id'] == 'dhl_ECX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } if ($_SESSION['shipping']['id'] == 'dhl_DOX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } if ($_SESSION['shipping']['id'] == 'dhl_SDX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } if ($_SESSION['shipping']['id'] == 'dhl_MDX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } if ($_SESSION['shipping']['id'] == 'dhl_WPX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } if ($_SESSION['shipping']['id'] == 'ups_ups') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPS); } if ($_SESSION['shipping']['id'] == 'upse_upse') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPSE); } if ($_SESSION['shipping']['id'] == 'free_free') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREE); } if ($_SESSION['shipping']['id'] == 'freeamount_freeamount') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_FREEAMOUNT_FREE); } // EOF - Hetfield - 2009-08-18 - replaced deprecated function split with preg_split to be ready for PHP >= 5.3 for ($i = 0; $i < count($cod_zones); $i++) { if ($cod_zones[$i] == $order->delivery['country']['iso_code_2']) { $cod_cost = $cod_zones[$i + 1]; $cod_country = true; break; } elseif ($cod_zones[$i] == '00') { $cod_cost = $cod_zones[$i + 1]; $cod_country = true; break; } else { } $i++; } } else { //COD selected, but no shipping module which offers COD } if ($cod_country) { $cod_tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); $cod_tax_description = xtc_get_tax_description(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) { $cod_cost_value = xtc_add_tax($cod_cost, $cod_tax); $cod_cost = $xtPrice->xtcFormat($cod_cost_value, true); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $cod_cost_value = $cod_cost; $cod_cost = $xtPrice->xtcFormat($cod_cost, true); } if (!$cod_cost_value) { $cod_cost_value = $cod_cost; $cod_cost = $xtPrice->xtcFormat($cod_cost, true); } $this->cost = '+ ' . $cod_cost; } return array('id' => $this->code, 'module' => $this->title, 'description' => $this->info, 'module_cost' => $this->cost); }
function xtc_get_products_price_export($products_id, $price_special, $quantity, $group_id = 0, $add_tax = 1, $currency, $calculate_currencies = true) { // load price data into array for further use! $product_price_query = xtc_db_query("SELECT products_price,\n products_discount_allowed,\n products_tax_class_id\n FROM " . TABLE_PRODUCTS . "\n WHERE\n products_id = '" . $products_id . "'"); $product_price = xtc_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 = xtc_get_tax_rate_export($price_data['PRODUCT_TAX_CLASS_ID']); // check if user is allowed to see tax rates if ($add_tax == '0') { $products_tax = ''; } // end $_SESSION['customers_status']['customers_status_show_price_tax'] =='0' // check if special price is available for product (no product discount on special prices!) if ($special_price = xtc_get_products_special_price($products_id)) { $special_price = xtc_add_tax($special_price, $products_tax); $price_data['PRODUCTS_PRICE'] = xtc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax); $price_string = xtc_format_special_price_export($special_price, $price_data['PRODUCTS_PRICE'], $price_special, $calculate_currencies = true, $quantity, $products_tax, $add_tax, $currency); } else { // if ($special_price=xtc_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 = xtc_db_query("SELECT personal_offer\n FROM personal_offers_by_customers_status_" . $group_id . "\n WHERE products_id='" . $products_id . "'"); $group_price_data = xtc_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 ($_SESSION['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 = xtc_get_qty($products_id); if (!xtc_get_qty($products_id)) { $qty = $quantity; } $graduated_price_query = xtc_db_query("SELECT max(quantity)\n FROM personal_offers_by_customers_status_" . $group_id . "\n WHERE products_id='" . $products_id . "'\n AND quantity<='" . $qty . "'"); $graduated_price_data = xtc_db_fetch_array($graduated_price_query); // get singleprice $graduated_price_query = xtc_db_query("SELECT personal_offer\n FROM personal_offers_by_customers_status_" . $group_id . "\n WHERE products_id='" . $products_id . "'\n AND quantity='" . $graduated_price_data['max(quantity)'] . "'"); $graduated_price_data = xtc_db_fetch_array($graduated_price_query); $price_string = $graduated_price_data['personal_offer']; // } // end $_SESSION['customers_status']['customers_status_graduated_prices']=='1' $price_string = xtc_add_tax($price_string, $products_tax); //*$quantity; } else { // if ($group_price_data['personal_offer']!='' and $group_price_data['personal_offer']!='0.0000') $price_string = xtc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax); //*$quantity; // check if product allows discount } // format price & calculate currency $price_string = $price_string * $quantity; // currency calculations $currencies_query = xtc_db_query("SELECT *\n FROM " . TABLE_CURRENCIES . " WHERE\n code = '" . $currency . "'"); $currencies_value = xtc_db_fetch_array($currencies_query); $currencies_data = array(); $currencies_data = array('SYMBOL_LEFT' => $currencies_value['symbol_left'], 'SYMBOL_RIGHT' => $currencies_value['symbol_right'], 'DECIMAL_PLACES' => $currencies_value['decimal_places'], 'VALUE' => $currencies_value['value']); if ($calculate_currencies == 'true') { $price_string = $price_string * $currencies_data['VALUE']; } $price_string = xtc_precision($price_string, $currencies_data['DECIMAL_PLACES']); if ($price_special == '1') { $currencies_query = xtc_db_query("SELECT *\n FROM " . TABLE_CURRENCIES . " WHERE\n code = '" . $currency . "'"); $currencies_value = xtc_db_fetch_array($currencies_query); $price_string = number_format($price_string, $currencies_data['DECIMAL_PLACES'], $currencies_value['decimal_point'], $currencies_value['thousands_point']); if ($show_currencies == 1) { $price_string = $currencies_data['SYMBOL_LEFT'] . ' ' . $price_string . ' ' . $currencies_data['SYMBOL_RIGHT']; } } } //} return $price_string; // return $price_data['PRODUCTS_PRICE']; }
function before_process() { global $order, $xtPrice; $currency = $_SESSION['currency']; $customer_id = $_SESSION['customer_id']; if (sizeof($order->delivery) != sizeof($order->billing)) { $display = null; } else { if (is_array($order->billing)) { foreach ($order->billing as $key => $val) { if ($order->billing[$key] != $order->delivery[$key]) { xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error_message=' . stripslashes(urlencode(html_entity_decode(MODULE_PAYMENT_BILLSAFE_2HP_ERROR_MESSAGE_ADDRESS))), 'SSL')); } } } } // if ($order->billing['company'] != '') xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error_message='.stripslashes(html_entity_decode(MODULE_PAYMENT_BILLSAFE_2HP_ERROR_MESSAGE_COMPANY)), 'SSL')); if (empty($_GET['token'])) { require_once DIR_FS_CATALOG . 'includes/external/billsafe/classes/billsafe_2/billsafe_2.php'; //DokuMan - 2012-06-19 - move billsafe to external directory $bs = new Billsafe_Sdk(DIR_FS_CATALOG . 'includes/external/billsafe/classes/billsafe_2/ini.php'); //DokuMan - 2012-06-19 - move billsafe to external directory if (MODULE_PAYMENT_BILLSAFE_2HP_LOG == 'true') { if (MODULE_PAYMENT_BILLSAFE_2HP_LOG_TYPE == 'Echo') { require_once DIR_FS_CATALOG . 'includes/external/billsafe/classes/billsafe_2/LoggerEcho.php'; //DokuMan - 2012-06-19 - move billsafe to external directory $bs->setLogger(new Billsafe_LoggerEcho()); } elseif (MODULE_PAYMENT_BILLSAFE_2HP_LOG_TYPE == 'Mail') { require_once DIR_FS_CATALOG . 'includes/external/billsafe/classes/billsafe_2/LoggerMail.php'; //DokuMan - 2012-06-19 - move billsafe to external directory $bs->setLogger(new Billsafe_LoggerMail(MODULE_PAYMENT_BILLSAFE_2HP_LOG_ADDR)); } elseif (MODULE_PAYMENT_BILLSAFE_2HP_LOG_TYPE == 'File') { require_once DIR_FS_CATALOG . 'includes/external/billsafe/classes/billsafe_2/LoggerFile.php'; //DokuMan - 2012-06-19 - move billsafe to external directory $bs->setLogger(new Billsafe_LoggerFile(DIR_FS_CATALOG . 'export/BillSAFE_' . date('YmdHis') . '.log')); } } if ($_SESSION['language_charset'] == 'iso-8859-1' || $_SESSION['language_charset'] == 'iso-8859-15') { $bs->setUtf8Mode(false); } else { $bs->setUtf8Mode(true); } if (MODULE_PAYMENT_BILLSAFE_2HP_SERVER == 'Live') { $bs->setMode('LIVE'); } else { $bs->setMode('SANDBOX'); } $bs->setCredentials(array('merchantId' => MODULE_PAYMENT_BILLSAFE_2HP_MERCHANT_ID, 'merchantLicenseSandbox' => MODULE_PAYMENT_BILLSAFE_2HP_MERCHANT_LICENSE, 'merchantLicenseLive' => MODULE_PAYMENT_BILLSAFE_2HP_MERCHANT_LICENSE, 'applicationSignature' => $this->applicationSignature, 'applicationVersion' => $this->application_version)); $schg_tax = 0; $article = array(); for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { if (is_array($order->products[$i]['attributes'])) { for ($ia = 0, $na = sizeof($order->products[$i]['attributes']); $ia < $na; $ia++) { for ($iao = 0, $nao = sizeof($order->products[$i]['attributes'][$ia]['option']); $iao < $nao; $iao++) { $att .= '-' . $order->products[$i]['attributes'][$ia]['value']; } } } $article[$i]['number'] = $order->products[$i]['model'] . $att; $article[$i]['name'] = $order->products[$i]['name']; $article[$i]['type'] = 'goods'; $article[$i]['quantity'] = intval($order->products[$i]['qty']); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '0') { $article[$i]['netPrice'] = number_format($order->products[$i]['price'], 2, '.', ''); } else { $article[$i]['grossPrice'] = number_format($order->products[$i]['price'], 2, '.', ''); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) { $article[$i]['tax'] = number_format(0, 2, '.', ''); } else { $article[$i]['tax'] = number_format($order->products[$i]['tax'], 2, '.', ''); } unset($att); } $shipping_cost = $order->info['shipping_cost']; if ($shipping_cost > 0) { $shipping_id = explode('_', $order->info['shipping_class']); $shipping_id = $shipping_id[0]; $shipping_tax_rate = $this->get_shipping_tax_rate($shipping_id); $article[$i]['number'] = 'Versand'; $article[$i]['name'] = $order->info['shipping_method']; $article[$i]['type'] = 'shipment'; $article[$i]['quantity'] = 1; $shipping_cost = round($order->info['shipping_cost'] * $xtPrice->currencies[$currency]['value'], $xtPrice->get_decimal_places($currency)); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '0') { $article[$i]['netPrice'] = number_format($shipping_cost, 2, '.', ''); } else { $shipping_cost = xtc_add_tax($shipping_cost, $shipping_tax_rate); $article[$i]['grossPrice'] = number_format($shipping_cost, 2, '.', ''); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) { $article[$i]['tax'] = number_format(0, 2, '.', ''); } else { $article[$i]['tax'] = number_format($shipping_tax_rate, 2, '.', ''); } } else { $i = $i - 1; } if ($_SESSION['discount_value'] != 0) { $discount_tax_rate = xtc_get_tax_rate('1'); $i = $i + 1; $article[$i]['number'] = 'discount'; $article[$i]['name'] = $_SESSION['discount_name']; $article[$i]['type'] = 'voucher'; $article[$i]['quantity'] = 1; if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '0') { $article[$i]['netPrice'] = number_format($_SESSION['discount_value'], 2, '.', ''); } else { $article[$i]['grossPrice'] = number_format($_SESSION['discount_value'], 2, '.', ''); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) { $article[$i]['tax'] = number_format(0, 2, '.', ''); } else { $article[$i]['tax'] = number_format($discount_tax_rate, 2, '.', ''); } } if ($_SESSION['voucher_value'] != 0) { $i = $i + 1; $article[$i]['number'] = 'voucher'; $article[$i]['name'] = $_SESSION['voucher_name']; $article[$i]['type'] = 'voucher'; $article[$i]['quantity'] = 1; if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '0') { $article[$i]['netPrice'] = number_format($_SESSION['voucher_value'], 2, '.', ''); } else { $article[$i]['grossPrice'] = number_format($_SESSION['voucher_value'], 2, '.', ''); } $article[$i]['tax'] = number_format(0, 2, '.', ''); } if ($_SESSION['coupon_value'] != 0) { if (MODULE_ORDER_TOTAL_COUPON_TAX_CLASS) { $coupon_tax_rate = xtc_get_tax_rate(MODULE_ORDER_TOTAL_COUPON_TAX_CLASS); } else { $coupon_tax_rate = xtc_get_tax_rate('1'); } $i = $i + 1; $article[$i]['number'] = 'coupon'; $article[$i]['name'] = $_SESSION['coupon_name']; $article[$i]['type'] = 'voucher'; $article[$i]['quantity'] = 1; if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '0') { $article[$i]['netPrice'] = number_format($_SESSION['coupon_value'], 2, '.', ''); } else { $article[$i]['grossPrice'] = number_format($_SESSION['coupon_value'], 2, '.', ''); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $article[$i]['tax'] = number_format($coupon_tax_rate, 2, '.', ''); $coupon_tax = $_SESSION['coupon_value'] * $coupon_tax_rate / 100; } elseif ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) { $article[$i]['tax'] = number_format(0, 2, '.', ''); $coupon_tax = 0; } else { $article[$i]['tax'] = number_format($coupon_tax_rate, 2, '.', ''); $coupon_tax = $_SESSION['coupon_value'] - $_SESSION['coupon_value'] / (1 + $coupon_tax_rate / 100); } } if ($_SESSION['lofee_value'] != 0) { $lofee_tax_rate = xtc_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS); $i = $i + 1; $article[$i]['number'] = 'surcharge'; $article[$i]['name'] = $_SESSION['lofee_name']; $article[$i]['type'] = 'goods'; $article[$i]['quantity'] = 1; if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '0') { $article[$i]['netPrice'] = number_format($_SESSION['lofee_value'], 2, '.', ''); } else { $article[$i]['grossPrice'] = number_format($_SESSION['lofee_value'], 2, '.', ''); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) { $article[$i]['tax'] = number_format(0, 2, '.', ''); $lofee_tax = 0; } else { $article[$i]['tax'] = number_format($lofee_tax_rate, 2, '.', ''); $lofee_tax = $_SESSION['lofee_value'] - $_SESSION['lofee_value'] / (1 + $lofee_tax_rate / 100); } } $customer_query = xtc_db_query('SELECT customers_gender, DATE_FORMAT(customers_dob, "%Y-%m-%d") AS customers_dob, customers_email_address, customers_telephone from ' . TABLE_CUSTOMERS . ' WHERE customers_id = "' . xtc_db_input($customer_id) . '"'); if (xtc_db_num_rows($customer_query)) { $customer = xtc_db_fetch_array($customer_query); } $shipping_tax = round($order->info['shipping_cost'] / 100 * $shipping_tax_rate, 2); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $total = $order->info['subtotal'] + $order->info['tax'] + $shipping_tax + $_SESSION['discount_value'] + $_SESSION['voucher_value'] + $_SESSION['coupon_value'] + $coupon_tax + $_SESSION['lofee_value']; } else { $total = $order->info['subtotal'] + $_SESSION['discount_value'] + $_SESSION['voucher_value'] + $_SESSION['coupon_value'] + $_SESSION['lofee_value']; } $total = round($xtPrice->xtcCalculateCurrEx($total, $_SESSION['currency']), $xtPrice->get_decimal_places($_SESSION['currency'])); $info_tax = $order->info['tax']; $total = number_format(round($total + $shipping_cost, $xtPrice->get_decimal_places($currency)), 2, '.', ''); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) { $info_tax = number_format(0, 2, '.', ''); } else { $info_tax = number_format(round($info_tax + $shipping_tax + $coupon_tax + $lofee_tax, $xtPrice->get_decimal_places($currency)), 2, '.', ''); } $url_image = $this->checkLogoURL(MODULE_PAYMENT_BILLSAFE_2HP_SHOP_LOGO_URL); if ($customer['customers_gender'] != '') { $params = array('order_amount' => round($total, $xtPrice->get_decimal_places($currency)), 'order_taxAmount' => number_format($info_tax, 2, '.', ''), 'order_currencyCode' => $currency, 'customer' => array('id' => $customer_id, 'gender' => $customer['customers_gender'], 'company' => $order->delivery['company'], 'firstname' => $order->delivery['firstname'], 'lastname' => $order->delivery['lastname'], 'street' => $order->delivery['street_address'], 'postcode' => $order->delivery['postcode'], 'city' => $order->delivery['city'], 'country' => $order->delivery['country']['iso_code_2'], 'email' => $customer['customers_email_address'], 'phone' => $customer['customers_telephone']), 'product' => 'installment', 'url_return' => xtc_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'), 'url_cancel' => xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'billsafe_close=true', 'SSL'), 'url_image' => $url_image, 'articleList' => $article); } else { $params = array('order_amount' => round($total, $xtPrice->get_decimal_places($currency)), 'order_taxAmount' => number_format($info_tax, 2, '.', ''), 'order_currencyCode' => $currency, 'customer' => array('id' => $customer_id, 'company' => $order->delivery['company'], 'firstname' => $order->delivery['firstname'], 'lastname' => $order->delivery['lastname'], 'street' => $order->delivery['street_address'], 'postcode' => $order->delivery['postcode'], 'city' => $order->delivery['city'], 'country' => $order->delivery['country']['iso_code_2'], 'email' => $customer['customers_email_address'], 'phone' => $customer['customers_telephone']), 'product' => 'installment', 'url_return' => xtc_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'), 'url_cancel' => xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'billsafe_close=true', 'SSL'), 'url_image' => $url_image, 'articleList' => $article); } // $_SESSION['bs_article'] = $article; if (!empty($customer['customers_dob']) && $customer['customers_dob'] != '0000-00-00') { $params['customer']['dateOfBirth'] = $customer['customers_dob']; } $response = $bs->callMethod('prepareOrder', $params); if ($response->ack == 'OK') { if (MODULE_PAYMENT_BILLSAFE_2HP_LAYER == 'true') { $bs->callPaymentLayer($response->token); } else { $bs->redirectToPaymentGateway($response->token); } } else { $message = $this->get_error_message($response); xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error_message=' . stripslashes(urlencode(html_entity_decode($message))), 'SSL')); } } else { $token = $_GET['token']; $check_query = xtc_db_query('SELECT token FROM billsafe_orders_2 WHERE token = "' . $token . '"'); $check_token = xtc_db_num_rows($check_query); if ($check_token == 1) { xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error_message=' . stripslashes(urlencode(html_entity_decode(MODULE_PAYMENT_BILLSAFE_2HP_ERROR_MESSAGE_COMMON))), 'SSL')); } require_once DIR_FS_CATALOG . 'includes/external/billsafe/classes/billsafe_2/billsafe_2.php'; //DokuMan - 2012-06-19 - move billsafe to external directory $bs = new Billsafe_Sdk(DIR_FS_CATALOG . 'includes/external/billsafe/classes/billsafe_2/ini.php'); //DokuMan - 2012-06-19 - move billsafe to external directory if ($_SESSION['language_charset'] == 'iso-8859-1' || $_SESSION['language_charset'] == 'iso-8859-15') { $bs->setUtf8Mode(false); } else { $bs->setUtf8Mode(true); } if (MODULE_PAYMENT_BILLSAFE_2HP_SERVER == 'Live') { $bs->setMode("LIVE"); } else { $bs->setMode("SANDBOX"); } $bs->setCredentials(array('merchantId' => MODULE_PAYMENT_BILLSAFE_2HP_MERCHANT_ID, 'merchantLicenseSandbox' => MODULE_PAYMENT_BILLSAFE_2HP_MERCHANT_LICENSE, 'merchantLicenseLive' => MODULE_PAYMENT_BILLSAFE_2HP_MERCHANT_LICENSE, 'applicationSignature' => $this->applicationSignature, 'applicationVersion' => $this->application_version)); $params = array('token' => $token); $this->response = $bs->callMethod('getTransactionResult', $params); if ($this->response->ack == 'OK' && $this->response->status == 'ACCEPTED') { } else { $_SESSION['billsafe_status'] = 'declined'; xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error_message=' . stripslashes(urlencode(html_entity_decode(MODULE_PAYMENT_BILLSAFE_2HP_ERROR_MESSAGE_COMMON))), 'SSL')); } } return true; }
/** * Calculate order total and save it away. * * We need to access to all additional charges, ie the order_totals list, in * the before_process() function but at that point order_totals->process * hasn't been run. * * @return array order_total_array */ public function getOrderTotal() { global $order_total_modules, $order; $klarna_ot = $_SESSION['klarna_ot']; $shipping = $_SESSION['shipping']; $orderTotalModules = $order_total_modules->modules; $klarnaOrderTotals = array(); if (!is_array($orderTotalModules)) { return $klarnaOrderTotals; } $ignore = array('ot_tax', 'ot_subtotal', 'ot_total', 'ot_subtotal_no_tax'); $showTax = KlarnaConstant::showPriceTax(); foreach ($orderTotalModules as $value) { $className = substr($value, 0, strrpos($value, '.')); $class = $GLOBALS[$className]; // If the module class isn't an object, move along if (!is_object($class)) { continue; } // It this module isn't enabled, move along. if (!$class->enabled) { continue; } // Check if the module should be ignored. This is so that we don't add // the sub_total, order_total and tax_total to our goods list if (in_array($class->code, $ignore)) { continue; } $output = $class->output; if (sizeof($output) == 0) { continue; } $taxClass = null; foreach ($class->keys() as $constant) { if (strlen(strstr($constant, "TAX_CLASS")) > 0) { if (defined($constant)) { $taxClass = constant($constant); continue; } } } $taxRate = 0; $delCountryId = $order->delivery['country']['id']; $delZoneId = $order->delivery['zone_id'] > 0 ? $order->delivery['zone_id'] : null; if ($taxClass !== null) { $taxRate = xtc_get_tax_rate($taxClass, $delCountryId, $delZoneId); } foreach ($output as $orderTotal) { $orderTotal["rate"] = $taxRate; $klarnaOrderTotals[$className] = $orderTotal; } //Set Shipping VAT if ($className == 'ot_shipping') { $taxRate = $this->_getShippingTaxRate($shipping["id"]); $klarnaOrderTotals[$className]["rate"] = $taxRate; } $tax = 0; $value = $klarnaOrderTotals[$className]["value"]; if ($showTax === false) { $tax = xtc_add_tax($value, $taxRate) - $value; } else { $tax = $value - $value / (1 + $taxRate / 100); } $klarnaOrderTotals[$className]["tax"] = $tax; } return $klarnaOrderTotals; }
$info_smarty->assign('MANUFACTURER_LINK', xtc_href_link(FILENAME_DEFAULT, xtc_manufacturer_link($manufacturer['manufacturers_id'], $manufacturer['manufacturers_name']))); } // build products price $products_price = $xtPrice->xtcGetPrice($product->data['products_id'], $format = true, 1, $product->data['products_tax_class_id'], $product->data['products_price'], 1); $products_attributes_query = xtc_db_query("select count(*) as total \n from " . TABLE_PRODUCTS_OPTIONS . " popt, \n " . TABLE_PRODUCTS_ATTRIBUTES . " patrib \n where patrib.products_id='" . $product->data['products_id'] . "' \n and patrib.options_id = popt.products_options_id \n and popt.language_id = '" . (int) $_SESSION['languages_id'] . "'\n "); $products_attributes = xtc_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { $products_options_name_query = xtc_db_query("select distinct popt.products_options_id, \n popt.products_options_name \n from " . TABLE_PRODUCTS_OPTIONS . " popt, \n " . TABLE_PRODUCTS_ATTRIBUTES . " patrib \n where patrib.products_id='" . $product->data['products_id'] . "' \n and patrib.options_id = popt.products_options_id \n and popt.language_id = '" . (int) $_SESSION['languages_id'] . "' \n order by popt.products_options_name\n "); while ($products_options_name = xtc_db_fetch_array($products_options_name_query)) { $products_options_query = xtc_db_query(" select pov.products_options_values_id,\n pov.products_options_values_name,\n pa.options_values_price,\n pa.price_prefix,pa.attributes_stock,\n pa.attributes_model\n from " . TABLE_PRODUCTS_ATTRIBUTES . " pa,\n " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov\n where pa.products_id = '" . $product->data['products_id'] . "'\n and pa.options_id = '" . $products_options_name['products_options_id'] . "'\n and pa.options_values_id = pov.products_options_values_id\n and pov.language_id = '" . (int) $_SESSION['languages_id'] . "'\n order by pa.sortorder\n "); while ($products_options = xtc_db_fetch_array($products_options_query)) { $module_content[] = array('GROUP' => $products_options_name['products_options_name'], 'NAME' => $products_options['products_options_values_name']); if ($products_options['options_values_price'] != '0') { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) { $tax_rate = $xtPrice->TAX[$product->data['products_tax_class_id']]; $products_options['options_values_price'] = xtc_add_tax($products_options['options_values_price'], $xtPrice->TAX[$product->data['products_tax_class_id']]); } if ($_SESSION['customers_status']['customers_status_show_price'] == 1) { $module_content[sizeof($module_content) - 1]['NAME'] .= ' (' . $products_options['price_prefix'] . $xtPrice->xtcFormat($products_options['options_values_price'], true, 0, true) . ')'; } } } } } $info_smarty->assign('module_content', $module_content); // show expiry date of active special products $special_expires_date_query = "SELECT expires_date\n FROM " . TABLE_SPECIALS . "\n WHERE products_id = '" . $product->data['products_id'] . "'\n AND status = '1'"; $special_expires_date_query = xtDBquery($special_expires_date_query); $sDate = xtc_db_fetch_array($special_expires_date_query, true); $info_smarty->assign('PRODUCTS_EXPIRES', $sDate['expires_date'] != '0000-00-00 00:00:00' ? xtc_date_short($sDate['expires_date']) : ''); // FSK18
function process() { global $order, $xtPrice, $free_shipping, $free_shipping_value_over; if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') { switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) { case 'national': if ($order->delivery['country_id'] == STORE_COUNTRY) { $pass = true; } $free_shipping_value_over = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER; break; case 'international': if ($order->delivery['country_id'] != STORE_COUNTRY) { $pass = true; } $free_shipping_value_over = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER_INTERNATIONAL; break; case 'both': if ($order->delivery['country_id'] == STORE_COUNTRY) { $free_shipping_value_over = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER; } else { $free_shipping_value_over = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER_INTERNATIONAL; } $pass = true; break; default: $pass = false; break; } if ($pass == true && $xtPrice->xtcRemoveCurr($order->info['total'] - $order->info['shipping_cost']) >= $free_shipping_value_over) { $order->info['shipping_method'] = $this->title; $order->info['total'] -= $order->info['shipping_cost']; $order->info['shipping_cost'] = 0; $free_shipping = true; } } if (!isset($_SESSION['shipping'])) { return; } $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_')); if (xtc_not_null($order->info['shipping_method']) && isset($GLOBALS[$module]) && is_object($GLOBALS[$module])) { $tax = 0; $shipping_tax = 0; $shipping_tax_description = ''; $shipping_tax = xtc_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $shipping_tax_description = xtc_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $tax = xtc_add_tax($order->info['shipping_cost'], $shipping_tax) - $order->info['shipping_cost']; $tax = $xtPrice->xtcFormat($tax, false, 0, true); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) { // price with tax $order->info['shipping_cost'] = xtc_add_tax($order->info['shipping_cost'], $shipping_tax); $order->info['tax'] += $tax; $order->info['tax_groups'][TAX_ADD_TAX . "{$shipping_tax_description}"] += $tax; $order->info['total'] += $tax; } else { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $order->info['tax'] = $order->info['tax'] += $tax; $order->info['tax_groups'][TAX_NO_TAX . "{$shipping_tax_description}"] = $order->info['tax_groups'][TAX_NO_TAX . "{$shipping_tax_description}"] += $tax; } } $this->output[] = array('title' => $order->info['shipping_method'] . ':', 'text' => $xtPrice->xtcFormat($order->info['shipping_cost'], true, 0, true), 'value' => $xtPrice->xtcFormat($order->info['shipping_cost'], false, 0, true)); } }
function process() { global $order, $xtPrice, $cod_cost, $cod_country, $shipping; if (MODULE_ORDER_TOTAL_COD_FEE_STATUS == 'true') { //Will become true, if cod can be processed. $cod_country = false; //check if payment method is cod. If yes, check if cod is possible. if ($_SESSION['payment'] == 'cod') { //process installed shipping modules // BOF - Hetfield - 2009-08-18 - replaced deprecated function split with preg_split to be ready for PHP >= 5.3 if ($_SESSION['shipping']['id'] == 'flat_flat') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FLAT); } if ($_SESSION['shipping']['id'] == 'item_item') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ITEM); } if ($_SESSION['shipping']['id'] == 'table_table') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_TABLE); } if ($_SESSION['shipping']['id'] == 'zones_zones') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ZONES); } if ($_SESSION['shipping']['id'] == 'ap_ap') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_AP); } if ($_SESSION['shipping']['id'] == 'dp_dp') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DP); } // module chp if ($_SESSION['shipping']['id'] == 'chp_ECO') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP); } if ($_SESSION['shipping']['id'] == 'chp_PRI') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP); } if ($_SESSION['shipping']['id'] == 'chp_URG') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP); } // module chronopost if ($_SESSION['shipping']['id'] == 'chronopost_chronopost') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHRONOPOST); } // module DHL if ($_SESSION['shipping']['id'] == 'dhl_ECX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } if ($_SESSION['shipping']['id'] == 'dhl_DOX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } if ($_SESSION['shipping']['id'] == 'dhl_SDX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } if ($_SESSION['shipping']['id'] == 'dhl_MDX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } if ($_SESSION['shipping']['id'] == 'dhl_WPX') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL); } // UPS if ($_SESSION['shipping']['id'] == 'ups_ups') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPS); } if ($_SESSION['shipping']['id'] == 'upse_upse') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPSE); } // Free Shipping if ($_SESSION['shipping']['id'] == 'free_free') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREE); } if ($_SESSION['shipping']['id'] == 'freeamount_freeamount') { $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_FREEAMOUNT_FREE); } // EOF - Hetfield - 2009-08-18 - replaced deprecated function split with preg_split to be ready for PHP >= 5.3 for ($i = 0; $i < count($cod_zones); $i++) { if ($cod_zones[$i] == $order->delivery['country']['iso_code_2']) { $cod_cost = $cod_zones[$i + 1]; $cod_country = true; break; } elseif ($cod_zones[$i] == '00') { $cod_cost = $cod_zones[$i + 1]; $cod_country = true; break; } else { } $i++; } } else { //COD selected, but no shipping module which offers COD } if ($cod_country) { $cod_tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); $cod_tax_description = xtc_get_tax_description(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) { $order->info['tax'] += xtc_add_tax($cod_cost, $cod_tax) - $cod_cost; $order->info['tax_groups'][TAX_ADD_TAX . "{$cod_tax_description}"] += xtc_add_tax($cod_cost, $cod_tax) - $cod_cost; $order->info['total'] += $cod_cost + (xtc_add_tax($cod_cost, $cod_tax) - $cod_cost); $cod_cost_value = xtc_add_tax($cod_cost, $cod_tax); $cod_cost = $xtPrice->xtcFormat($cod_cost_value, true); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $order->info['tax'] += xtc_add_tax($cod_cost, $cod_tax) - $cod_cost; $order->info['tax_groups'][TAX_NO_TAX . "{$cod_tax_description}"] += xtc_add_tax($cod_cost, $cod_tax) - $cod_cost; $cod_cost_value = $cod_cost; $cod_cost = $xtPrice->xtcFormat($cod_cost, true); $order->info['subtotal'] += $cod_cost_value; $order->info['total'] += $cod_cost_value; } if (!$cod_cost_value) { $cod_cost_value = $cod_cost; $cod_cost = $xtPrice->xtcFormat($cod_cost, true); $order->info['total'] += $cod_cost_value; } $this->output[] = array('title' => $this->title . ':', 'text' => $cod_cost, 'value' => $cod_cost_value); } else { //Following code should be improved if we can't get the shipping modules disabled, who don't allow COD // as well as countries who do not have cod // $this->output[] = array('title' => $this->title . ':', // 'text' => 'No COD for this module.', // 'value' => ''); } } }
function shopAddTax($price, $tax) { return xtc_add_tax($price, $tax); }
function confirmation() { global $order, $smarty, $xtPrice, $main, $messageStack, $total_weight, $total_count, $free_shipping; if (isset($_GET['conditions_message'])) { $message_condition = str_replace('\\n', '', ERROR_CONDITIONS_NOT_ACCEPTED); $message_address = str_replace('\\n', '', ERROR_ADDRESS_NOT_ACCEPTED); switch ($_GET['conditions_message']) { case "1": $messageStack->add('checkout_confirmation', $message_condition); break; case "13": $messageStack->add('checkout_confirmation', $message_condition); $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD); break; case "2": $messageStack->add('checkout_confirmation', $message_address); break; case "23": $messageStack->add('checkout_confirmation', $message_address); $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD); break; case "12": $messageStack->add('checkout_confirmation', $message_condition); $messageStack->add('checkout_confirmation', $message_address); break; case "123": $messageStack->add('checkout_confirmation', $message_condition); $messageStack->add('checkout_confirmation', $message_address); $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD); break; case "3": $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD); break; } } if ($order->delivery['country']['iso_code_2'] != '') { $_SESSION['delivery_zone'] = $order->delivery['country']['iso_code_2']; } $no_shipping = false; if ($order->content_type == 'virtual' || $order->content_type == 'virtual_weight' || $_SESSION['cart']->count_contents_virtual() == 0) { $no_shipping = true; } $total_weight = $_SESSION['cart']->show_weight(); $total_count = $_SESSION['cart']->count_contents(); // load all enabled shipping modules $shipping_modules = new shipping(); // add unallowed payment / shipping if (defined('MODULE_EXCLUDE_PAYMENT_STATUS') && MODULE_EXCLUDE_PAYMENT_STATUS == 'True') { for ($i = 1; $i <= MODULE_EXCLUDE_PAYMENT_NUMBER; $i++) { $payment_exclude = explode(',', constant('MODULE_EXCLUDE_PAYMENT_PAYMENT_' . $i)); if (in_array($this->code, $payment_exclude)) { $shipping_exclude = explode(',', constant('MODULE_EXCLUDE_PAYMENT_SHIPPING_' . $i)); for ($i = 0, $n = count($shipping_modules->modules); $i < $n; $i++) { if (in_array(substr($shipping_modules->modules[$i], 0, -4), $shipping_exclude)) { unset($shipping_modules->modules[$i]); } } } } } $free_shipping = false; $ot_shipping = new ot_shipping(); $ot_shipping->process(); if ($no_shipping === true) { $_SESSION['shipping'] = false; } // get all available shipping quotes $quotes = $shipping_modules->quote(); // if no shipping method has been selected, automatically select the cheapest method. // if the modules status was changed when none were available, to save on implementing // a javascript force-selection method, also automatically select the cheapest shipping // method if more than one module is now enabled if (!isset($_SESSION['shipping']) && CHECK_CHEAPEST_SHIPPING_MODUL == 'true' || isset($_SESSION['shipping']) && $_SESSION['shipping'] == false && xtc_count_shipping_modules() > 1) { $_SESSION['shipping'] = $shipping_modules->cheapest(); } if ($no_shipping === true) { $_SESSION['shipping'] = false; } if (defined('SHOW_SELFPICKUP_FREE') && SHOW_SELFPICKUP_FREE == 'true') { if ($free_shipping == true) { $free_shipping = false; $quotes = array_merge($ot_shipping->quote(), $shipping_modules->quote('selfpickup', 'selfpickup')); } } $module_smarty = new Smarty(); $shipping_block = ''; if (xtc_count_shipping_modules() > 0) { $showtax = $_SESSION['customers_status']['customers_status_show_price_tax']; $module_smarty->assign('FREE_SHIPPING', $free_shipping); # free shipping or not... if ($free_shipping == true) { $module_smarty->assign('FREE_SHIPPING_TITLE', FREE_SHIPPING_TITLE); $module_smarty->assign('FREE_SHIPPING_DESCRIPTION', sprintf(FREE_SHIPPING_DESCRIPTION, $xtPrice->xtcFormat($free_shipping_value_over, true, 0, true)) . xtc_draw_hidden_field('shipping', 'free_free')); $module_smarty->assign('FREE_SHIPPING_ICON', $quotes[$i]['icon']); } else { $radio_buttons = 0; #loop through installed shipping methods... for ($i = 0, $n = sizeof($quotes); $i < $n; $i++) { if (!isset($quotes[$i]['error'])) { for ($j = 0, $n2 = sizeof($quotes[$i]['methods']); $j < $n2; $j++) { # set the radio button to be checked if it is the method chosen $quotes[$i]['methods'][$j]['radio_buttons'] = $radio_buttons; $checked = isset($_SESSION['shipping']) && $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $_SESSION['shipping']['id'] ? true : false; if ($checked == true || $n == 1 && $n2 == 1) { $quotes[$i]['methods'][$j]['checked'] = 1; } if ($n > 1 || $n2 > 1) { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 || !isset($quotes[$i]['tax'])) { $quotes[$i]['tax'] = 0; } $quotes[$i]['methods'][$j]['price'] = $xtPrice->xtcFormat(xtc_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax']), true, 0, true); $quotes[$i]['methods'][$j]['radio_field'] = xtc_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked, 'id="rd-' . ($i + 1) . '" onChange="this.form.submit()"'); } else { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0) { $quotes[$i]['tax'] = 0; } $quotes[$i]['methods'][$j]['price'] = $xtPrice->xtcFormat(xtc_add_tax($quotes[$i]['methods'][$j]['cost'], isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0), true, 0, true) . xtc_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); } $radio_buttons++; } } } $module_smarty->assign('module_content', $quotes); } $module_smarty->assign('language', $_SESSION['language']); $module_smarty->caching = 0; $shipping_block = $module_smarty->fetch(CURRENT_TEMPLATE . '/module/checkout_shipping_block.html'); } if ($no_shipping === false) { $module_smarty->assign('FORM_SHIPPING_ACTION', xtc_draw_form('checkout_shipping', xtc_href_link(FILENAME_CHECKOUT_CONFIRMATION, xtc_get_all_get_params(), 'SSL')) . xtc_draw_hidden_field('action', 'process')); $shipping_found = false; for ($i = 0, $n = sizeof($quotes); $i < $n; $i++) { for ($j = 0, $n2 = sizeof($quotes[$i]['methods']); $j < $n2; $j++) { if ($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $_SESSION['shipping']['id']) { $shipping_found = true; break; } } } if ($shipping_found === false) { $module_smarty->assign('shipping_message', ERROR_CHECKOUT_SHIPPING_NO_METHOD); /* if (xtc_count_shipping_modules() == 1) { $module_smarty->assign('BUTTON_CONTINUE', xtc_image_submit('button_confirm.gif', IMAGE_BUTTON_CONFIRM)); } */ } $module_smarty->assign('BUTTON_CONTINUE', xtc_image_submit('button_confirm.gif', IMAGE_BUTTON_CONFIRM)); $module_smarty->assign('FORM_END', '</form>'); if ($no_shipping === false) { $module_smarty->assign('SHIPPING_BLOCK', $shipping_block); } $module_smarty->assign('language', $_SESSION['language']); $module_smarty->caching = 0; $shipping_method = $module_smarty->fetch(DIR_FS_EXTERNAL . '/paypal/templates/shipping_block.html'); $smarty->assign('SHIPPING_METHOD', $shipping_method); } $smarty->assign('SHIPPING_ADDRESS_EDIT', xtc_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, xtc_get_all_get_params(), 'SSL')); $smarty->assign('BILLING_ADDRESS_EDIT', xtc_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, xtc_get_all_get_params(), 'SSL')); $smarty->clear_assign('SHIPPING_EDIT'); $smarty->clear_assign('PAYMENT_EDIT'); //$smarty->clear_assign('PRODUCTS_EDIT'); }
function process() { global $order, $xtPrice, $ps_cost, $ps_country, $shipping; $customer_id = $_SESSION['customer_id']; if (MODULE_ORDER_TOTAL_PS_FEE_STATUS == 'true') { //Will become true, if ps can be processed. $ps_country = false; //check if payment method is ps. If yes, check if ps is possible. $count_query = xtc_db_query("select count(*) as count from " . TABLE_CUSTOMERS_BASKET . " cb, " . TABLE_PRODUCTS . " p where cb.customers_id = '" . $customer_id . "' and cb.products_id = p.products_id and p.products_fsk18 = '1'"); $num = xtc_db_fetch_array($count_query); $age = $num['count']; if ($age > '0') { //process installed shipping modules // BOF - Hetfield - 2009-08-18 - replaced deprecated function split with preg_split to be ready for PHP >= 5.3 if ($_SESSION['shipping']['id'] == 'flat_flat') { $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_FLAT); } if ($_SESSION['shipping']['id'] == 'item_item') { $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_ITEM); } if ($_SESSION['shipping']['id'] == 'table_table') { $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_TABLE); } if ($_SESSION['shipping']['id'] == 'zones_zones') { $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_ZONES); } if ($_SESSION['shipping']['id'] == 'ap_ap') { $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_AP); } if ($_SESSION['shipping']['id'] == 'dp_dp') { $ps_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_PS_FEE_DP); } // EOF - Hetfield - 2009-08-18 - replaced deprecated function split with preg_split to be ready for PHP >= 5.3 for ($i = 0; $i < count($ps_zones); $i++) { if ($ps_zones[$i] == $order->billing['country']['iso_code_2']) { $ps_cost = $ps_zones[$i + 1]; $ps_country = true; //print('match' . $ps_zones[$i] . ': ' . $ps_cost); break; } elseif ($ps_zones[$i] == '00') { $ps_cost = $ps_zones[$i + 1]; $ps_country = true; //print('match' . $i . ': ' . $ps_cost); break; } else { //print('no match'); } $i++; } } else { //PS selected, but no shipping module which offers PS } if ($ps_country) { $ps_tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_PS_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); $ps_tax_description = xtc_get_tax_description(MODULE_ORDER_TOTAL_PS_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) { $order->info['tax'] += xtc_add_tax($ps_cost, $ps_tax) - $ps_cost; $order->info['tax_groups'][TAX_ADD_TAX . "{$ps_tax_description}"] += xtc_add_tax($ps_cost, $ps_tax) - $ps_cost; $order->info['total'] += $ps_cost + (xtc_add_tax($ps_cost, $ps_tax) - $ps_cost); $ps_cost_value = xtc_add_tax($ps_cost, $ps_tax); $ps_cost = $xtPrice->xtcFormat($ps_cost_value, true); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $order->info['tax'] += xtc_add_tax($ps_cost, $ps_tax) - $ps_cost; $order->info['tax_groups'][TAX_NO_TAX . "{$ps_tax_description}"] += xtc_add_tax($ps_cost, $ps_tax) - $ps_cost; $ps_cost_value = $ps_cost; $ps_cost = $xtPrice->xtcFormat($ps_cost, true); $order->info['subtotal'] += $ps_cost_value; $order->info['total'] += $ps_cost_value; } if (!$ps_cost_value) { $ps_cost_value = $ps_cost; $ps_cost = $xtPrice->xtcFormat($ps_cost, true); $order->info['total'] += $ps_cost_value; } $this->output[] = array('title' => $this->title . ':', 'text' => $ps_cost, 'value' => $ps_cost_value); } else { //Following pse should be improved if we can't get the shipping modules disabled, who don't allow PS // as well as countries who do not have ps // $this->output[] = array('title' => $this->title . ':', // 'text' => 'No PS for this module.', // 'value' => ''); } } }
function display_price($products_price, $products_tax, $quantity = 1) { return $this->format(xtc_add_tax($products_price, $products_tax) * $quantity); }
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 = xtc_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . xtc_get_prid($products_id) . "'"); if ($product = xtc_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = xtc_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; $specials_query = xtc_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'"); if (xtc_db_num_rows($specials_query)) { $specials = xtc_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } $this->total += xtc_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 = xtc_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $prid . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'"); $attribute_price = xtc_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $this->total += $qty * xtc_add_tax($attribute_price['options_values_price'], $products_tax); } else { $this->total -= $qty * xtc_add_tax($attribute_price['options_values_price'], $products_tax); } } } } }
function getShippingCosts($payment, $price = null, $offerWeight = null, $taxClass = -1) { $shippingCost = ''; // is the is payment active? if ($this->payment[$payment]['active'] === true) { // is free delivery active and price equal or higher than the limit? if ($this->freeShipping === true && $price >= $this->freeShippingValue) { $shippingCost = 0.0; } elseif ($this->shipping_free_shipping > 0 && $price > $this->shipping_free_shipping) { $shippingCost = 0.0; } elseif ($this->paymentTable === true || $this->paymentItem === true || $this->paymentFlat === true) { // first of all we get the standard shipping costs (default sc, per item or table) // are the table shipping costs active? Check which table payment option is active if ($this->paymentTable === true) { // run through the table values and check which weight / price matches the offer switch ($this->paymentTableMode) { case 'weight': $offerCompareValue = $offerWeight; break; case 'price': $offerCompareValue = $price; break; } if (is_array($this->paymentTableValues) && $offerCompareValue != null) { foreach ($this->paymentTableValues as $tableModeValue => $tablePrice) { // stop the loop if sth. matched if ($offerCompareValue <= $tableModeValue) { $shippingCost = $tablePrice; break; } } // If no weight / price was matched accordingly, the last entry in the array is taken if ($shippingCost == '') { end($this->paymentTableValues); // Zeiger an letzte Stelle bewegen $shippingCost = current($this->paymentTableValues); // Wert ausgeben auf den der Zeiger aktuell zeigt reset($this->paymentTableValues); // Setze Zeiger wieder in Ausgangsposition } } else { // if the table sc values are not correct or the weight / price is null => nothing shall appear in the csv $shippingCost = ''; } } else { $shippingCost = $this->standardShippingCost; } } // calculate taxes if ($this->shippingtax > 0) { $tax = $this->TAX[$this->shippingtax]; $shippingCost = xtc_add_tax($shippingCost, $tax); } // cod needs additional calculation // the additional cod_fee (if active) depends on the shipping option that is active as the fee can differ if ($payment == 'COD') { // check if extra fee for "Cash on Delivery" is active // 1. get the db data $getCodExtraFeeStatus = xtc_db_query("SELECT `configuration_value` AS `cod_fee_status`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t FROM `configuration`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE `configuration_key` LIKE 'MODULE_ORDER_TOTAL_COD_FEE_STATUS';"); $result = array(); $result = xtc_db_fetch_array($getCodExtraFeeStatus); // 2. is the fee status active? if (isset($result['cod_fee_status']) && $result['cod_fee_status'] == 'true') { $modul = ''; // which shipping option is active? if ($this->freeShipping === true && $price >= $this->freeShippingValue) { $modul = 'MODULE_ORDER_TOTAL_FREEAMOUNT_FREE'; } elseif ($this->paymentTable === true) { $modul = 'MODULE_ORDER_TOTAL_COD_FEE_TABLE'; } elseif ($this->paymentItem === true) { $modul = 'MODULE_ORDER_TOTAL_COD_FEE_ITEM'; } elseif ($this->paymentFlat === true) { $modul = 'MODULE_ORDER_TOTAL_COD_FEE_FLAT'; } $getCodCost = xtc_db_query("SELECT `configuration_value` AS `cod_cost`\r\n\t\t\t\t\t\t\t\t\t\t\t\tFROM `configuration`\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `configuration_key` LIKE '{$modul}';"); unset($result); $result = array(); $result = xtc_db_fetch_array($getCodCost); // Are there any costs? if (isset($result['cod_cost']) && $result['cod_cost'] != '') { // get the value for the country preg_match_all('/DE:([^,]+)?/', $result['cod_cost'], $match); // $match[1][0] contains the result in the form of (e.g.) 7.00 or 7 // to make sure that mistakes like 7.00:9.99 (correct would be 7,00:9.99) are also handled, we check for the colon if (preg_match('/:/', $match[1][0])) { $tmpArr = explode(':', $match[1][0]); $codCost = $tmpArr[0]; } else { $codCost = $match[1][0]; } // de we ge a useful value? if (isset($codCost) && $codCost != NULL && is_numeric($codCost)) { // calculate taxes if ($this->shippingtaxcod > 0) { $tax = $this->TAX[$this->shippingtaxcod]; $codCost = xtc_add_tax($codCost, $tax); } $shippingCost += $codCost; } } } } // format and round numbers $shippingCost = number_format($shippingCost, 2, ',', '.'); } return $shippingCost; }