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)); } } }
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); } } } }
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)); }
function tep_calculate_tax($x, $y) { return olc_calculate_tax($x, $y); }
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; }
olc_db_query(SQL_UPDATE . TABLE_PRODUCTS_ATTRIBUTES . " set\n attributes_stock=attributes_stock - '" . $current_product_qty . "'\n where\n products_id='" . $current_product_id . "'\n and options_values_id='" . $current_product_attribute_value_id . "'\n and options_id='" . $current_product_attribute_option_id . "'\n "); $attributes_values = olc_db_fetch_array($attributes); $sql_data_array = array('orders_id' => $orders_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values['products_options_name'], 'products_options_values' => $attributes_values['products_options_values_name'], 'options_values_price' => $attributes_values['options_values_price'], 'price_prefix' => $attributes_values['price_prefix']); olc_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array); if ($download_enabled) { $products_attributes_filename = $attributes_values['products_attributes_filename']; if ($products_attributes_filename) { $sql_data_array = array('orders_id' => $orders_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $products_attributes_filename, 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount']); olc_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array); } } } } //------insert customer choosen option eof ---- $total_weight += $current_product_qty * $current_product['weight']; $total_tax += olc_calculate_tax($total_products_price, $products_tax) * $current_product_qty; $total_cost += $total_products_price; } // load the after_process function from the payment modules $payment_modules->after_process(); // NEW EMAIL configuration ! $order_totals = $order_total_modules->apply_credit(); if ($real_checkout || $is_auction) { include 'send_order.php'; } else { $sendto = $_SESSION['sendto']; $billto = $_SESSION['billto']; $shipping = $_SESSION['shipping']; $payment = $_SESSION['payment']; } if (SHOW_AFFILIATE) {
function get_product_price($product_id) { global $order, $olPrice; $products_id = olc_get_prid($product_id); // products price $qty = $_SESSION['cart']->contents[$product_id]['qty']; $product_query = olc_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . $product_id . APOS); if ($product = olc_db_fetch_array($product_query)) { $products_tax = $olPrice->TAX[$product['products_tax_class_id']]; $prid = $product['products_id']; if ($this->include_tax == TRUE_STRING_S) { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $total_price += olc_get_products_price($product['products_id'], $price_special = 0, $qty) + olc_calculate_tax(olc_get_products_price($product['products_id'], $price_special = 0, $qty), $products_tax); } else { $total_price += olc_get_products_price($product['products_id'], $price_special = 0, $qty); } } else { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) { $total_price += olc_get_products_price($product['products_id'], $price_special = 0, $qty) - olc_calculate_tax(olc_get_products_price($product['products_id'], $price_special = 0, $qty) / (100 + $products_tax) * 100, $products_tax); } else { $total_price += olc_get_products_price($product['products_id'], $price_special = 0, $qty); } } // attributes price if (isset($_SESSION['cart']->contents[$product_id]['attributes'])) { reset($_SESSION['cart']->contents[$product_id]['attributes']); while (list($option, $value) = each($_SESSION['cart']->contents[$product_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'] == '+') { if ($this->include_tax == TRUE_STRING_S) { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $total_price += olc_get_products_attribute_price($attribute_price['options_values_price'], $product['products_tax_class_id'], 0, $qty, $attribute_price['price_prefix']) + olc_calculate_tax(olc_get_products_attribute_price($attribute_price['options_values_price'], $product['products_tax_class_id'], 0, $qty, $attribute_price['price_prefix']), $products_tax); } else { $total_price += olc_get_products_attribute_price($attribute_price['options_values_price'], $product['products_tax_class_id'], 0, $qty, $attribute_price['price_prefix']); } } else { $total_price += olc_get_products_attribute_price($attribute_price['options_values_price'], '', 0, $qty, $attribute_price['price_prefix']); } } else { if ($this->include_tax == TRUE_STRING_S) { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $total_price -= olc_get_products_attribute_price($attribute_price['options_values_price'], $product['products_tax_class_id'], 0, $qty, $attribute_price['price_prefix']) + olc_calculate_tax(olc_get_products_attribute_price($attribute_price['options_values_price'], $product['products_tax_class_id'], 0, $qty, $attribute_price['price_prefix']), $products_tax); } else { $total_price -= olc_get_products_attribute_price($attribute_price['options_values_price'], $product['products_tax_class_id'], 0, $qty, $attribute_price['price_prefix']); } } else { $total_price -= olc_get_products_attribute_price($attribute_price['options_values_price'], '', 0, $qty, $attribute_price['price_prefix']); } } } } } return $total_price; }
function updateProducts(&$order) { // initialized for the email confirmation $this->products_ordered = ''; $subtotal = 0; $total_tax = 0; for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { // Stock Update - Joao Correia if (STOCK_LIMITED == TRUE_STRING_S) { if (DOWNLOAD_ENABLED == TRUE_STRING_S) { $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename\n FROM " . TABLE_PRODUCTS . " p\n LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n ON p.products_id=pa.products_id\n LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n ON pa.products_attributes_id=pad.products_attributes_id\n WHERE p.products_id = '" . olc_get_prid($order->products[$i]['id']) . APOS; // Will work with only one option for downloadable products // otherwise, we have to build the query dynamically with a loop $products_attributes = $order->products[$i]['attributes']; if (is_array($products_attributes)) { $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . APOS; } $stock_query = olc_db_query($stock_query_raw); } else { $stock_query = olc_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . olc_get_prid($order->products[$i]['id']) . APOS); } if (olc_db_num_rows($stock_query) > 0) { $stock_values = olc_db_fetch_array($stock_query); // do not decrement quantities if products_attributes_filename exists if (DOWNLOAD_ENABLED != TRUE_STRING_S || !$stock_values['products_attributes_filename']) { $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty']; } else { $stock_left = $stock_values['products_quantity']; } olc_db_query(SQL_UPDATE . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . olc_get_prid($order->products[$i]['id']) . APOS); if ($stock_left < 1 && STOCK_ALLOW_CHECKOUT == FALSE_STRING_S) { olc_db_query(SQL_UPDATE . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . olc_get_prid($order->products[$i]['id']) . APOS); } } } // Update products_ordered (for bestsellers list) olc_db_query(SQL_UPDATE . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . olc_get_prid($order->products[$i]['id']) . APOS); //------insert customer choosen option to order-------- $attributes_exist = '0'; $products_ordered_attributes = ''; if (isset($order->products[$i]['attributes'])) { $attributes_exist = '1'; for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) { if (DOWNLOAD_ENABLED == TRUE_STRING_S) { $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename\n from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n on pa.products_attributes_id=pad.products_attributes_id\n where pa.products_id = '" . $order->products[$i]['id'] . "'\n and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n and pa.options_id = popt.products_options_id\n and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n and pa.options_values_id = poval.products_options_values_id\n and popt.language_id = '" . $this->languageID . "'\n and poval.language_id = '" . $this->languageID . APOS; $attributes = olc_db_query($attributes_query); } else { $attributes = olc_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $this->languageID . "' and poval.language_id = '" . $this->languageID . APOS); } $attributes_values = olc_db_fetch_array($attributes); if (DOWNLOAD_ENABLED == TRUE_STRING_S && isset($attributes_values['products_attributes_filename']) && olc_not_null($attributes_values['products_attributes_filename'])) { $sql_data_array = array('orders_id' => $this->orderID, 'orders_products_id' => $order->products[$i]['orders_products_id'], 'orders_products_filename' => $attributes_values['products_attributes_filename'], 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount']); olc_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array); } $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name']; } } //------insert customer choosen option eof ---- $total_weight += $order->products[$i]['qty'] * $order->products[$i]['weight']; $total_tax += olc_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty']; $total_cost += $total_products_price; //$currency_price = $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']); $products_ordered_price = $this->displayPrice($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']); $this->products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . LPAREN . $order->products[$i]['model'] . ') = ' . $products_ordered_price . $products_ordered_attributes . NEW_LINE; } }