コード例 #1
0
                     $row = $result->fields;
 					extract($row, EXTR_PREFIX_ALL, "opt");
 					$AddedOptionsPrice += $opt_options_values_price;
 					$option_value_details[$option_id][$option_value_id] = array ("options_values_price" => $opt_options_values_price);
 					$option_names[$option_id] = $opt_products_options_name;
 					$option_values_names[$option_value_id] = $opt_products_options_values_name;
 				}
 			} */
 // Get Product Info
 $InfoQuery = "select p.products_model,p.products_price,pd.products_name,p.products_tax_class_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on pd.products_id=p.products_id where p.products_id='{$add_product_products_id}'";
 $result = $db->Execute($InfoQuery);
 #$row = zen_db_fetch_array($result);
 extract($result->fields, EXTR_PREFIX_ALL, "p");
 // Following functions are defined at the bottom of this file
 $CountryID = zen_get_country_id($order->delivery["country"]);
 $ZoneID = zen_get_zone_id($CountryID, $order->delivery["state"]);
 $ProductsTax = zen_get_tax_rate($p_products_tax_class_id, $CountryID, $ZoneID);
 if ($_POST[applyspecialstoprice] && zen_get_products_special_price((int) $add_product_products_id)) {
     $product_price_woa = zen_get_products_special_price((int) $add_product_products_id);
 } else {
     $product_price_woa = $p_products_price;
 }
 $Query = "insert into " . TABLE_ORDERS_PRODUCTS . " set\n\t\t\t\torders_id = {$oID},\n\t\t\t\tproducts_id = {$add_product_products_id},\n\t\t\t\tproducts_model = '{$p_products_model}',\n\t\t\t\tproducts_name = '" . str_replace("'", "'", $p_products_name) . "',\n\t\t\t\tproducts_price = '{$product_price_woa}',\n\t\t\t\tfinal_price = '" . ($product_price_woa + $AddedOptionsPrice) . "',\n\t\t\t\tproducts_tax = '{$ProductsTax}',\n\t\t\t\tproducts_quantity = {$add_product_quantity},\n                                onetime_charges = {$AddedOptionsPrice_OneTime};";
 $db->Execute($Query);
 $new_product_id = zen_db_insert_id();
 //UPDATE_INVENTORY_QUANTITY_START##############################################################################################################
 if (STOCK_LIMITED == "true") {
     $db->Execute("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $add_product_quantity . ", products_ordered = products_ordered + " . $add_product_quantity . " where products_id = '" . $add_product_products_id . "'");
 } else {
     $db->Execute("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . $add_product_quantity . " where products_id = '" . $add_product_products_id . "'");
 }
コード例 #2
0
function eo_get_order_by_id($oID)
{
    global $db, $order;
    // Retrieve the order
    $order = new order($oID);
    // Add some required customer information for tax calculation
    // The next method has been modified to add required info to the
    // session and global variables.
    zen_get_tax_locations();
    // Cleanup tax_groups in the order (broken code in order.php)
    // Shipping module will automatically add tax if needed.
    $order->info['tax_groups'] = array();
    foreach ($order->products as $product) {
        eo_get_product_taxes($product);
    }
    // Correctly add the running subtotal (broken code in order.php)
    if (!array_key_exists('subtotal', $order->info)) {
        $query = $db->Execute('SELECT `value` FROM `' . TABLE_ORDERS_TOTAL . '` ' . 'WHERE `orders_id`=\'' . (int) $oID . '\' ' . 'AND `class`=\'ot_subtotal\'');
        if (!$query->EOF) {
            $order->info['subtotal'] = $query->fields['value'];
        }
    }
    // Convert country portion of addresses to same format used in catalog side
    $country = null;
    if (array_key_exists('country', $order->customer)) {
        $country = eo_get_country($order->customer['country']);
        if ($country !== null) {
            $order->customer['country'] = $country;
            $order->customer['zone_id'] = zen_get_zone_id($order->customer['country']['id'], $order->customer['state']);
        }
    }
    if (array_key_exists('country', $order->delivery)) {
        $country = eo_get_country($order->delivery['country']);
        if ($country !== null) {
            $order->delivery['country'] = $country;
            $order->delivery['zone_id'] = zen_get_zone_id($order->delivery['country']['id'], $order->delivery['state']);
        }
    }
    if (array_key_exists('country', $order->billing)) {
        $country = eo_get_country($order->billing['country']);
        if ($country !== null) {
            $order->billing['country'] = $country;
            $order->billing['zone_id'] = zen_get_zone_id($order->billing['country']['id'], $order->billing['state']);
        }
    }
    unset($country);
    // Handle shipping costs (module will automatically handle tax)
    if (!array_key_exists('shipping_cost', $order->info)) {
        $query = $db->Execute('SELECT `value` FROM `' . TABLE_ORDERS_TOTAL . '` ' . 'WHERE `orders_id` = \'' . (int) $oID . '\' ' . 'AND `class` = \'ot_shipping\'');
        if (!$query->EOF) {
            $order->info['shipping_cost'] = $query->fields['value'];
            $_SESSION['shipping'] = array('title' => $order->info['shipping_method'], 'id' => $order->info['shipping_module_code'] . '_', 'cost' => $order->info['shipping_cost']);
            // Load the shopping cart class into the session
            eo_shopping_cart();
            // Load the shipping class into the globals
            require_once DIR_FS_CATALOG . DIR_WS_CLASSES . 'shipping.php';
            $shipping_modules = new shipping($_SESSION['shipping']);
        }
    }
    return $order;
}
コード例 #3
0
ファイル: html_output.php プロジェクト: bitweaver/commerce
function zen_get_country_zone_list($pName, $pCountriesId, $pSelected = '', $pParameters = '')
{
    $ret = '';
    if ($zones = zen_get_country_zones($pCountriesId)) {
        $zoneArray = array(array('id' => '', 'text' => tra('Please Choose Your State or Province')));
        foreach ($zones as $zoneId => $zoneHash) {
            $zoneArray[] = array('id' => $zoneHash['zone_id'], 'text' => $zoneHash['zone_name']);
        }
        if (!empty($pSelected) && !is_numeric($pSelected)) {
            $pSelected = zen_get_zone_id($pCountriesId, $pSelected);
        }
        $ret = zen_draw_pull_down_menu($pName, $zoneArray, $pSelected, $pParameters);
    }
    return $ret;
}
コード例 #4
0
ファイル: CommerceOrder.php プロジェクト: bitweaver/commerce
 protected function load()
 {
     global $gBitDb, $gBitSystem;
     $ret = FALSE;
     if ($this->isValid()) {
         $selectSql = '';
         $joinSql = '';
         if ($gBitSystem->isPackageActive('stats')) {
             $selectSql .= " , sru.`referer_url` ";
             $joinSql .= " LEFT JOIN `" . BIT_DB_PREFIX . "stats_referer_users_map` srum ON (srum.`user_id`=uu.`user_id`) \n\t\t\t\t\t\t\t  LEFT JOIN `" . BIT_DB_PREFIX . "stats_referer_urls` sru ON (sru.`referer_url_id`=srum.`referer_url_id`) ";
         }
         $order_query = "SELECT co.*, uu.*, cpccl.`ref_id`, cpccl.`trans_result`, cpccl.`trans_auth_code`, cpccl.`trans_message`, cpccl.`trans_amount`, cpccl.`trans_date` {$selectSql}\n\t\t\t\t\t\t\tFROM " . TABLE_ORDERS . " co\n\t\t\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON(uu.`user_id`=co.`customers_id`)\n\t\t\t\t\t\t\t\t{$joinSql}\n\t\t\t\t\t\t\t\tLEFT JOIN `com_pubs_credit_card_log` cpccl ON(cpccl.`orders_id`=co.`orders_id` AND `trans_result`='0')\n\t\t\t\t\t\t\tWHERE co.`orders_id` = ?";
         $order = $gBitDb->query($order_query, array($this->mOrdersId));
         $totals_query = "SELECT `title`, `text`, `class`, `orders_value` FROM " . TABLE_ORDERS_TOTAL . " where `orders_id`=? ORDER BY `sort_order`";
         $totals = $gBitDb->query($totals_query, array($this->mOrdersId));
         while (!$totals->EOF) {
             $this->totals[] = array('title' => $totals->fields['title'], 'text' => $totals->fields['text'], 'class' => $totals->fields['class'], 'orders_value' => $totals->fields['orders_value']);
             $totals->MoveNext();
         }
         $order_total_query = "SELECT `text`, `orders_value` FROM " . TABLE_ORDERS_TOTAL . " where `orders_id` =? AND class = 'ot_total'";
         $order_total = $gBitDb->query($order_total_query, array($this->mOrdersId));
         $order_status_query = "select `orders_status_name` from " . TABLE_ORDERS_STATUS . " where `orders_status_id` = ? AND `language_id` = ?";
         $order_status = $gBitDb->query($order_status_query, array($order->fields['orders_status'], $_SESSION['languages_id']));
         $this->info = array('currency' => $order->fields['currency'], 'currency_value' => $order->fields['currency_value'], 'payment_method' => $order->fields['payment_method'], 'payment_module_code' => $order->fields['payment_module_code'], 'shipping_method' => $order->fields['shipping_method'], 'shipping_method_code' => $order->fields['shipping_method_code'], 'shipping_module_code' => $order->fields['shipping_module_code'], 'coupon_code' => $order->fields['coupon_code'], 'cc_type' => $order->fields['cc_type'], 'cc_owner' => $order->fields['cc_owner'], 'cc_number' => $order->fields['cc_number'], 'cc_expires' => $order->fields['cc_expires'], 'cc_ref_id' => $order->fields['ref_id'], 'date_purchased' => $order->fields['date_purchased'], 'orders_status_id' => $order->fields['orders_status'], 'orders_status' => $order_status->fields['orders_status_name'], 'last_modified' => $order->fields['last_modified'], 'total' => $order->fields['order_total'], 'tax' => $order->fields['order_tax'], 'ip_address' => $order->fields['ip_address']);
         $this->info['shipping_cost'] = $gBitDb->getOne("SELECT `orders_value` AS `shipping_cost` FROM " . TABLE_ORDERS_TOTAL . " WHERE `orders_id` = ? AND class = 'ot_shipping'", array($this->mOrdersId));
         $this->customer = array('id' => $order->fields['customers_id'], 'user_id' => $order->fields['user_id'], 'name' => $order->fields['customers_name'], 'real_name' => $order->fields['real_name'], 'login' => $order->fields['login'], 'company' => $order->fields['customers_company'], 'street_address' => $order->fields['customers_street_address'], 'suburb' => $order->fields['customers_suburb'], 'city' => $order->fields['customers_city'], 'postcode' => $order->fields['customers_postcode'], 'state' => $order->fields['customers_state'], 'country' => $order->fields['customers_country'], 'format_id' => $order->fields['customers_address_format_id'], 'telephone' => $order->fields['customers_telephone'], 'email_address' => $order->fields['email']);
         // 'email' comes from users_users, which is always most current
         if (!empty($order->fields['referer_url'])) {
             $this->customer['referer_url'] = $order->fields['referer_url'];
         }
         $this->delivery = array('name' => $order->fields['delivery_name'], 'company' => $order->fields['delivery_company'], 'street_address' => $order->fields['delivery_street_address'], 'suburb' => $order->fields['delivery_suburb'], 'city' => $order->fields['delivery_city'], 'postcode' => $order->fields['delivery_postcode'], 'state' => $order->fields['delivery_state'], 'country' => zen_get_countries($order->fields['delivery_country'], TRUE), 'zone_id' => zen_get_zone_id($order->fields['delivery_country'], $order->fields['delivery_state']), 'telephone' => $order->fields['delivery_telephone'], 'format_id' => $order->fields['delivery_address_format_id']);
         if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) {
             $this->delivery = false;
         }
         $this->billing = array('name' => $order->fields['billing_name'], 'company' => $order->fields['billing_company'], 'street_address' => $order->fields['billing_street_address'], 'suburb' => $order->fields['billing_suburb'], 'city' => $order->fields['billing_city'], 'postcode' => $order->fields['billing_postcode'], 'country' => zen_get_countries($order->fields['billing_country'], TRUE), 'state' => $order->fields['billing_state'], 'telephone' => $order->fields['billing_telephone'], 'format_id' => $order->fields['billing_address_format_id']);
         $orders_products_query = "SELECT op.*, pt.*, p.content_id, p.related_content_id, lc.user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_ORDERS_PRODUCTS . " op\n\t\t\t\t\t\t\t\t\tLEFT OUTER JOIN\t" . TABLE_PRODUCTS . " p ON ( op.`products_id`=p.`products_id` )\n\t\t\t\t\t\t\t\t\tLEFT OUTER JOIN\t" . TABLE_PRODUCT_TYPES . " pt ON ( p.`products_type`=pt.`type_id` )\n\t\t\t\t\t\t\t\t\tLEFT OUTER JOIN\t`" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id`=p.`content_id` )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `orders_id` = ?\n\t\t\t\t\t\t\t\tORDER BY op.`orders_products_id`";
         $orders_products = $this->mDb->query($orders_products_query, array($this->mOrdersId));
         while (!$orders_products->EOF) {
             // convert quantity to proper decimals - account history
             if (QUANTITY_DECIMALS != 0) {
                 $fix_qty = $orders_products->fields['products_quantity'];
                 switch (true) {
                     case !strstr($fix_qty, '.'):
                         $new_qty = $fix_qty;
                         break;
                     default:
                         $new_qty = preg_replace('/[0]+$/', '', $orders_products->fields['products_quantity']);
                         break;
                 }
             } else {
                 $new_qty = $orders_products->fields['products_quantity'];
             }
             $new_qty = round($new_qty, QUANTITY_DECIMALS);
             if ($new_qty == (int) $new_qty) {
                 $new_qty = (int) $new_qty;
             }
             $productsKey = $orders_products->fields['orders_products_id'];
             $this->contents[$productsKey] = $orders_products->fields;
             $this->contents[$productsKey]['products_quantity'] = $new_qty;
             $this->contents[$productsKey]['id'] = $orders_products->fields['products_id'];
             $this->contents[$productsKey]['name'] = $orders_products->fields['products_name'];
             $this->contents[$productsKey]['model'] = $orders_products->fields['products_model'];
             $this->contents[$productsKey]['tax'] = !empty($orders_products->fields['tax_rate']) ? $orders_products->fields['tax_rate'] : NULL;
             $this->contents[$productsKey]['price'] = $orders_products->fields['products_price'];
             $attributes_query = "SELECT opa.*, `orders_products_attributes_id` AS `products_attributes_id`\n\t\t\t\t\t\t\t\t\t FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa\n\t\t\t\t\t\t\t\t\t WHERE `orders_id` = ? AND `orders_products_id` = ?\n\t\t\t\t\t\t\t\t\t ORDER BY `orders_products_id`";
             $attributes = $this->mDb->query($attributes_query, array($this->mOrdersId, $orders_products->fields['orders_products_id']));
             if ($attributes->RecordCount()) {
                 while (!$attributes->EOF) {
                     $this->contents[$productsKey]['attributes'][] = array('options_id' => $attributes->fields['products_options_id'], 'options_values_id' => $attributes->fields['products_options_values_id'], 'option' => $attributes->fields['products_options'], 'value' => $attributes->fields['products_options_values'], 'prefix' => $attributes->fields['price_prefix'], 'final_price' => $this->getOrderAttributePrice($attributes->fields, $this->contents[$productsKey]), 'price' => $attributes->fields['options_values_price'], 'orders_products_attributes_id' => $attributes->fields['orders_products_attributes_id']);
                     $attributes->MoveNext();
                 }
             }
             $this->info['tax_groups']["{$this->contents[$productsKey]['tax']}"] = '1';
             $orders_products->MoveNext();
         }
         $ret = TRUE;
     }
     return $ret;
 }