Ejemplo n.º 1
0
 function cart($customer_id = EMPTY_STRING)
 {
     global $currencies;
     if ($customer_id == EMPTY_STRING) {
         $customer_id = CUSTOMER_ID;
     }
     $this->content_type = $_SESSION['cart']->get_content_type();
     $customer_address_query = olc_db_query("\n\t\tselect\n\t\tc.customers_firstname,\n\t\tc.customers_cid,\n\t\tc.customers_gender,\n\t\tc.customers_lastname,\n\t\tc.customers_telephone,\n\t\tc.customers_email_address,\n\t\tc.customers_email_type,\n\t\tab.entry_company,\n\t\tab.entry_street_address,\n\t\tab.entry_suburb,\n\t\tab.entry_postcode,\n\t\tab.entry_city,\n\t\tab.entry_zone_id,\n\t\tab.entry_state,\n\t\tz.zone_name,\n\t\tco.countries_id,\n\t\tco.countries_name,\n\t\tco.countries_iso_code_2,\n\t\tco.countries_iso_code_3,\n\t\tco.address_format_id\n\t\tfrom " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab\n\t\tleft join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\t\tleft join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id)\n\t\twhere\n\t\tc.customers_id = '" . $customer_id . "'\n\t\tand ab.customers_id = '" . $customer_id . "'\n\t\tand c.customers_default_address_id = ab.address_book_id");
     $customer_address = olc_db_fetch_array($customer_address_query);
     $shipping_address_query = olc_db_query("\n\t\tselect\n\t\tab.entry_firstname,\n\t\tab.entry_lastname,\n\t\tab.entry_company,\n\t\tab.entry_street_address,\n\t\tab.entry_suburb,\n\t\tab.entry_postcode,\n\t\tab.entry_city,\n\t\tab.entry_zone_id,\n\t\tab.entry_country_id,\n\t\tab.entry_state,\n\t\tz.zone_name,\n\t\tc.countries_id,\n\t\tc.countries_name,\n\t\tc.countries_iso_code_2,\n\t\tc.countries_iso_code_3,\n\t\tc.address_format_id\n\t\tfrom " . TABLE_ADDRESS_BOOK . " ab\n\t\tleft join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\t\tleft join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id)\n\t\twhere\n\t\tab.customers_id = '" . $customer_id . "'\n\t\tand ab.address_book_id = '" . $_SESSION['sendto'] . APOS);
     $shipping_address = olc_db_fetch_array($shipping_address_query);
     $billing_address_query = olc_db_query("\n\t\tselect\n\t\tab.entry_firstname,\n\t\tab.entry_lastname,\n\t\tab.entry_company,\n\t\tab.entry_street_address,\n\t\tab.entry_suburb,\n\t\tab.entry_postcode,\n\t\tab.entry_city,\n\t\tab.entry_zone_id,\n\t\tab.entry_state,\n\t\tab.entry_country_id,\n\t\tz.zone_name,\n\t\tc.countries_id,\n\t\tc.countries_name,\n\t\tc.countries_iso_code_2,\n\t\tc.countries_iso_code_3,\n\t\tc.address_format_id\n\t\tfrom " . TABLE_ADDRESS_BOOK . " ab\n\t\tleft join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\t\tleft join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id)\n\t\twhere ab.customers_id = '" . $customer_id . "'\n\t\tand ab.address_book_id = '" . $_SESSION['billto'] . APOS);
     $billing_address = olc_db_fetch_array($billing_address_query);
     $tax_address_query = olc_db_query("\n\t\tselect\n\t\tab.entry_country_id,\n\t\tab.entry_zone_id\n\t\tfrom " . TABLE_ADDRESS_BOOK . " ab\n\t\tleft join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\n\t\twhere ab.customers_id = '" . $_SESSION['$customer_id'] . "' and ab.address_book_id = '" . ($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . APOS);
     $tax_address = olc_db_fetch_array($tax_address_query);
     $shipping = $_SESSION['shipping'];
     $shipping_class = $shipping['id'];
     //$shipping_class=$shipping['id'];
     $pos = strpos($shipping_class, UNDERSCORE);
     if ($pos > 0) {
         $shipping_class = substr($shipping_class, 0, $pos);
     }
     $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $_SESSION['currency'], 'currency_value' => $currencies->currencies[$_SESSION['currency']]['value'], 'payment_method' => $_SESSION['payment'], 'cc_type' => $GLOBALS['cc_type'], 'cc_owner' => $GLOBALS['cc_owner'], 'cc_number' => $GLOBALS['cc_number'], 'cc_expires' => $GLOBALS['cc_expires'], 'cc_start' => $GLOBALS['cc_start'], 'cc_issue' => $GLOBALS['cc_issue'], 'cc_cvv' => $GLOBALS['cc_cvv'], 'shipping_class' => $shipping_class, 'shipping_method' => $shipping['title'], 'shipping_cost' => $shipping['cost'], 'comments' => $_SESSION['comments'], 'payment_class' => $_SESSION['payment'], 'customers_order_reference' => $_SESSION['customers_order_reference']);
     if (isset($_SESSION['payment']) && is_object($_SESSION['payment'])) {
         $this->info['payment_method'] = $_SESSION['payment']->title;
         $this->info['payment_class'] = $_SESSION['payment']->title;
         if (isset($_SESSION['payment']->order_status) && is_numeric($_SESSION['payment']->order_status) && $_SESSION['payment']->order_status > 0) {
             $this->info['order_status'] = $_SESSION['payment']->order_status;
         }
     }
     $this->customer = array('firstname' => $customer_address['customers_firstname'], 'lastname' => $customer_address['customers_lastname'], 'csID' => $customer_address['customers_cid'], 'gender' => $customer_address['customers_gender'], 'company' => $customer_address['entry_company'], 'street_address' => $customer_address['entry_street_address'], 'suburb' => $customer_address['entry_suburb'], 'city' => $customer_address['entry_city'], 'postcode' => $customer_address['entry_postcode'], 'state' => olc_not_null($customer_address['entry_state']) ? $customer_address['entry_state'] : $customer_address['zone_name'], 'zone_id' => $customer_address['entry_zone_id'], 'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']), 'format_id' => $customer_address['address_format_id'], 'telephone' => $customer_address['customers_telephone'], 'email_address' => $customer_address['customers_email_address'], 'email_type' => $customer_address['customers_email_type']);
     $this->delivery = array('firstname' => $shipping_address['entry_firstname'], 'lastname' => $shipping_address['entry_lastname'], 'company' => $shipping_address['entry_company'], 'street_address' => $shipping_address['entry_street_address'], 'suburb' => $shipping_address['entry_suburb'], 'city' => $shipping_address['entry_city'], 'postcode' => $shipping_address['entry_postcode'], 'state' => olc_not_null($shipping_address['entry_state']) ? $shipping_address['entry_state'] : $shipping_address['zone_name'], 'zone_id' => $shipping_address['entry_zone_id'], 'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']), 'country_id' => $shipping_address['entry_country_id'], 'format_id' => $shipping_address['address_format_id']);
     $this->billing = array('firstname' => $billing_address['entry_firstname'], 'lastname' => $billing_address['entry_lastname'], 'company' => $billing_address['entry_company'], 'street_address' => $billing_address['entry_street_address'], 'suburb' => $billing_address['entry_suburb'], 'city' => $billing_address['entry_city'], 'postcode' => $billing_address['entry_postcode'], 'state' => olc_not_null($billing_address['entry_state']) ? $billing_address['entry_state'] : $billing_address['zone_name'], 'zone_id' => $billing_address['entry_zone_id'], 'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']), 'country_id' => $billing_address['entry_country_id'], 'format_id' => $billing_address['address_format_id']);
     $index = 0;
     $tax_country = $tax_address['entry_country_id'];
     $tax_zone = $tax_address['entry_zone_id'];
     $products = $_SESSION['cart']->get_products();
     for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
         $product = $products[$i];
         $quantity = $product['quantity'];
         $products_id = $product['id'];
         $price = olc_get_products_price($products_id, $price_special = 0, $quantity, $price_real);
         $price = abs($price_real);
         $products_attributes = $product['attributes'];
         if ($products_attributes) {
             $attributes_price = $_SESSION['cart']->attributes_price($products_id);
             if ((double) $attributes_price != 0) {
                 $attributes_price = olc_get_products_attribute_price_checkout($attributes_price, 0, 0, 1, EMPTY_STRING, false);
                 $price += $attributes_price;
             }
         }
         $final_price = $price * $quantity;
         $tax_class = $product['tax_class_id'];
         $this->products[$index] = array('qty' => $quantity, 'name' => $product['name'], 'model' => $product['model'], 'tax' => olc_get_tax_rate($tax_class, $tax_country, $tax_zone), 'tax_description' => olc_get_tax_description($tax_class, $tax_country, $tax_zone), 'price' => $price, 'final_price' => $final_price, 'weight' => $product['weight'], 'id' => $products_id, 'auctionid' => $product['auctionid']);
         if ($products_attributes) {
             $subindex = 0;
             reset($products_attributes);
             while (list($option, $value) = each($products_attributes)) {
                 $attributes_query = olc_db_query("\n\t\t\t\t\tselect\n\t\t\t\t\tpopt.products_options_name,\n\t\t\t\t\tpoval.products_options_values_name,\n\t\t\t\t\tpa.options_values_price,\n\t\t\t\t\tpa.price_prefix\n\t\t\t\t\tfrom " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\t\t\t\t\twhere\n\t\t\t\t\tpa.products_id = '" . $products_id . "' and pa.options_id = '" . $option . "'\n\t\t\t\t\tand pa.options_id = popt.products_options_id\n\t\t\t\t\tand pa.options_values_id = '" . $value . "'\n\t\t\t\t\tand pa.options_values_id = poval.products_options_values_id\n\t\t\t\t\tand popt.language_id = '" . SESSION_LANGUAGE_ID . "'\n\t\t\t\t\tand poval.language_id = '" . SESSION_LANGUAGE_ID . APOS);
                 $attributes = olc_db_fetch_array($attributes_query);
                 $attributes_price = $attributes['options_values_price'];
                 if ($attributes_price > 0) {
                     $attributes_price_prefix = $attributes['price_prefix'];
                 } else {
                     $attributes_price_prefix = EMPTY_STRING;
                 }
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'], 'value' => $attributes['products_options_values_name'], 'option_id' => $option, 'value_id' => $value, 'prefix' => $attributes['price_prefix'], 'price' => $attributes_price);
                 $subindex++;
             }
         }
         $subtotal += $final_price;
         $shown_price = $final_price;
         if (CUSTOMER_SHOW_OT_DISCOUNT) {
             $shown_price_tax = $shown_price - $shown_price / 100 * CUSTOMER_OT_DISCOUNT;
         }
         $products_tax = $this->products[$index]['tax'];
         $products_tax_description = $this->products[$index]['tax_description'];
         if (CUSTOMER_SHOW_PRICE_TAX) {
             if (CUSTOMER_SHOW_OT_DISCOUNT) {
                 $shown_price = $shown_price_tax;
             }
             $products_tax_1 = str_replace(DOT, EMPTY_STRING, $products_tax);
             $products_tax_1 = $products_tax < 10 ? "1.0" . $products_tax_1 : "1." . $products_tax_1;
             $this->info['tax'] += $shown_price - $shown_price / $products_tax_1;
             $this->info['tax_groups'][TAX_ADD_TAX . "{$products_tax_description}"] += $shown_price / (100 + $products_tax) * $products_tax;
         } else {
             if (CUSTOMER_SHOW_OT_DISCOUNT) {
                 $shown_price = $shown_price_tax;
             }
             $shown_price = $shown_price / 100 * $products_tax;
             $this->info['tax'] += $shown_price;
             $this->info['tax_groups'][TAX_NO_TAX . $products_tax_description] += $shown_price;
         }
         $index++;
     }
     $this->info['subtotal'] = $subtotal;
     $this->info['total'] = $subtotal + $this->info['shipping_cost'];
     if (CUSTOMER_SHOW_OT_DISCOUNT) {
         $discount = $subtotal * (CUSTOMER_OT_DISCOUNT / 100);
         $this->info['total'] -= $discount;
         $this->info['orders_discount'] = $discount;
     }
 }
        $total_price = $single_price;
    }
    $data_products .= '
					<tr>
						<td class="main" nowrap="nowrap" align="left" valign="top" width="">' . $products_qty . ' x ' . $order_products['name'] . '						</td>
						<td class="main" align="right" valign="top">' . $single_price . '</td>
						<td class="main" align="right" valign="top">' . $total_price . '</td>
					</tr>
';
    $products_attributes = $order_products['attributes'];
    if (sizeof($products_attributes) > 0) {
        for ($j = 0, $n2 = sizeof($products_attributes); $j < $n2; $j++) {
            $products_attribute = $products_attributes[$j];
            $products_attribute_price = $products_attribute['price'];
            if ($products_attribute_price != 0) {
                $products_attribute_price_single = olc_get_products_attribute_price_checkout($products_attribute_price, $order_products['tax'], 1, $products_qty, $products_attribute['prefix']);
                if ($products_qty != 1) {
                    $products_attribute_price_total = olc_format_price($products_attribute_price * $products_qty, true, true);
                } else {
                    $products_attribute_price_total = $products_attribute_price_single;
                }
            } else {
                $products_attribute_price = EMPTY_STRING;
            }
            $data_products .= '					<tr>
						<td class="main" align="left" valign="top">
							<nobr><small>&nbsp;<i> - ' . $products_attribute['option'] . COLON_BLANK . $products_attribute['value'] . '
							</i></small>
						</td>
						<td class="main" align="right" valign="top"><i><small>' . $products_attribute_price_single . '							</i></small></nobr>
						</td>