예제 #1
0
 function process()
 {
     global $order, $currencies;
     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'] - ($_SESSION['sppc_customer_group_show_tax'] == '1' ? 0 : $order->info['shipping_tax']) - $order->info['shipping_cost']) / $order->info['currency_value'] < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) {
         $tax = xos_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
         $tax_description = xos_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
         $tax_value = round($order->info['currency_value'] * xos_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
         $order->info['tax'] += $tax_value;
         $order->info['tax_groups']["{$tax_description}"] += $tax_value;
         $order->info['total'] += round($order->info['currency_value'] * MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $currencies->currencies[$_SESSION['currency']]['decimal_places']) + $tax_value;
         $this->output[] = array('title' => $this->title . ':', 'text' => $currencies->format(xos_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax), $order->info['currency_value']), 'value' => round(xos_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax) * $order->info['currency_value'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), 'tax' => xos_display_tax_value($tax));
     }
 }
예제 #2
0
 function process()
 {
     global $order, $currencies;
     $cod_country = false;
     if ($_SESSION['payment'] == 'cod') {
         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'] == 'usps_usps') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_USPS);
         }
         if ($_SESSION['shipping']['id'] == 'zones_zones') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ZONES);
         }
         if ($_SESSION['shipping']['id'] == 'free_free') {
             $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREE);
         }
         for ($i = 0; $i < count($cod_zones); $i++) {
             if ($cod_zones[$i] == $order->delivery['country']['iso_code_2']) {
                 $cod_cost = $cod_zones[$i + 1];
                 $cod_country = true;
                 break;
             } elseif ($cod_zones[$i] == '00') {
                 $cod_cost = $cod_zones[$i + 1];
                 $cod_country = true;
             }
             $i++;
         }
     }
     if ($cod_country) {
         $tax = xos_get_tax_rate(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
         $tax_description = xos_get_tax_description(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
         $tax_value = round($order->info['currency_value'] * xos_calculate_tax($cod_cost, $tax), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
         $order->info['tax'] += $tax_value;
         $order->info['tax_groups']["{$tax_description}"] += $tax_value;
         $order->info['total'] += round($order->info['currency_value'] * $cod_cost, $currencies->currencies[$_SESSION['currency']]['decimal_places']) + $tax_value;
         $this->output[] = array('title' => $this->title . ':', 'text' => $currencies->format(xos_add_tax($cod_cost, $tax), $order->info['currency_value']), 'value' => round(xos_add_tax($cod_cost, $tax) * $order->info['currency_value'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), 'tax' => xos_display_tax_value($tax));
     }
 }
예제 #3
0
 function process()
 {
     global $order, $currencies;
     if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
         switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
             case 'national':
                 if ($order->delivery['country_id'] == STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'international':
                 if ($order->delivery['country_id'] != STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'both':
                 $pass = true;
                 break;
             default:
                 $pass = false;
                 break;
         }
         if ($pass == true && $_SESSION['cart']->get_content_type() != 'virtual' && $order->info['subtotal'] >= $currencies->currencies[$_SESSION['currency']]['value'] * MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {
             $order->info['shipping_method'] = FREE_SHIPPING_TITLE;
             //          $order->info['total'] -= $order->info['shipping_cost'];
             $order->info['shipping_cost'] = 0;
         }
     }
     $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
     if (xos_not_null($order->info['shipping_method'])) {
         $order->info['shipping_cost'] = $order->info['currency_value'] * $order->info['shipping_cost'];
         //        if ($GLOBALS[$module]->tax_class > 0) {
         $shipping_tax = xos_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
         $shipping_tax_description = xos_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
         $shipping_tax_value = xos_calculate_tax($order->info['shipping_cost'], $shipping_tax);
         $order->info['tax'] += $order->info['shipping_tax'] = $shipping_tax_value;
         $order->info['tax_groups']["{$shipping_tax_description}"] += $shipping_tax_value;
         $order->info['total'] += $shipping_tax_value;
         if ($_SESSION['sppc_customer_group_show_tax'] == '1') {
             $order->info['shipping_cost'] += $shipping_tax_value;
         }
         //        }
         $this->output[] = array('title' => $order->info['shipping_method'] . ':', 'text' => $currencies->format($order->info['shipping_cost']), 'value' => $order->info['shipping_cost'], 'tax' => $order->info['shipping_method'] == FREE_SHIPPING_TITLE || strpos($order->info['shipping_method'], MODULE_SHIPPING_STORE_PICKUP_TEXT_TITLE) !== false && $order->info['shipping_cost'] == 0 ? -1 : xos_display_tax_value($shipping_tax));
     }
 }
예제 #4
0
 function calculate($crrency_value = 1)
 {
     global $customer_group_id, $currencies;
     $this->total = 0;
     $this->discount = 0;
     $this->weight = 0;
     $this->tax_groups = array();
     if (!is_array($this->contents)) {
         return 0;
     }
     $tax_address_query = xos_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "' and ab.address_book_id = '" . (int) ($this->get_content_type() == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . "'");
     $tax_address = xos_db_fetch_array($tax_address_query);
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $shown_price = 0;
         $shown_product_price = 0;
         $shown_attribute_price = 0;
         $qty = $this->contents[$products_id]['qty'];
         // products price
         $product_query = xos_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'");
         if ($product = xos_db_fetch_array($product_query)) {
             $prid = $product['products_id'];
             $products_tax = xos_get_tax_rate($product['products_tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']);
             $tax_description = xos_get_tax_description($product['products_tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']);
             $products_weight = $product['products_weight'];
             $products_prices = xos_get_product_prices($product['products_price']);
             if (isset($products_prices[$customer_group_id][0])) {
                 $products_prices[$customer_group_id]['special_status'] == 1 && $products_prices[$customer_group_id][0]['special'] > 0 ? $products_price = $products_prices[$customer_group_id][0]['special'] : ($products_price = $products_prices[$customer_group_id][0]['regular']);
                 $sizeof = count($products_prices[$customer_group_id]);
                 if ($sizeof > 2) {
                     $array_keys = array_keys($products_prices[$customer_group_id]);
                     for ($count = 2, $n = $sizeof; $count < $n; $count++) {
                         $quantity = $array_keys[$count];
                         if ($this->contents[$products_id]['qty'] >= $quantity) {
                             $products_prices[$customer_group_id]['special_status'] == 1 && $products_prices[$customer_group_id][$quantity]['special'] > 0 ? $products_price = $products_prices[$customer_group_id][$quantity]['special'] : ($products_price = $products_prices[$customer_group_id][$quantity]['regular']);
                         }
                     }
                 }
             } else {
                 $products_prices[0]['special_status'] == 1 && $products_prices[0][0]['special'] > 0 ? $products_price = $products_prices[0][0]['special'] : ($products_price = $products_prices[0][0]['regular']);
                 $sizeof = count($products_prices[0]);
                 if ($sizeof > 2) {
                     $array_keys = array_keys($products_prices[0]);
                     for ($count = 2, $n = $sizeof; $count < $n; $count++) {
                         $quantity = $array_keys[$count];
                         if ($this->contents[$products_id]['qty'] >= $quantity) {
                             $products_prices[0]['special_status'] == 1 && $products_prices[0][$quantity]['special'] > 0 ? $products_price = $products_prices[0][$quantity]['special'] : ($products_price = $products_prices[0][$quantity]['regular']);
                         }
                     }
                 }
             }
             $this->total += $shown_product_price = xos_add_tax($crrency_value * $products_price, $products_tax) * $qty;
             $this->weight += $qty * $products_weight;
         }
         // attributes price
         if (isset($this->contents[$products_id]['attributes'])) {
             reset($this->contents[$products_id]['attributes']);
             while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
                 $attribute_price_query = xos_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int) $prid . "' and options_id = '" . (int) $option . "' and options_values_id = '" . (int) $value . "'");
                 $attribute_price = xos_db_fetch_array($attribute_price_query);
                 if ($attribute_price['price_prefix'] == '+') {
                     $shown_attribute_price += $qty * xos_add_tax($crrency_value * $attribute_price['options_values_price'], $products_tax);
                 } else {
                     $shown_attribute_price -= $qty * xos_add_tax($crrency_value * $attribute_price['options_values_price'], $products_tax);
                 }
             }
             $this->total += $shown_attribute_price;
         }
         $shown_price = $shown_product_price + $shown_attribute_price;
         if ($_SESSION['sppc_customer_group_show_tax'] == '1') {
             if (isset($this->tax_groups["{$tax_description}"])) {
                 $this->tax_groups["{$tax_description}"] += round($shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             } else {
                 $this->tax_groups["{$tax_description}"] = round($shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             }
         } else {
             if (isset($this->tax_groups["{$tax_description}"])) {
                 $this->tax_groups["{$tax_description}"] += round($products_tax / 100 * $shown_price, $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             } else {
                 $this->tax_groups["{$tax_description}"] = round($products_tax / 100 * $shown_price, $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             }
         }
     }
     if ($_SESSION['sppc_customer_group_discount'] > 0) {
         $this->total -= $this->discount = $this->total / 100 * $_SESSION['sppc_customer_group_discount'];
         $this->discount = 0 - $this->discount;
         reset($this->tax_groups);
         while (list($key, $value) = each($this->tax_groups)) {
             if ($value > 0) {
                 $this->tax_groups["{$key}"] -= round($value / 100 * $_SESSION['sppc_customer_group_discount'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             }
         }
     }
 }
예제 #5
0
 function cart()
 {
     global $currencies;
     $this->content_type = $_SESSION['cart']->get_content_type();
     if ($this->content_type != 'virtual' && $_SESSION['sendto'] == false) {
         $_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
     }
     $customer_address_query = xos_db_query("select c.customers_c_id, c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int) $_SESSION['customer_id'] . "' and ab.customers_id = '" . (int) $_SESSION['customer_id'] . "' and c.customers_default_address_id = ab.address_book_id");
     $customer_address = xos_db_fetch_array($customer_address_query);
     if (is_array($_SESSION['sendto']) && !empty($_SESSION['sendto'])) {
         $shipping_address = array('entry_firstname' => $_SESSION['sendto']['firstname'], 'entry_lastname' => $_SESSION['sendto']['lastname'], 'entry_company' => $_SESSION['sendto']['company'], 'entry_street_address' => $_SESSION['sendto']['street_address'], 'entry_suburb' => $_SESSION['sendto']['suburb'], 'entry_postcode' => $_SESSION['sendto']['postcode'], 'entry_city' => $_SESSION['sendto']['city'], 'entry_zone_id' => $_SESSION['sendto']['zone_id'], 'zone_name' => $_SESSION['sendto']['zone_name'], 'entry_country_id' => $_SESSION['sendto']['country_id'], 'countries_id' => $_SESSION['sendto']['country_id'], 'countries_name' => $_SESSION['sendto']['country_name'], 'countries_iso_code_2' => $_SESSION['sendto']['country_iso_code_2'], 'countries_iso_code_3' => $_SESSION['sendto']['country_iso_code_3'], 'address_format_id' => $_SESSION['sendto']['address_format_id'], 'entry_state' => $_SESSION['sendto']['zone_name']);
     } elseif (is_numeric($_SESSION['sendto'])) {
         $shipping_address_query = xos_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "' and ab.address_book_id = '" . (int) $_SESSION['sendto'] . "'");
         $shipping_address = xos_db_fetch_array($shipping_address_query);
     } else {
         $shipping_address = array('entry_firstname' => null, 'entry_lastname' => null, 'entry_company' => null, 'entry_street_address' => null, 'entry_suburb' => null, 'entry_postcode' => null, 'entry_city' => null, 'entry_zone_id' => null, 'zone_name' => null, 'entry_country_id' => null, 'countries_id' => null, 'countries_name' => null, 'countries_iso_code_2' => null, 'countries_iso_code_3' => null, 'address_format_id' => 0, 'entry_state' => null);
     }
     if (is_array($_SESSION['billto']) && !empty($_SESSION['billto'])) {
         $billing_address = array('entry_firstname' => $_SESSION['billto']['firstname'], 'entry_lastname' => $_SESSION['billto']['lastname'], 'entry_company' => $_SESSION['billto']['company'], 'entry_street_address' => $_SESSION['billto']['street_address'], 'entry_suburb' => $_SESSION['billto']['suburb'], 'entry_postcode' => $_SESSION['billto']['postcode'], 'entry_city' => $_SESSION['billto']['city'], 'entry_zone_id' => $_SESSION['billto']['zone_id'], 'zone_name' => $_SESSION['billto']['zone_name'], 'entry_country_id' => $_SESSION['billto']['country_id'], 'countries_id' => $_SESSION['billto']['country_id'], 'countries_name' => $_SESSION['billto']['country_name'], 'countries_iso_code_2' => $_SESSION['billto']['country_iso_code_2'], 'countries_iso_code_3' => $_SESSION['billto']['country_iso_code_3'], 'address_format_id' => $_SESSION['billto']['address_format_id'], 'entry_state' => $_SESSION['billto']['zone_name']);
     } else {
         $billing_address_query = xos_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "' and ab.address_book_id = '" . (int) $_SESSION['billto'] . "'");
         $billing_address = xos_db_fetch_array($billing_address_query);
     }
     if ($this->content_type == 'virtual') {
         $tax_address = array('entry_country_id' => $billing_address['entry_country_id'], 'entry_zone_id' => $billing_address['entry_zone_id']);
     } else {
         $tax_address = array('entry_country_id' => $shipping_address['entry_country_id'], 'entry_zone_id' => $shipping_address['entry_zone_id']);
     }
     $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' => '', 'cc_owner' => '', 'cc_number' => '', 'cc_expires' => '', 'shipping_method' => $_SESSION['shipping']['title'], 'shipping_cost' => $_SESSION['shipping']['cost'], 'subtotal' => 0, 'tax' => 0, 'shipping_tax' => 0, 'discount' => 0, 'tax_groups' => array(), 'comments' => $_SESSION['comments']);
     if (isset($GLOBALS[$_SESSION['payment']]) && is_object($GLOBALS[$_SESSION['payment']])) {
         if (isset($GLOBALS[$_SESSION['payment']]->public_title)) {
             $this->info['payment_method'] = $GLOBALS[$_SESSION['payment']]->public_title;
         } else {
             $this->info['payment_method'] = $GLOBALS[$_SESSION['payment']]->title;
         }
         if (isset($GLOBALS[$_SESSION['payment']]->order_status) && is_numeric($GLOBALS[$_SESSION['payment']]->order_status) && $GLOBALS[$_SESSION['payment']]->order_status > 0) {
             $this->info['order_status'] = $GLOBALS[$_SESSION['payment']]->order_status;
         }
     }
     $this->customer = array('c_id' => $customer_address['customers_c_id'], 'firstname' => $customer_address['customers_firstname'], 'lastname' => $customer_address['customers_lastname'], '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' => xos_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']), 'country_id' => $customer_address['countries_id'], 'format_id' => $customer_address['address_format_id'], 'telephone' => $customer_address['customers_telephone'], 'email_address' => $customer_address['customers_email_address']);
     $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' => xos_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' => xos_not_null($billing_address['entry_state']) ? $billing_address['entry_state'] : $billing_address['zone_name'], 'zone_id' => $billing_address['entry_zone_id'], 'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']), 'country_id' => $billing_address['entry_country_id'], 'format_id' => $billing_address['address_format_id']);
     $index = 0;
     $products = $_SESSION['cart']->get_products($currencies->currencies[$_SESSION['currency']]['value']);
     for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
         $this->products[$index] = array('qty' => $products[$i]['quantity'], 'model' => $products[$i]['model'], 'name' => $products[$i]['name'], 'packaging_unit' => $products[$i]['packaging_unit'], 'delivery_time_id' => $products[$i]['delivery_time_id'], 'tax' => xos_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => xos_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['final_price'], 'price_formated' => $currencies->format($products[$i]['price']), 'final_price_formated' => $currencies->format($products[$i]['final_price']), 'total_price_formated' => $currencies->format($products[$i]['quantity'] * $products[$i]['final_price']), 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id']);
         if ($products[$i]['attributes']) {
             $subindex = 0;
             reset($products[$i]['attributes']);
             while (list($option, $value) = each($products[$i]['attributes'])) {
                 $attributes_price = '';
                 $attributes_query = xos_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 = '" . (int) $products[$i]['id'] . "' and pa.options_id = '" . (int) $option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int) $value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int) $_SESSION['languages_id'] . "' and poval.language_id = '" . (int) $_SESSION['languages_id'] . "'");
                 $attributes = xos_db_fetch_array($attributes_query);
                 $attributes_price = xos_add_tax($currencies->currencies[$_SESSION['currency']]['value'] * $attributes['options_values_price'], xos_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']));
                 $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, 'price_formated' => $currencies->format($attributes_price));
                 $subindex++;
             }
         }
         // $shown_price = $this->products[$index]['final_price'] * $this->products[$index]['qty'];
         $shown_price = round($this->products[$index]['final_price'] * $this->products[$index]['qty'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
         $this->info['subtotal'] += $shown_price;
         $products_tax = $this->products[$index]['tax'];
         $products_tax_description = $this->products[$index]['tax_description'];
         if ($_SESSION['sppc_customer_group_show_tax'] == '1') {
             $this->info['tax'] += $shown_price - round($shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             if (isset($this->info['tax_groups']["{$products_tax_description}"])) {
                 $this->info['tax_groups']["{$products_tax_description}"] += $shown_price - round($shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             } else {
                 $this->info['tax_groups']["{$products_tax_description}"] = $shown_price - round($shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             }
         } else {
             $this->info['tax'] += round($products_tax / 100 * $shown_price, $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             if (isset($this->info['tax_groups']["{$products_tax_description}"])) {
                 $this->info['tax_groups']["{$products_tax_description}"] += round($products_tax / 100 * $shown_price, $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             } else {
                 $this->info['tax_groups']["{$products_tax_description}"] = round($products_tax / 100 * $shown_price, $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             }
         }
         $index++;
     }
     if ($_SESSION['sppc_customer_group_discount'] > 0) {
         $this->info['subtotal'] -= $this->info['discount'] = round($this->info['subtotal'] / 100 * $_SESSION['sppc_customer_group_discount'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
         $this->info['discount'] = 0 - $this->info['discount'];
         reset($this->info['tax_groups']);
         while (list($key, $value) = each($this->info['tax_groups'])) {
             if ($value > 0) {
                 $discount_tax = round($value / 100 * $_SESSION['sppc_customer_group_discount'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
                 $this->info['tax_groups']["{$key}"] -= $discount_tax;
                 $this->info['tax'] -= $discount_tax;
             }
         }
     }
     if ($_SESSION['sppc_customer_group_show_tax'] == '1') {
         $this->info['total'] = $this->info['subtotal'] + round($this->info['currency_value'] * $this->info['shipping_cost'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
     } else {
         $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + round($this->info['currency_value'] * $this->info['shipping_cost'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
     }
 }