本文整理汇总了PHP中osC_Product::updateStock方法的典型用法代码示例。如果您正苦于以下问题:PHP osC_Product::updateStock方法的具体用法?PHP osC_Product::updateStock怎么用?PHP osC_Product::updateStock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osC_Product
的用法示例。
在下文中一共展示了osC_Product::updateStock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
function process($order_id, $status_id = '', $comments = '')
{
global $osC_Database;
if (empty($status_id) || is_numeric($status_id) === false) {
$status_id = DEFAULT_ORDERS_STATUS_ID;
}
$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, now(), :customer_notified, :comments)');
$Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
$Qstatus->bindInt(':orders_id', $order_id);
$Qstatus->bindInt(':orders_status_id', $status_id);
$Qstatus->bindInt(':customer_notified', SEND_EMAILS == '1' ? '1' : '0');
$Qstatus->bindValue(':comments', $comments);
$Qstatus->execute();
$Qupdate = $osC_Database->query('update :table_orders set orders_status = :orders_status where orders_id = :orders_id');
$Qupdate->bindTable(':table_orders', TABLE_ORDERS);
$Qupdate->bindInt(':orders_status', $status_id);
$Qupdate->bindInt(':orders_id', $order_id);
$Qupdate->execute();
$Qproducts = $osC_Database->query('select orders_products_id, products_id, products_quantity from :table_orders_products where orders_id = :orders_id');
$Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
$Qproducts->bindInt(':orders_id', $order_id);
$Qproducts->execute();
while ($Qproducts->next()) {
osC_Product::updateStock($order_id, $Qproducts->valueInt('orders_products_id'), $Qproducts->valueInt('products_id'), $Qproducts->valueInt('products_quantity'));
}
$order_status = self::getOrderStatusData($status_id);
if ($order_status['downloads_flag'] == 1) {
self::activeDownloadables($order_id);
}
if ($order_status['gift_certificates_flag'] == 1) {
self::activeGiftCertificates($order_id);
}
osC_Order::sendEmail($order_id);
unset($_SESSION['prepOrderID']);
}
示例2: addProduct
//.........这里部分代码省略.........
$Qinsert->bindInt(':products_id', $osC_Product->getID());
$Qinsert->bindValue(':products_sku', $osC_Product->getSKU());
$Qinsert->bindValue(':products_name', $osC_Product->getTitle());
$Qinsert->bindValue(':products_price', $products_price);
$Qinsert->bindValue(':final_price', $products_price);
$Qinsert->bindValue(':products_tax', $osC_Tax->getTaxRate($osC_Product->getTaxClassID(), $this->_shipping_address['country_id'], $this->_shipping_address['zone_id']));
$Qinsert->bindInt(':products_quantity', $quantity);
$Qinsert->bindInt(':products_type', $osC_Product->getProductType());
$Qinsert->execute();
if ($osC_Database->isError()) {
$error = true;
} else {
$orders_products_id = $osC_Database->nextID();
if (is_array($variants) && !empty($variants)) {
foreach ($variants as $groups_id => $values_id) {
$Qvariants = $osC_Database->query('select pvg.products_variants_groups_name, pvv.products_variants_values_name from :table_products_variants pv, :table_products_variants_entries pve, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_id = pve.products_variants_id and pve.products_variants_groups_id = :groups_id and pve.products_variants_values_id = :variants_values_id and pve.products_variants_groups_id = pvg.products_variants_groups_id and pve.products_variants_values_id = pvv.products_variants_values_id and pvg.language_id = :language_id and pvv.language_id = :language_id');
$Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
$Qvariants->bindTable(':table_products_variants_entries', TABLE_PRODUCTS_VARIANTS_ENTRIES);
$Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
$Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
$Qvariants->bindInt(':products_id', $osC_Product->getID());
$Qvariants->bindInt(':groups_id', $groups_id);
$Qvariants->bindInt(':variants_values_id', $values_id);
$Qvariants->bindInt(':language_id', $osC_Language->getID());
$Qvariants->bindInt(':language_id', $osC_Language->getID());
$Qvariants->execute();
$Qinsert = $osC_Database->query('insert into :table_orders_products_variants (orders_id, orders_products_id, products_variants_groups_id, products_variants_groups, products_variants_values_id, products_variants_values) values (:orders_id, :orders_products_id, :products_variants_groups_id, :products_variants_groups, :products_variants_values_id, :products_variants_values) ');
$Qinsert->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS);
$Qinsert->bindInt(':orders_id', $this->_order_id);
$Qinsert->bindInt(':orders_products_id', $orders_products_id);
$Qinsert->bindInt(':products_variants_groups_id', $groups_id);
$Qinsert->bindValue(':products_variants_groups', $Qvariants->value('products_variants_groups_name'));
$Qinsert->bindInt(':products_variants_values_id', $values_id);
$Qinsert->bindValue(':products_variants_values', $Qvariants->value('products_variants_values_name'));
$Qinsert->setLogging($_SESSION['module'], $this->_order_id);
$Qinsert->execute();
if ($osC_Database->isError()) {
$error = true;
break;
}
}
}
if ($error === false) {
if ($osC_Product->getProductType() == PRODUCT_TYPE_DOWNLOADABLE) {
$Qdownloadable = $osC_Database->query('select * from :table_products_downloadables where products_id = :products_id');
$Qdownloadable->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
$Qdownloadable->bindInt(':products_id', $products_id);
$Qdownloadable->execute();
$Qopd = $osC_Database->query('insert into :table_orders_products_download (orders_id, orders_products_id, orders_products_filename, orders_products_cache_filename, download_maxdays, download_count) values (:orders_id, :orders_products_id, :orders_products_filename, :orders_products_cache_filename, :download_maxdays, :download_count)');
$Qopd->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD);
$Qopd->bindInt(':orders_id', $_REQUEST['orders_id']);
$Qopd->bindInt(':orders_products_id', $orders_products_id);
$Qopd->bindValue(':orders_products_filename', $Qdownloadable->value('filename'));
$Qopd->bindValue(':orders_products_cache_filename', $Qdownloadable->value('cache_filename'));
$Qopd->bindValue(':download_maxdays', $Qdownloadable->valueInt('number_of_accessible_days'));
$Qopd->bindValue(':download_count', $Qdownloadable->valueInt('number_of_downloads'));
$Qopd->setLogging($_SESSION['module'], $this->_order_id);
$Qopd->execute();
if ($osC_Database->isError()) {
$error = true;
}
}
}
if ($error === false) {
if ($osC_Product->getProductType() == PRODUCT_TYPE_GIFT_CERTIFICATE) {
require_once '../includes/classes/gift_certificates.php';
$Qgc = $osC_Database->query('insert into :table_gift_certificates (orders_id, orders_products_id, gift_certificates_type, amount, gift_certificates_code, recipients_name, recipients_email, senders_name, senders_email, messages) values (:orders_id, :orders_products_id, :gift_certificates_type, :amount, :gift_certificates_code, :recipients_name, :recipients_email, :senders_name, :senders_email, :messages)');
$Qgc->bindTable(':table_gift_certificates', TABLE_GIFT_CERTIFICATES);
$Qgc->bindInt(':orders_id', $_REQUEST['orders_id']);
$Qgc->bindInt(':gift_certificates_type', $gift_certificate_data['type']);
$Qgc->bindInt(':orders_products_id', $orders_products_id);
$Qgc->bindValue(':amount', $gift_certificate_data['price']);
$Qgc->bindValue(':gift_certificates_code', toC_Gift_Certificates::createGiftCertificateCode());
$Qgc->bindValue(':recipients_name', $gift_certificate_data['recipients_name']);
$Qgc->bindValue(':recipients_email', $gift_certificate_data['recipients_email']);
$Qgc->bindValue(':senders_name', $gift_certificate_data['senders_name']);
$Qgc->bindValue(':senders_email', $gift_certificate_data['senders_email']);
$Qgc->bindValue(':messages', $gift_certificate_data['message']);
$Qgc->setLogging($_SESSION['module'], $this->_order_id);
$Qgc->execute();
if ($osC_Database->isError()) {
$error = true;
}
}
}
}
if ($error === false) {
$this->_contents[$products_id_string] = array('id' => $products_id, 'orders_products_id' => $orders_products_id, 'quantity' => $quantity, 'name' => $osC_Product->getTitle(), 'sku' => $osC_Product->getSKU($variants_array), 'tax' => $osC_Tax->getTaxRate($osC_Product->getTaxClassID(), $this->_shipping_address['country_id'], $this->_shipping_address['zone_id']), 'price' => $product_price, 'final_price' => $products_price, 'weight' => $osC_Product->getWeight($variants), 'tax_class_id' => $osC_Product->getTaxClassID(), 'weight_class_id' => $osC_Product->getWeightClass());
}
}
osC_Product::updateStock($this->_order_id, $orders_products_id, $products_id, $quantity);
if ($error === false) {
$osC_Database->commitTransaction();
$this->_calculate();
$this->updateOrderTotal();
return true;
}
$osC_Database->rollbackTransaction();
return false;
}