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 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; }
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; } }
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' => ''); } } }
function calculate_tax_deduction($amount, $od_amount, $method) { global $order; $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); if ($get_result['coupon_type'] != 'S') { //RESTRICTION-------------------------------- if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) { // What to do here. // Loop through all products and build a list of all product_ids, price, tax class // at the same time create total net amount. // then // for percentage discounts. simply reduce tax group per product by discount percentage // or // for fixed payment amount // calculate ratio based on total net // for each product reduce tax group per product by ratio amount. $products = $_SESSION['cart']->get_products(); $valid_product = false; for ($i = 0; $i < sizeof($products); $i++) { $valid_product = false; $t_prid = olc_get_prid($products[$i]['id']); $cc_query = olc_db_query("select products_tax_class_id from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . APOS); $cc_result = olc_db_fetch_array($cc_query); if ($get_result['restrict_to_products']) { $pr_ids = split("[,]", $get_result['restrict_to_products']); for ($p = 0; $p < sizeof($pr_ids); $p++) { if ($pr_ids[$p] == $t_prid) { $valid_product = true; } } } if ($get_result['restrict_to_categories']) { $cat_ids = split("[,]", $get_result['restrict_to_categories']); for ($c = 0; $c < sizeof($cat_ids); $c++) { $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) { $valid_product = true; } } } if ($valid_product) { $price_excl_vat = $products[$i]['final_price'] * $products[$i]['quantity']; $price_incl_vat = $this->product_price($t_prid); $valid_array[] = array('product_id' => $t_prid, 'products_price' => $price_excl_vat, 'products_tax_class' => $cc_result['products_tax_class_id']); $total_price += $price_excl_vat; } } if (sizeof($valid_array) > 0) { // if ($valid_product) { if ($get_result['coupon_type'] == 'P') { $ratio = $get_result['coupon_amount'] / 100; } else { $ratio = $od_amount / $total_price; } if ($get_result['coupon_type'] == 'S') { $ratio = 1; } if ($method == 'Credit Note') { $tax_rate = 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']); if ($get_result['coupon_type'] == 'P') { $tod_amount = $od_amount / (100 + $tax_rate) * $tax_rate; } else { $tod_amount = $order->info['tax_groups'][$tax_desc] * $od_amount / 100; } $order->info['tax_groups'][$tax_desc] -= $tod_amount; $order->info['total'] -= $tod_amount; $order->info['tax'] -= $tod_amount; } else { for ($p = 0; $p < sizeof($valid_array); $p++) { $tax_rate = olc_get_tax_rate($valid_array[$p]['products_tax_class'], $order->delivery['country']['id'], $order->delivery['zone_id']); $tax_desc = olc_get_tax_description($valid_array[$p]['products_tax_class'], $order->delivery['country']['id'], $order->delivery['zone_id']); if ($tax_rate > 0) { $tod_amount = $valid_array[$p]['products_price'] * $tax_rate / 100 * $ratio; $order->info['tax_groups'][$tax_desc] -= $valid_array[$p]['products_price'] * $tax_rate / 100 * $ratio; $order->info['total'] -= $valid_array[$p]['products_price'] * $tax_rate / 100 * $ratio; $order->info['tax'] -= $valid_array[$p]['products_price'] * $tax_rate / 100 * $ratio; } } } } //NO RESTRICTION-------------------------------- } else { if ($get_result['coupon_type'] == 'F') { $tod_amount = 0; if ($method == 'Credit Note') { $tax_rate = 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 = $od_amount / (100 + $tax_rate) * $tax_rate; $order->info['tax_groups'][TAX_ADD_TAX . $tax_desc] -= $tod_amount; } else { reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $ratio1 = $od_amount / ($amount - $order->info['tax_groups'][$key]); $tax_rate = olc_get_tax_rate_from_desc(str_replace(TAX_ADD_TAX, "", $key)); $net = $tax_rate * $order->info['tax_groups'][$key]; if ($net > 0) { $god_amount = $od_amount * $tax_rate / (100 + $tax_rate); $tod_amount += $god_amount; $order->info['tax_groups'][$key] -= $god_amount; } } } $order->info['tax'] -= $tod_amount; } if ($get_result['coupon_type'] == 'P') { $tod_amount = 0; if ($method == 'Credit Note') { $tax_desc = olc_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $tod_amount = $order->info['tax_groups'][$tax_desc] * $od_amount / 100; $order->info['tax_groups'][TAX_ADD_TAX . $tax_desc] -= $tod_amount; } else { reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $god_amout = 0; $tax_rate = olc_get_tax_rate_from_desc(str_replace(TAX_ADD_TAX, "", $key)); $net = $tax_rate * $order->info['tax_groups'][$key]; if ($net > 0) { $god_amount = $order->info['tax_groups'][$key] * $get_result['coupon_amount'] / 100; $tod_amount += $god_amount; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } } $order->info['tax'] -= $tod_amount; } } } } return $tod_amount; }
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); } } } }