本文整理汇总了PHP中tep_get_prid函数的典型用法代码示例。如果您正苦于以下问题:PHP tep_get_prid函数的具体用法?PHP tep_get_prid怎么用?PHP tep_get_prid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tep_get_prid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_order_total
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 = tep_get_prid($products[$i]['id']);
$gv_query = tep_db_query("select products_price, products_tax_class_id, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
$gv_result = tep_db_fetch_array($gv_query);
if (ereg('^GIFT', addslashes($gv_result['products_model']))) {
$qty = $cart->get_quantity($t_prid);
$products_tax = tep_get_tax_rate($gv_result['products_tax_class_id']);
if ($this->include_tax == 'false') {
$gv_amount = $gv_result['products_price'] * $qty;
} else {
$gv_amount = ($gv_result['products_price'] + tep_calculate_tax($gv_result['products_price'], $products_tax)) * $qty;
}
$order_total = $order_total - $gv_amount;
}
}
if ($this->include_tax == 'false') {
$order_total = $order_total - $order->info['tax'];
}
if ($this->include_shipping == 'false') {
$order_total = $order_total - $order->info['shipping_cost'];
}
return $order_total;
}
示例2: calculate
function calculate()
{
$this->total = 0;
$this->weight = 0;
if (!is_array($this->contents)) {
return 0;
}
foreach (array_keys($this->contents) as $products_id) {
$qty = $this->contents[$products_id]['qty'];
// products price
$Qproduct = $this->db->get('products', ['products_id', 'products_price', 'products_tax_class_id', 'products_weight'], ['products_id' => (int) tep_get_prid($products_id)]);
if ($Qproduct->fetch() !== false) {
$prid = $Qproduct->valueInt('products_id');
$products_tax = tep_get_tax_rate($Qproduct->valueInt('products_tax_class_id'));
$products_price = $Qproduct->value('products_price');
$products_weight = $Qproduct->value('products_weight');
$Qspecials = $this->db->get('specials', 'specials_new_products_price', ['products_id' => $prid, 'status' => '1']);
if ($Qspecials->fetch() !== false) {
$products_price = $Qspecials->value('specials_new_products_price');
}
$this->total += tep_add_tax($products_price, $products_tax) * $qty;
$this->weight += $qty * $products_weight;
// attributes price
if (isset($this->contents[$products_id]['attributes'])) {
foreach ($this->contents[$products_id]['attributes'] as $option => $value) {
$Qattribute = $this->db->get('products_attributes', ['options_values_price', 'price_prefix'], ['products_id' => $prid, 'options_id' => (int) $option, 'options_values_id' => (int) $value]);
if ($Qattribute->value('price_prefix') == '+') {
$this->total += $qty * tep_add_tax($Qattribute->value('options_values_price'), $products_tax);
} else {
$this->total -= $qty * tep_add_tax($Qattribute->value('options_values_price'), $products_tax);
}
}
}
}
}
}
示例3: before_process
function before_process()
{
global $customer_id, $order, $order_totals, $sendto, $billto, $payment, $currencies;
global ${$payment};
$pass = false;
if (isset($_GET['transaction_id']) && isset($_GET['msid'])) {
if ($_GET['transaction_id'] == substr($GLOBALS[$this->_mbcartID], strpos($GLOBALS[$this->_mbcartID], '-') + 1)) {
if ($_GET['msid'] == strtoupper(md5(MODULE_PAYMENT_MONEYBOOKERS_MERCHANT_ID . $_GET['transaction_id'] . strtoupper(md5(MODULE_PAYMENT_MONEYBOOKERS_SECRET_WORD))))) {
$pass = true;
}
}
} elseif (isset($_GET['osig']) && $_GET['osig'] == md5(MODULE_PAYMENT_MONEYBOOKERS_SECRET_WORD . $GLOBALS[$this->_mbcartID])) {
$pass = true;
}
if ($pass == true) {
$order_id = substr($GLOBALS[$this->_mbcartID], strpos($GLOBALS[$this->_mbcartID], '-') + 1);
$check_query = tep_db_query("select orders_status from " . TABLE_ORDERS . " where orders_id = '" . (int) $order_id . "'");
if (tep_db_num_rows($check_query)) {
$check = tep_db_fetch_array($check_query);
if ($check['orders_status'] == MODULE_PAYMENT_MONEYBOOKERS_PREPARE_ORDER_STATUS_ID) {
$sql_data_array = array('orders_id' => $order_id, 'orders_status_id' => MODULE_PAYMENT_MONEYBOOKERS_PREPARE_ORDER_STATUS_ID, 'date_added' => 'now()', 'customer_notified' => '0', 'comments' => '');
tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
}
}
tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . (MODULE_PAYMENT_MONEYBOOKERS_ORDER_STATUS_ID > 0 ? (int) MODULE_PAYMENT_MONEYBOOKERS_ORDER_STATUS_ID : (int) DEFAULT_ORDERS_STATUS_ID) . "', last_modified = now() where orders_id = '" . (int) $order_id . "'");
$sql_data_array = array('orders_id' => $order_id, 'orders_status_id' => MODULE_PAYMENT_MONEYBOOKERS_ORDER_STATUS_ID > 0 ? (int) MODULE_PAYMENT_MONEYBOOKERS_ORDER_STATUS_ID : (int) DEFAULT_ORDERS_STATUS_ID, 'date_added' => 'now()', 'customer_notified' => SEND_EMAILS == 'true' ? '1' : '0', 'comments' => $order->info['comments']);
tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
// initialized for the email confirmation
$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') {
if (DOWNLOAD_ENABLED == 'true') {
$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 = '" . tep_get_prid($order->products[$i]['id']) . "'";
// 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'] . "'";
}
$stock_query = tep_db_query($stock_query_raw);
} else {
$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
}
if (tep_db_num_rows($stock_query) > 0) {
$stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
if (DOWNLOAD_ENABLED != 'true' || !$stock_values['products_attributes_filename']) {
$stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
} else {
$stock_left = $stock_values['products_quantity'];
}
tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
if ($stock_left < 1 && STOCK_ALLOW_CHECKOUT == 'false') {
tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
}
}
}
// Update products_ordered (for bestsellers list)
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
//------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') {
$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 = '" . $_SESSION['languages_id'] . "'\n and poval.language_id = '" . $_SESSION['languages_id'] . "'";
$attributes = tep_db_query($attributes_query);
} else {
$attributes = tep_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 = '" . $_SESSION['languages_id'] . "' and poval.language_id = '" . $_SESSION['languages_id'] . "'");
}
$attributes_values = tep_db_fetch_array($attributes);
$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 += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
$total_cost += $total_products_price;
$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
}
// lets start with the email confirmation
$email_order = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $order_id . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $order_id, 'SSL', false) . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
if ($order->info['comments']) {
$email_order .= tep_db_output($order->info['comments']) . "\n\n";
}
$email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n";
for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
$email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n";
}
if ($order->content_type != 'virtual') {
$email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";
}
$email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n";
if (is_object(${$payment})) {
$email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n";
$payment_class = ${$payment};
//.........这里部分代码省略.........
示例4: tep_db_fetch_array
if (tep_db_num_rows($stock_query) > 0) {
$stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
if (DOWNLOAD_ENABLED != 'true' || !$stock_values['products_attributes_filename']) {
$stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
} else {
$stock_left = $stock_values['products_quantity'];
}
tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
if ($stock_left < 1 && STOCK_ALLOW_CHECKOUT == 'false') {
tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
}
}
}
// Update products_ordered (for bestsellers list)
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
// Let's get all the info together for the email
$total_weight += $order->products[$i]['qty'] * $order->products[$i]['weight'];
$total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
$total_cost += $total_products_price;
// Let's get the attributes
$products_ordered_attributes = '';
if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0) {
for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
$products_ordered_attributes .= "\n\t" . $order->products[$i]['attributes'][$j]['option'] . ' ' . $order->products[$i]['attributes'][$j]['value'];
}
}
// Let's format the products model
$products_model = '';
if (!empty($order->products[$i]['model'])) {
$products_model = ' (' . $order->products[$i]['model'] . ')';
示例5: _process
function _process()
{
global $osC_Database, $osC_Session, $osC_Customer, $osC_Currencies, $cart, $order, $payment_modules, $shipping_modules, $order_total_modules;
// load selected payment module
require DIR_WS_CLASSES . 'payment.php';
$payment_modules = new payment($osC_Session->value('payment'));
// load the selected shipping module
require DIR_WS_CLASSES . 'shipping.php';
$shipping_modules = new shipping($osC_Session->value('shipping'));
$order = new order();
// load the before_process function from the payment modules
$payment_modules->before_process();
require DIR_WS_CLASSES . 'order_total.php';
$order_total_modules = new order_total();
$order_totals = $order_total_modules->process();
$Qorder = $osC_Database->query('insert into :table_orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, customers_ip_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, date_purchased, orders_status, currency, currency_value) values (:customers_id, :customers_name, :customers_company, :customers_street_address, :customers_suburb, :customers_city, :customers_postcode, :customers_state, :customers_country, :customers_telephone, :customers_email_address, :customers_address_format_id, :customers_ip_address, :delivery_name, :delivery_company, :delivery_street_address, :delivery_suburb, :delivery_city, :delivery_postcode, :delivery_state, :delivery_country, :delivery_address_format_id, :billing_name, :billing_company, :billing_street_address, :billing_suburb, :billing_city, :billing_postcode, :billing_state, :billing_country, :billing_address_format_id, :payment_method, :cc_type, :cc_owner, :cc_number, :cc_expires, :date_purchased, :orders_status, :currency, :currency_value)');
$Qorder->bindTable(':table_orders', TABLE_ORDERS);
$Qorder->bindInt(':customers_id', $osC_Customer->id);
$Qorder->bindValue(':customers_name', $order->customer['firstname'] . ' ' . $order->customer['lastname']);
$Qorder->bindValue(':customers_company', $order->customer['company']);
$Qorder->bindValue(':customers_street_address', $order->customer['street_address']);
$Qorder->bindValue(':customers_suburb', $order->customer['suburb']);
$Qorder->bindValue(':customers_city', $order->customer['city']);
$Qorder->bindValue(':customers_postcode', $order->customer['postcode']);
$Qorder->bindValue(':customers_state', $order->customer['state']);
$Qorder->bindValue(':customers_country', $order->customer['country']['title']);
$Qorder->bindValue(':customers_telephone', $order->customer['telephone']);
$Qorder->bindValue(':customers_email_address', $order->customer['email_address']);
$Qorder->bindInt(':customers_address_format_id', $order->customer['format_id']);
$Qorder->bindValue(':customers_ip_address', tep_get_ip_address());
$Qorder->bindValue(':delivery_name', $order->delivery['firstname'] . ' ' . $order->delivery['lastname']);
$Qorder->bindValue(':delivery_company', $order->delivery['company']);
$Qorder->bindValue(':delivery_street_address', $order->delivery['street_address']);
$Qorder->bindValue(':delivery_suburb', $order->delivery['suburb']);
$Qorder->bindValue(':delivery_city', $order->delivery['city']);
$Qorder->bindValue(':delivery_postcode', $order->delivery['postcode']);
$Qorder->bindValue(':delivery_state', $order->delivery['state']);
$Qorder->bindValue(':delivery_country', $order->delivery['country']['title']);
$Qorder->bindInt(':delivery_address_format_id', $order->delivery['format_id']);
$Qorder->bindValue(':billing_name', $order->billing['firstname'] . ' ' . $order->billing['lastname']);
$Qorder->bindValue(':billing_company', $order->billing['company']);
$Qorder->bindValue(':billing_street_address', $order->billing['street_address']);
$Qorder->bindValue(':billing_suburb', $order->billing['suburb']);
$Qorder->bindValue(':billing_city', $order->billing['city']);
$Qorder->bindValue(':billing_postcode', $order->billing['postcode']);
$Qorder->bindValue(':billing_state', $order->billing['state']);
$Qorder->bindValue(':billing_country', $order->billing['country']['title']);
$Qorder->bindInt(':billing_address_format_id', $order->billing['format_id']);
$Qorder->bindValue(':payment_method', $order->info['payment_method']);
$Qorder->bindValue(':cc_type', $order->info['cc_type']);
$Qorder->bindValue(':cc_owner', $order->info['cc_owner']);
$Qorder->bindValue(':cc_number', $order->info['cc_number']);
$Qorder->bindValue(':cc_expires', $order->info['cc_expires']);
$Qorder->bindRaw(':date_purchased', 'now()');
$Qorder->bindValue(':orders_status', $order->info['order_status']);
$Qorder->bindValue(':currency', $order->info['currency']);
$Qorder->bindValue(':currency_value', $order->info['currency_value']);
$Qorder->execute();
$insert_id = $osC_Database->nextID();
for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
$Qtotals = $osC_Database->query('insert into :table_orders_total (orders_id, title, text, value, class, sort_order) values (:orders_id, :title, :text, :value, :class, :sort_order)');
$Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
$Qtotals->bindInt(':orders_id', $insert_id);
$Qtotals->bindValue(':title', $order_totals[$i]['title']);
$Qtotals->bindValue(':text', $order_totals[$i]['text']);
$Qtotals->bindValue(':value', $order_totals[$i]['value']);
$Qtotals->bindValue(':class', $order_totals[$i]['code']);
$Qtotals->bindInt(':sort_order', $order_totals[$i]['sort_order']);
$Qtotals->execute();
}
$Qstatus = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, :date_added, :customer_notified, :comments)');
$Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
$Qstatus->bindInt(':orders_id', $insert_id);
$Qstatus->bindInt(':orders_status_id', $order->info['order_status']);
$Qstatus->bindRaw(':date_added', 'now()');
$Qstatus->bindInt(':customer_notified', SEND_EMAILS == 'true' ? '1' : '0');
$Qstatus->bindValue(':comments', $order->info['comments']);
$Qstatus->execute();
// initialized for the email confirmation
$products_ordered = '';
$subtotal = 0;
$total_tax = 0;
$total_weight = 0;
$total_cost = 0;
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
// Stock Update - Joao Correia
if (STOCK_LIMITED == 'true') {
if (DOWNLOAD_ENABLED == 'true') {
$Qstock = $osC_Database->query('select products_quantity, pad.products_attributes_filename from :table_products p left join :table_products_attributes pa on (p.products_id = pa.products_id) left join :table_products_attributes_download pad on (pa.products_attributes_id = pad.products_attributes_id) where p.products_id = :products_id');
$Qstock->bindTable(':table_products', TABLE_PRODUCTS);
$Qstock->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
$Qstock->bindTable(':table_products_attributes_download', TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD);
$Qstock->bindInt(':products_id', tep_get_prid($order->products[$i]['id']));
// 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)) {
$Qstock->appendQuery('and pa.options_id = :options_id and pa.options_values_id = :options_values_id');
$Qstock->bindInt(':options_id', $products_attributes[0]['option_id']);
$Qstock->bindInt(':options_values_id', $products_attributes[0]['value_id']);
}
//.........这里部分代码省略.........
示例6: before_process
function before_process()
{
/* ** Altered for CCGV **
global $customer_id, $order, $order_totals, $sendto, $billto, $languages_id, $payment, $currencies, $cart, $cart_PayPal_Standard_ID, $$payment, $HTTP_GET_VARS, $HTTP_POST_VARS, $messageStack;
$result = false;
*/
global $customer_id, $order, $order_totals, $sendto, $billto, $languages_id, $payment, $currencies, $cart, $cart_PayPal_Standard_ID, ${$payment}, $HTTP_GET_VARS, $HTTP_POST_VARS, $messageStack, $order_total_modules;
$result = false;
$order_total_modules->apply_credit();
/* **EOF alteration for CCGV ** */
if (isset($HTTP_POST_VARS['receiver_email']) && ($HTTP_POST_VARS['receiver_email'] == MODULE_PAYMENT_PAYPAL_STANDARD_ID || defined('MODULE_PAYMENT_PAYPAL_STANDARD_PRIMARY_ID') && tep_not_null(MODULE_PAYMENT_PAYPAL_STANDARD_PRIMARY_ID) && $HTTP_POST_VARS['receiver_email'] == MODULE_PAYMENT_PAYPAL_STANDARD_PRIMARY_ID)) {
$parameters = 'cmd=_notify-validate';
foreach ($HTTP_POST_VARS as $key => $value) {
$parameters .= '&' . $key . '=' . urlencode(stripslashes($value));
}
$result = $this->sendTransactionToGateway($this->form_action_url, $parameters);
}
if ($result != 'VERIFIED') {
if (defined('MODULE_PAYMENT_PAYPAL_STANDARD_TEXT_INVALID_TRANSACTION')) {
$messageStack->add_session('header', MODULE_PAYMENT_PAYPAL_STANDARD_TEXT_INVALID_TRANSACTION);
}
$this->sendDebugEmail($result);
tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
}
$this->verifyTransaction();
$order_id = substr($cart_PayPal_Standard_ID, strpos($cart_PayPal_Standard_ID, '-') + 1);
$check_query = tep_db_query("select orders_status from " . TABLE_ORDERS . " where orders_id = '" . (int) $order_id . "' and customers_id = '" . (int) $customer_id . "'");
if (!tep_db_num_rows($check_query) || $order_id != $HTTP_POST_VARS['invoice'] || $customer_id != $HTTP_POST_VARS['custom']) {
tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
}
$check = tep_db_fetch_array($check_query);
$new_order_status = DEFAULT_ORDERS_STATUS_ID;
if ($check['orders_status'] != MODULE_PAYMENT_PAYPAL_STANDARD_PREPARE_ORDER_STATUS_ID) {
$new_order_status = $check['orders_status'];
}
if (MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID > 0 && $check['orders_status'] == MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID) {
$new_order_status = MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID;
}
tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . (int) $new_order_status . "', last_modified = now() where orders_id = '" . (int) $order_id . "'");
$sql_data_array = array('orders_id' => $order_id, 'orders_status_id' => (int) $new_order_status, 'date_added' => 'now()', 'customer_notified' => SEND_EMAILS == 'true' ? '1' : '0', 'comments' => $order->info['comments']);
tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
// initialized for the email confirmation
$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') {
if (DOWNLOAD_ENABLED == 'true') {
$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 = '" . tep_get_prid($order->products[$i]['id']) . "'";
// 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'] . "'";
}
$stock_query = tep_db_query($stock_query_raw);
} else {
$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
}
if (tep_db_num_rows($stock_query) > 0) {
$stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
if (DOWNLOAD_ENABLED != 'true' || !$stock_values['products_attributes_filename']) {
$stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
} else {
$stock_left = $stock_values['products_quantity'];
}
tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
if ($stock_left < 1 && STOCK_ALLOW_CHECKOUT == 'false') {
tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
}
}
}
// Update products_ordered (for bestsellers list)
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
//------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') {
$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 = '" . $languages_id . "'\n and poval.language_id = '" . $languages_id . "'";
$attributes = tep_db_query($attributes_query);
} else {
$attributes = tep_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 = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
}
$attributes_values = tep_db_fetch_array($attributes);
$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 += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
$total_cost += $total_products_price;
$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
}
// lets start with the email confirmation
//.........这里部分代码省略.........
示例7: update_quantity
function update_quantity($products_id, $quantity = '', $attributes = '')
{
$OSCOM_Db = Registry::get('Db');
$products_id_string = tep_get_uprid($products_id, $attributes);
$products_id = tep_get_prid($products_id_string);
if (defined('MAX_QTY_IN_CART') && MAX_QTY_IN_CART > 0 && (int) $quantity > MAX_QTY_IN_CART) {
$quantity = MAX_QTY_IN_CART;
}
$attributes_pass_check = true;
if (is_array($attributes)) {
foreach ($attributes as $option => $value) {
if (!is_numeric($option) || !is_numeric($value)) {
$attributes_pass_check = false;
break;
}
}
}
if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity) && $attributes_pass_check == true) {
$this->contents[$products_id_string] = array('qty' => (int) $quantity);
// update database
if (isset($_SESSION['customer_id'])) {
$OSCOM_Db->save('customers_basket', ['customers_basket_quantity' => (int) $quantity], ['customers_id' => $_SESSION['customer_id'], 'products_id' => $products_id_string]);
}
if (is_array($attributes)) {
foreach ($attributes as $option => $value) {
$this->contents[$products_id_string]['attributes'][$option] = $value;
// update database
if (isset($_SESSION['customer_id'])) {
$OSCOM_Db->save('customers_basket_attributes', ['products_options_value_id' => (int) $value], ['customers_id' => $_SESSION['customer_id'], 'products_id' => $products_id_string, 'products_options_id' => (int) $option]);
}
}
}
// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
$this->cartID = $this->generate_cart_id();
}
}
示例8: count_contents_virtual
function count_contents_virtual()
{
// get total number of items in cart disregard gift vouchers
$total_items = 0;
if (is_array($this->contents)) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$no_count = false;
$gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
$gv_result = tep_db_fetch_array($gv_query);
if (ereg('^GIFT', $gv_result['products_model'])) {
$no_count = true;
}
if (defined('NO_COUNT_ZERO_WEIGHT') && NO_COUNT_ZERO_WEIGHT == 1) {
$gv_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($products_id) . "'");
$gv_result = tep_db_fetch_array($gv_query);
if ($gv_result['products_weight'] <= MINIMUM_WEIGHT) {
$no_count = true;
}
}
if (!$no_count) {
$total_items += $this->get_quantity($products_id);
}
}
}
return $total_items;
}
示例9: _build_attributes_combinations
function _build_attributes_combinations($attributes, $showoos, $markoos, &$combinations, &$selected_combination, $oidindex = 0, $comb = array(), $id = "", $text = '', $isselected = true)
{
global $cart;
foreach ($attributes[$oidindex]['ovals'] as $attrib) {
$newcomb = $comb;
$newcomb[$attributes[$oidindex]['oid']] = $attrib['id'];
$newid = $id . ',' . $attributes[$oidindex]['oid'] . '-' . $attrib['id'];
$newtext = $text . ", " . $attrib['text'];
if (isset($cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']])) {
$newisselected = $cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']] == $attrib['id'] ? $isselected : false;
} else {
$newisselected = false;
}
if (isset($attributes[$oidindex + 1])) {
$this->_build_attributes_combinations($attributes, $showoos, $markoos, $combinations, $selected_combination, $oidindex + 1, $newcomb, $newid, $newtext, $newisselected);
} else {
$is_out_of_stock = tep_check_stock(tep_get_prid($this->products_id), 1, $newcomb);
if (!$is_out_of_stock | $showoos == true) {
switch ($markoos) {
case 'Left':
$newtext = ($is_out_of_stock ? TEXT_OUT_OF_STOCK . ' - ' : '') . substr($newtext, 2);
break;
case 'Right':
$newtext = substr($newtext, 2) . ($is_out_of_stock ? ' - ' . TEXT_OUT_OF_STOCK : '');
break;
default:
$newtext = substr($newtext, 2);
break;
}
$combinations[] = array('comb' => $newcomb, 'id' => substr($newid, 1), 'text' => $newtext);
if ($newisselected) {
$selected_combination = sizeof($combinations) - 1;
}
}
}
}
}
示例10: get_rectricted_product_price_for_coupon
function get_rectricted_product_price_for_coupon($restrict_to_products)
{
global $order;
$i_get_rectricted_product_price_for_coupon = 0;
$pr_ids = explode(",", $restrict_to_products);
//print("<br><br>************************************<br><br>");
for ($io = 0; $io < count($order->products); $io++) {
$pr_c = $this->product_price(tep_get_prid($order->products[$io]['id']));
//print('order-products_id : '.$order->products[$io]['id'].'<br>');
//print('<xmp>');
//print_r($pr_ids);
//print('</xmp>');
//print('order-products_price :: pr_c : '.$pr_c.'<br>');
//print('i_get_rectricted_product_price_for_coupon :: pr_c : '.$i_get_rectricted_product_price_for_coupon.'<br>');
if (in_array($order->products[$io]['id'], $pr_ids)) {
//print(' pr_c : '.$pr_c.'<br>');
//print(' qty : '.$order->products[$io]['qty'].'<br>');
//print(' i_get_rectricted_product_price_for_coupon : '.$i_get_rectricted_product_price_for_coupon.'<br>');
$i_get_rectricted_product_price_for_coupon += $pr_c;
//print(' i_get_rectricted_product_price_for_coupon : '.$i_get_rectricted_product_price_for_coupon.'<br>');
}
}
//print("<br><br>************************************<br><br>");
return $i_get_rectricted_product_price_for_coupon;
}
示例11: update_quantity
function update_quantity($products_id, $quantity = '', $attributes = '')
{
global $customer_id;
$products_id_string = tep_get_uprid($products_id, $attributes);
$products_id = tep_get_prid($products_id_string);
$attributes_pass_check = true;
if (is_array($attributes)) {
reset($attributes);
while (list($option, $value) = each($attributes)) {
if (!is_numeric($option) || !is_numeric($value)) {
$attributes_pass_check = false;
break;
}
}
}
if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity) && $attributes_pass_check == true) {
$this->contents[$products_id_string] = array('qty' => $quantity);
// update database
if (tep_session_is_registered('customer_id')) {
tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int) $quantity . "' where customers_id = '" . (int) $customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "'");
}
if (is_array($attributes)) {
reset($attributes);
while (list($option, $value) = each($attributes)) {
$this->contents[$products_id_string]['attributes'][$option] = $value;
// update database
if (tep_session_is_registered('customer_id')) {
tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int) $value . "' where customers_id = '" . (int) $customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int) $option . "'");
}
}
}
}
}
示例12: while
<td class="productListing-heading"><?php
echo BOX_TEXT_PRICE;
?>
</td>
<td class="productListing-heading" align="center"><?php
echo BOX_TEXT_SELECT;
?>
</td>
</tr>
<?php
/*******************************************************************
***** LOOP THROUGH EACH PRODUCT ID TO DISPLAY IN THE WISHLIST ******
*******************************************************************/
$i = 0;
while ($wishlist = tep_db_fetch_array($wishlist_query)) {
$wishlist_id = tep_get_prid($wishlist['products_id']);
$products_query = tep_db_query("select pd.products_id, pd.products_name, pd.products_description, p.products_image, p.products_status, p.products_price, p.products_tax_class_id, IF(s.status = '1' and s.customers_group_id = '" . $customer_group_id . "', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on (p.products_id = s.products_id) where pd.products_id = '" . $wishlist_id . "' and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by products_name");
$products = tep_db_fetch_array($products_query);
if ($i / 2 == floor($i / 2)) {
$class = "productListing-even";
} else {
$class = "productListing-odd";
}
?>
<tr class="<?php
echo $class;
?>
">
<td valign="top" class="productListing-data-list" align="left"><a href="<?php
echo tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $wishlist['products_id'], 'NONSSL');
?>
示例13: getStock
function getStock($product_id)
{
$products_id = tep_get_prid($product_id);
if (isset($this->priceFormatterData[$products_id]) && tep_not_null($this->priceFormatterData[$products_id])) {
return $this->priceFormatterData[$products_id]['products_quantity'];
} else {
return false;
}
}
示例14: bts_select
// Most of this file is changed or moved to BTS - Basic Template System - format.
// For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).
// catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).
// (Sub 'fallback' with your current template to see if there is a template specific file.)
require 'includes/application_top.php';
require bts_select('language', FILENAME_WISHLIST);
if (!isset($_GET['public_id']) && !isset($_POST['add_wishprod'])) {
tep_redirect(tep_href_link(FILENAME_DEFAULT));
}
if (isset($_GET['public_id']) && $_GET['public_id'] == '') {
tep_redirect(tep_href_link(FILENAME_DEFAULT));
}
$public_id = $_GET['public_id'];
// QUERY CUSTOMER INFO FROM ID
$customer_query = tep_db_query("select customers_firstname from " . TABLE_CUSTOMERS . " where customers_id = '" . $public_id . "'");
$customer = tep_db_fetch_array($customer_query);
// ADD PRODUCT TO SHOPPING CART
if (isset($_POST['add_wishprod'])) {
if (isset($_POST['add_prod_x'])) {
foreach ($_POST['add_wishprod'] as $value) {
$product_id = tep_get_prid($value);
$cart->add_cart($product_id, $cart->get_quantity(tep_get_uprid($product_id, $_POST['id'][$value])) + 1, $_POST['id'][$value]);
}
tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
}
}
$breadcrumb->add(NAVBAR_TITLE_WISHLIST, tep_href_link(FILENAME_WISHLIST, '', 'SSL'));
$content = CONTENT_WISHLIST_PUBLIC;
include bts_select('main');
// BTSv1.5
require DIR_WS_INCLUDES . 'application_bottom.php';
示例15: before_process
function before_process()
{
global $customer_id, $order, $order_totals, $sendto, $billto, $languages_id, $payment, $currencies, $cart, $cart_PayPal_Standard_ID, $order_total_modules;
global ${$payment}, $onePageCheckout;
$order_id = substr($cart_PayPal_Standard_ID, strpos($cart_PayPal_Standard_ID, '-') + 1);
$check_query = tep_db_query("select orders_status from " . TABLE_ORDERS . " where orders_id = '" . (int) $order_id . "'");
if (tep_db_num_rows($check_query)) {
$check = tep_db_fetch_array($check_query);
if ($check['orders_status'] == MODULE_PAYMENT_PAYPAL_STANDARD_PREPARE_ORDER_STATUS_ID) {
$sql_data_array = array('orders_id' => $order_id, 'orders_status_id' => MODULE_PAYMENT_PAYPAL_STANDARD_PREPARE_ORDER_STATUS_ID, 'date_added' => 'now()', 'customer_notified' => '0', 'comments' => '');
tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
}
}
tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . (MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID > 0 ? (int) MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID : (int) DEFAULT_ORDERS_STATUS_ID) . "', last_modified = now() where orders_id = '" . (int) $order_id . "'");
$sql_data_array = array('orders_id' => $order_id, 'orders_status_id' => MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID > 0 ? (int) MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID : (int) DEFAULT_ORDERS_STATUS_ID, 'date_added' => 'now()', 'customer_notified' => SEND_EMAILS == 'true' ? '1' : '0', 'comments' => $order->info['comments']);
tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
// initialized for the email confirmation
$products_ordered = '';
$subtotal = 0;
$total_tax = 0;
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
// Stock Update - Joao Correia
//++++ QT Pro: Begin Changed code
$products_stock_attributes = null;
if (STOCK_LIMITED == 'true') {
$products_attributes = $order->products[$i]['attributes'];
// if (DOWNLOAD_ENABLED == 'true')
//++++ QT Pro: End Changed Code
$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 = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
//++++ QT Pro: Begin Changed code
// $products_attributes = $order->products[$i]['attributes'];
//++++ QT Pro: End Changed Code
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'] . "'";
}
$stock_query = tep_db_query($stock_query_raw);
} else {
$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
}
if (tep_db_num_rows($stock_query) > 0) {
$stock_values = tep_db_fetch_array($stock_query);
//++++ QT Pro: Begin Changed code
$actual_stock_bought = $order->products[$i]['qty'];
$download_selected = false;
if (DOWNLOAD_ENABLED == 'true' && isset($stock_values['products_attributes_filename']) && tep_not_null($stock_values['products_attributes_filename'])) {
$download_selected = true;
$products_stock_attributes = '$$DOWNLOAD$$';
}
// If not downloadable and attributes present, adjust attribute stock
if (!$download_selected && is_array($products_attributes)) {
$all_nonstocked = true;
$products_stock_attributes_array = array();
foreach ($products_attributes as $attribute) {
if ($attribute['track_stock'] == 1) {
$products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
$all_nonstocked = false;
}
}
if ($all_nonstocked) {
$actual_stock_bought = $order->products[$i]['qty'];
} else {
asort($products_stock_attributes_array, SORT_NUMERIC);
$products_stock_attributes = implode(",", $products_stock_attributes_array);
$attributes_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_stock_attributes = '{$products_stock_attributes}' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
if (tep_db_num_rows($attributes_stock_query) > 0) {
$attributes_stock_values = tep_db_fetch_array($attributes_stock_query);
$attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty'];
tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" . $attributes_stock_left . "' where products_stock_attributes = '{$products_stock_attributes}' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
$actual_stock_bought = $attributes_stock_left < 1 ? $attributes_stock_values['products_stock_quantity'] : $order->products[$i]['qty'];
} else {
$attributes_stock_left = 0 - $order->products[$i]['qty'];
tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " (products_id, products_stock_attributes, products_stock_quantity) values ('" . tep_get_prid($order->products[$i]['id']) . "', '" . $products_stock_attributes . "', '" . $attributes_stock_left . "')");
$actual_stock_bought = 0;
}
}
}
// $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
// }
// if (tep_db_num_rows($stock_query) > 0) {
// $stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
if (!$download_selected) {
$stock_left = $stock_values['products_quantity'] - $actual_stock_bought;
tep_db_query("UPDATE " . TABLE_PRODUCTS . " \n SET products_quantity = products_quantity - '" . $actual_stock_bought . "' \n WHERE products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
//++++ QT Pro: End Changed Code
if ($stock_left < 1 && STOCK_ALLOW_CHECKOUT == 'false') {
tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
}
}
}
// Update products_ordered (for bestsellers list)
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
//++++ QT Pro: Begin Changed code
if (!isset($products_stock_attributes)) {
$products_stock_attributes = null;
}
$sql_data_array = array('orders_id' => $insert_id, 'products_id' => tep_get_prid($order->products[$i]['id']), 'products_model' => $order->products[$i]['model'], 'products_name' => $order->products[$i]['name'], 'products_price' => $order->products[$i]['price'], 'final_price' => $order->products[$i]['final_price'], 'products_tax' => $order->products[$i]['tax'], 'products_quantity' => $order->products[$i]['qty'], 'products_stock_attributes' => $products_stock_attributes);
//++++ QT Pro: End Changed Code
//.........这里部分代码省略.........