本文整理汇总了PHP中Message::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::update方法的具体用法?PHP Message::update怎么用?PHP Message::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processOrderStep
function processOrderStep($params)
{
global $cart, $smarty, $errors;
if (!isset($_POST['id_address_delivery']) or !Address::isCountryActiveById(intval($_POST['id_address_delivery']))) {
$errors[] = 'this address is not in a valid area';
} else {
$cart->id_address_delivery = intval($_POST['id_address_delivery']);
$cart->id_address_invoice = isset($_POST['same']) ? intval($_POST['id_address_delivery']) : intval($_POST['id_address_invoice']);
if (!$cart->update()) {
$errors[] = Tools::displayError('an error occured while updating your cart');
}
Module::hookExec('orderAddressVerification', array());
if (isset($_POST['message']) and !empty($_POST['message'])) {
if (!Validate::isMessage($_POST['message'])) {
$errors[] = Tools::displayError('invalid message');
} elseif ($oldMessage = Message::getMessageByCartId(intval($cart->id))) {
$message = new Message(intval($oldMessage['id_message']));
$message->message = htmlentities($_POST['message'], ENT_COMPAT, 'UTF-8');
$message->update();
} else {
$message = new Message();
$message->message = htmlentities($_POST['message'], ENT_COMPAT, 'UTF-8');
$message->id_cart = intval($cart->id);
$message->id_customer = intval($cart->id_customer);
$message->add();
}
}
}
}
示例2: updateMessage
public static function updateMessage($id, $text, $ticket = false)
{
$msg = new Message(array('id' => $id, 'text' => $text));
$msg->update();
$tick_no = null;
if ($ticket) {
$wlticket = new Ticket(array('message_id' => $id, 'title' => 'NIEUW', 'text' => $text, 'status_id' => 1));
$tick_no = $wlticket->create();
}
if ($tick_no) {
$msg->setTicket($tick_no);
}
return array('id' => $msg->id);
}
示例3: update
public static function update($id, $topic_id)
{
self::checkLoggedIn();
self::verifyRightsforDeletingOrEditingMessage($id);
$params = $_POST;
$attributes = array('id' => $id, 'author' => $params['author'], 'posted' => $params['posted'], 'message' => $params['message'], 'topic_id' => $params['topic_id']);
$message = new Message($attributes);
$errors = $message->errors();
if (count($errors) == 0) {
$message->update();
} else {
Redirect::to('/topics/' . $message->topic_id . '/' . $message->id . '/edit', array('errors' => $errors));
}
Redirect::to('/topics/' . $message->topic_id);
}
示例4: updateMessage
public static function updateMessage($id)
{
$params = $_POST;
$time = date('Y-m-d G:i:s');
$oldMessage = new Message(Message::find($id));
$attributes = $oldMessage->asArray();
$attributes['id'] = $id;
$attributes['content'] = $params['content'];
$attributes['modified'] = $time;
$message = new Message($attributes);
$errors = $message->errors();
if (count($errors) == 0) {
$message->update();
Redirect::to('/thread/' . $message->thread_id);
} else {
$message = Message::find($id);
View::make('thread/thread_edit.html', array('errors' => $errors, 'message' => $message, 'attributes' => $attributes));
}
}
示例5: _updateMessage
protected function _updateMessage($messageContent)
{
if ($messageContent) {
if (!Validate::isMessage($messageContent)) {
$this->errors[] = Tools::displayError('Invalid message');
} else {
if ($oldMessage = Message::getMessageByCartId((int) $this->context->cart->id)) {
$message = new Message((int) $oldMessage['id_message']);
$message->message = $messageContent;
$message->update();
} else {
$message = new Message();
$message->message = $messageContent;
$message->id_cart = (int) $this->context->cart->id;
$message->id_customer = (int) $this->context->cart->id_customer;
$message->add();
}
}
} else {
if ($oldMessage = Message::getMessageByCartId($this->context->cart->id)) {
$message = new Message($oldMessage['id_message']);
$message->delete();
}
}
return true;
}
示例6: foreach
foreach (R(new WassrAPI())->friends_timeline() as $message) {
$messages[] = Message::parse($message);
}
$messages = omerge($messages, "key");
rosort($messages, "created_at");
return $messages;
}
public static function update($text)
{
R(new TwitterAPI())->update($text);
R(new WassrAPI())->update($text);
}
}
$flow = new Flow();
if ($flow->isPost() && $flow->isVars("text")) {
Message::update($flow->inVars("text"));
$flow->redirect_self();
}
$flow->vars("messages", Message::friends_timeline());
//$flow->output(__FILE__);
exit;
?>
<rt:template>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="post">
<textarea rows="3" cols="50" name="text"></textarea>
<input type="submit" value="update" />
示例7: _updateMessage
protected function _updateMessage($messageContent)
{
if ($messageContent) {
if (!Validate::isMessage($messageContent)) {
$this->errors[] = Tools::displayError('Invalid message');
} elseif ($oldMessage = Message::getMessageByCartId((int) self::$cart->id)) {
$message = new Message((int) $oldMessage['id_message']);
$message->message = htmlentities($messageContent, ENT_COMPAT, 'UTF-8');
$message->update();
} else {
$message = new Message();
$message->message = htmlentities($messageContent, ENT_COMPAT, 'UTF-8');
$message->id_cart = (int) self::$cart->id;
$message->id_customer = (int) self::$cart->id_customer;
$message->add();
}
} else {
if ($oldMessage = Message::getMessageByCartId((int) self::$cart->id)) {
$message = new Message((int) $oldMessage['id_message']);
$message->delete();
}
}
return true;
}
示例8: validateOrder
/**
* Validate an order in database
* Function called from a payment module
*
* @param integer $id_cart Value
* @param integer $id_order_state Value
* @param float $amountPaid Amount really paid by customer (in the default currency)
* @param string $paymentMethod Payment method (eg. 'Credit cart')
* @param string $message Message to attach to order
*/
function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false)
{
global $cart;
$cart = new Cart(intval($id_cart));
// Does order already exists ?
if (Validate::isLoadedObject($cart) and $cart->OrderExists() === 0) {
// Copying data from cart
$order = new Order();
$order->id_carrier = intval($cart->id_carrier);
$order->id_customer = intval($cart->id_customer);
$order->id_address_invoice = intval($cart->id_address_invoice);
$order->id_address_delivery = intval($cart->id_address_delivery);
$vat_address = new Address(intval($order->id_address_delivery));
$id_zone = Address::getZoneById(intval($vat_address->id));
$order->id_currency = $currency_special ? intval($currency_special) : intval($cart->id_currency);
$order->id_lang = intval($cart->id_lang);
$order->id_cart = intval($cart->id);
$customer = new Customer(intval($order->id_customer));
$order->secure_key = pSQL($customer->secure_key);
$order->payment = Tools::substr($paymentMethod, 0, 32);
if (isset($this->name)) {
$order->module = $this->name;
}
$order->recyclable = $cart->recyclable;
$order->gift = intval($cart->gift);
$order->gift_message = $cart->gift_message;
$currency = new Currency($order->id_currency);
$amountPaid = !$dont_touch_amount ? Tools::ps_round(floatval($amountPaid), 2) : $amountPaid;
$order->total_paid_real = $amountPaid;
$order->total_products = floatval($cart->getOrderTotal(false, 1));
$order->total_products_wt = floatval($cart->getOrderTotal(true, 1));
$order->total_discounts = floatval(abs($cart->getOrderTotal(true, 2)));
$order->total_shipping = floatval($cart->getOrderShippingCost());
$order->total_wrapping = floatval(abs($cart->getOrderTotal(true, 6)));
$order->total_paid = floatval(Tools::ps_round(floatval($cart->getOrderTotal(true, 3)), 2));
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
// Amount paid by customer is not the right one -> Status = payment error
if ($order->total_paid != $order->total_paid_real) {
$id_order_state = _PS_OS_ERROR_;
}
// Creating order
if ($cart->OrderExists() === 0) {
$result = $order->add();
} else {
die(Tools::displayError('An order has already been placed using this cart'));
}
// Next !
if ($result and isset($order->id)) {
// Optional message to attach to this order
if (isset($message) and !empty($message)) {
$msg = new Message();
$message = strip_tags($message, '<br>');
if (!Validate::isCleanHtml($message)) {
$message = $this->l('Payment message is not valid, please check your module!');
}
$msg->message = $message;
$msg->id_order = intval($order->id);
$msg->private = 1;
$msg->add();
}
// Insert products from cart into order_detail table
$products = $cart->getProducts();
$productsList = '';
$db = Db::getInstance();
$query = 'INSERT INTO `' . _DB_PREFIX_ . 'order_detail`
(`id_order`, `product_id`, `product_attribute_id`, `product_name`, `product_quantity`, `product_quantity_in_stock`, `product_price`, `reduction_percent`, `reduction_amount`, `product_quantity_discount`, `product_ean13`, `product_reference`, `product_supplier_reference`, `product_weight`, `tax_name`, `tax_rate`, `ecotax`, `discount_quantity_applied`, `download_deadline`, `download_hash`)
VALUES ';
$customizedDatas = Product::getAllCustomizedDatas(intval($order->id_cart));
Product::addCustomizationPrice($products, $customizedDatas);
foreach ($products as $key => $product) {
$outOfStock = false;
$productQuantity = intval(Product::getQuantity(intval($product['id_product']), $product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL));
$quantityInStock = $productQuantity - intval($product['cart_quantity']) < 0 ? $productQuantity : intval($product['cart_quantity']);
if ($id_order_state != _PS_OS_CANCELED_ and $id_order_state != _PS_OS_ERROR_) {
if (($updateResult = Product::updateQuantity($product)) === false or $updateResult === -1) {
$outOfStock = true;
}
if (!$outOfStock) {
$product['stock_quantity'] -= $product['cart_quantity'];
}
Hook::updateQuantity($product, $order);
}
$price = Product::getPriceStatic(intval($product['id_product']), false, $product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL, 6, NULL, false, true, $product['cart_quantity'], false, intval($order->id_customer), intval($order->id_cart), intval($order->id_address_delivery));
$price_wt = Product::getPriceStatic(intval($product['id_product']), true, $product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL, 2, NULL, false, true, $product['cart_quantity'], false, intval($order->id_customer), intval($order->id_cart), intval($order->id_address_delivery));
// Add some informations for virtual products
$deadline = '0000-00-00 00:00:00';
$download_hash = NULL;
if ($id_product_download = ProductDownload::getIdFromIdProduct(intval($product['id_product']))) {
$productDownload = new ProductDownload(intval($id_product_download));
//.........这里部分代码省略.........
示例9: audit
/**
* 审核,打回
*
* @param $audit int 操作状态 1审核 2打回
* @return $arr array id=>ids,status=>回调状态标识
*/
public function audit()
{
$ids = urldecode($this->input['id']);
if (!$ids) {
$this->errorOutput(NOID);
}
$tableName = $this->input['tablename'];
if (!$tableName) {
$this->errorOutput(NOTABLENAME);
}
$audit = $this->input['audit'];
$arr_id = explode(',', $ids);
#####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
/*$sql = "SELECT groupid FROM ".DB_PREFIX . $tableName . " WHERE id IN (".$ids.")";
$q = $this->db->query($sql);
while ($r = $this->db->fetch_array($q))
{
$group_ids[] = $r['groupid'];
}
if($group_ids)
{
$gids = implode(',', $group_ids);
}
if($gids && $this->user['group_type'] >= MAX_ADMIN_TYPE)
{
$sql = 'SELECT id, parents FROM '.DB_PREFIX.'message_node WHERE id IN('.$gids.')';
$query = $this->db->query($sql);
while($row = $this->db->fetch_array($query))
{
$data['nodes']['message_sort'][$row['id']] = $row['parents'];
}
}
else
{
$data = array('nodes'=>array('message_sort'=>array(0=>0)));
}
$this->verify_content_prms($data);*/
#####结束
$op = '';
$obj = new Message();
if ($audit == 1) {
$op = '审核评论';
//排除被审核评论中已审核评论
$sql = 'SELECT id,is_credits,member_id,member_type,app_uniqueid,mod_uniqueid,column_id,contentid FROM ' . DB_PREFIX . $tableName . ' WHERE state IN (0,2,3) AND id IN (' . $ids . ')';
$q = $this->db->query($sql);
$credit_rules_uid = array();
//需增加积分的会员id
while ($r = $this->db->fetch_array($q)) {
$wsh_ids[] = $r['id'];
if ($r['member_id'] && $r['is_credits'] > 0 && $r['member_type']) {
$credit_rules_uid[$r['id']] = $r;
}
}
//如果批量审核的评论中存在待审核或者打回的评论,进行更新操作
if ($wsh_ids) {
/*******************调用积分规则,给已审核评论增加积分START*****************/
if ($this->settings['App_members']) {
include ROOT_PATH . 'lib/class/members.class.php';
$Members = new members();
/***审核增加积分**/
if ($credit_rules_uid && is_array($credit_rules_uid)) {
foreach ($credit_rules_uid as $key => $v) {
$Members->Initoperation();
//初始化
$Members->Setoperation(APP_UNIQUEID, '', '', 'extra');
$Members->get_credit_rules($v['member_id'], $v['app_uniqueid'], $v['mod_uniqueid'], $v['column_id'], $v['contentid']);
$this->db->query("UPDATE " . DB_PREFIX . "{$tableName} SET is_credits=0 WHERE id=" . $key);
//更新获得积分字段
}
}
}
/********************调用积分规则,给已审核评论增加积分END*****************/
$ids = implode(',', $wsh_ids);
$where = " id IN (" . $ids . ")";
$res = $obj->update('state = 1', $tableName, $where);
if ($res) {
//更新各内容评论计数
$this->update_comment_count($ids, 'audit', $tableName);
}
}
$arr = array('id' => $arr_id, 'status' => 1);
} else {
if ($audit == 2) {
$op = '打回评论';
//排除被打回评论中已打回评论
$sql = 'SELECT id,state FROM ' . DB_PREFIX . $tableName . ' WHERE state IN (0,1) AND id IN (' . $ids . ')';
$q = $this->db->query($sql);
while ($r = $this->db->fetch_array($q)) {
if ($r['state'] == 1) {
$back_arr[] = $r['id'];
}
//.........这里部分代码省略.........
示例10: validateOrder
//.........这里部分代码省略.........
die($errorMessage);
}
// Next !
if ($result and isset($order->id)) {
if (!$secure_key) {
$message .= $this->l('Warning : the secure key is empty, check your payment account before validation');
}
// Optional message to attach to this order
if (isset($message) and !empty($message)) {
$msg = new Message();
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
$msg->message = $message;
$msg->id_order = intval($order->id);
$msg->private = 1;
$msg->add();
}
}
// Insert products from cart into order_detail table
$products = $cart->getProducts();
$productsList = '';
$db = Db::getInstance();
$query = 'INSERT INTO `' . _DB_PREFIX_ . 'order_detail`
(`id_order`, `product_id`, `product_attribute_id`, `product_name`, `product_quantity`, `product_quantity_in_stock`, `product_price`, `reduction_percent`, `reduction_amount`, `group_reduction`, `product_quantity_discount`, `product_ean13`, `product_upc`, `product_reference`, `product_supplier_reference`, `product_weight`, `tax_name`, `tax_rate`, `ecotax`, `ecotax_tax_rate`, `discount_quantity_applied`, `download_deadline`, `download_hash`)
VALUES ';
$customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
Product::addCustomizationPrice($products, $customizedDatas);
$outOfStock = false;
$store_all_taxes = array();
foreach ($products as $key => $product) {
$productQuantity = (int) Product::getQuantity((int) $product['id_product'], $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL);
$quantityInStock = $productQuantity - (int) $product['cart_quantity'] < 0 ? $productQuantity : (int) $product['cart_quantity'];
if ($id_order_state != Configuration::get('PS_OS_CANCELED') and $id_order_state != Configuration::get('PS_OS_ERROR')) {
if (Product::updateQuantity($product, (int) $order->id)) {
$product['stock_quantity'] -= $product['cart_quantity'];
}
if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
$outOfStock = true;
}
Product::updateDefaultAttribute($product['id_product']);
}
$price = Product::getPriceStatic((int) $product['id_product'], false, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 6, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 2, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
/* Store tax info */
$id_country = (int) Country::getDefaultCountryId();
$id_state = 0;
$id_county = 0;
$rate = 0;
$id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
$address_infos = Address::getCountryAndState($id_address);
if ($address_infos['id_country']) {
$id_country = (int) $address_infos['id_country'];
$id_state = (int) $address_infos['id_state'];
$id_county = (int) County::getIdCountyByZipCode($address_infos['id_state'], $address_infos['postcode']);
}
$allTaxes = TaxRulesGroup::getTaxes((int) Product::getIdTaxRulesGroupByIdProduct((int) $product['id_product']), $id_country, $id_state, $id_county);
// If its a freeOrder, there will be no calculation
if ($order->total_products > 0) {
// remove order discount quotepart on product price in order to obtain the real tax
$ratio = $price / $order->total_products;
$order_reduction_amount = (double) abs($cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS)) * $ratio;
$tmp_price = $price - $order_reduction_amount;
foreach ($allTaxes as $res) {
if (!isset($store_all_taxes[$res->id])) {
$store_all_taxes[$res->id] = array();
$store_all_taxes[$res->id]['amount'] = 0;
示例11: update_message
public function update_message()
{
if (!isset($_POST['message_id'])) {
error(__("Error"), __("No message ID specified.", "discuss"));
}
$message = new Message($_POST['message_id']);
if ($message->no_results) {
error(__("Error"), __("Invalid message ID specified.", "discuss"));
}
if (!$message->editable()) {
show_403(__("Access Denied"), __("You do not have sufficient privileges to edit this message.", "discuss"));
}
$message->update($_POST['body']);
$files = array();
foreach ($_FILES['attachment'] as $key => $val) {
foreach ($val as $file => $attr) {
$files[$file][$key] = $attr;
}
}
foreach ($files as $attachment) {
if ($attachment['error'] != 4) {
$path = upload($attachment, null, "attachments");
Attachment::add(basename($path), $path, "message", $message->id);
}
}
Flash::notice(__("Message updated.", "discuss"), $message->url(true));
}
示例12: processAddress
function processAddress()
{
global $cart, $smarty;
$errors = array();
if (!isset($_POST['id_address_delivery']) or !Address::isCountryActiveById(intval($_POST['id_address_delivery']))) {
$errors[] = 'this address is not in a valid area';
} else {
$cart->id_address_delivery = intval(Tools::getValue('id_address_delivery'));
$cart->id_address_invoice = Tools::isSubmit('same') ? $cart->id_address_delivery : intval(Tools::getValue('id_address_invoice'));
if (!$cart->update()) {
$errors[] = Tools::displayError('an error occured while updating your cart');
}
if (Tools::isSubmit('message') and !empty($_POST['message'])) {
if (!Validate::isMessage($_POST['message'])) {
$errors[] = Tools::displayError('invalid message');
} elseif ($oldMessage = Message::getMessageByCartId(intval($cart->id))) {
$message = new Message(intval($oldMessage['id_message']));
$message->message = htmlentities($_POST['message'], ENT_COMPAT, 'UTF-8');
$message->update();
} else {
$message = new Message();
$message->message = htmlentities($_POST['message'], ENT_COMPAT, 'UTF-8');
$message->id_cart = intval($cart->id);
$message->id_customer = intval($cart->id_customer);
$message->add();
}
}
}
if (sizeof($errors)) {
if (Tools::getValue('ajax')) {
die('{\'hasError\' : true, errors : [\'' . implode('\',\'', $errors) . '\']}');
}
$smarty->assign('errors', $errors);
displayAddress();
include_once dirname(__FILE__) . '/footer.php';
exit;
}
if (Tools::getValue('ajax')) {
die(true);
}
}
示例13: InvalidArgumentException
throw new InvalidArgumentException("Listing Id cannot be empty", 405);
}
if (empty($requestObject->orgId) === true) {
throw new InvalidArgumentException("Organization Id cannot be empty", 405);
}
if (empty($requestObject->messageText) === true) {
throw new InvalidArgumentException("Message field cannot be empty", 405);
}
//perform the actual put or post
if ($method === "PUT") {
$message = Message::getMessageByMessageId($pdo, $id);
if ($message === null) {
throw new RuntimeException("Message does not exist", 404);
}
$message = new Message($id, $requestObject->listingId, $requestObject->orgId, $requestObject->messageText);
$message->update($pdo);
$reply->message = "Message updated Ok";
} else {
if ($method === "POST") {
$message = new Message(null, $requestObject->listingId, $requestObject->orgId, $requestObject->messageText);
$message->insert($pdo);
$reply->message = "Message created ok";
}
}
} else {
if ($method === "DELETE") {
//verifyXsrf();
$message = Message::getMessageByMessageId($pdo, $id);
if ($message === null) {
throw new RuntimeException("Message does not exist", 404);
}
示例14: sprintf
Tool::logger(__METHOD__, __LINE__, sprintf("action: %s", $action), _LOG_DEBUG);
$message = new Message(_NONE);
$message->messageId = isset($_REQUEST["id"]) ? $_REQUEST["id"] : _NONE;
$message->email = isset($_REQUEST["email"]) ? $_REQUEST["email"] : "";
$message->uname = Tool::unescape(isset($_REQUEST["uname"]) ? $_REQUEST["uname"] : "");
$message->phone = isset($_REQUEST["phone"]) ? $_REQUEST["phone"] : "";
$message->content = Tool::unescape(isset($_REQUEST["message"]) ? $_REQUEST["message"] : "");
if ($message->messageId > 0) {
$message = Message::read($message);
}
$message->reply = isset($_REQUEST["reply"]) ? $_REQUEST["reply"] : $message->reply;
if ($action == "insert") {
$newId = Message::insert($message);
} else {
if ($action == "update") {
Message::update($message);
$emailResult = false;
//发送结果
include "email.php";
//发送邮件
if ($emailResult === false) {
$result = "邮件回复失败,请重试";
Tool::logger(__METHOD__, __LINE__, sprintf("回复邮件[%s]失败,请重试", $message->email), _LOG_ERROR);
}
} else {
if ($action == "delete") {
Message::delete($message);
}
}
}
} catch (Exception $e) {
示例15: validateOrder
//.........这里部分代码省略.........
Logger::addLog($errorMessage, 4, '0000001', 'Cart', intval($order->id_cart));
die($errorMessage);
}
// Next !
if ($result and isset($order->id)) {
if (!$secure_key) {
$message .= $this->l('Warning : the secure key is empty, check your payment account before validation');
}
// Optional message to attach to this order
if (isset($message) and !empty($message)) {
$msg = new Message();
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
$msg->message = $message;
$msg->id_order = intval($order->id);
$msg->private = 1;
$msg->add();
}
}
// Insert products from cart into order_detail table
$products = $cart->getProducts();
$productsList = '';
$db = Db::getInstance();
$query = 'INSERT INTO `' . _DB_PREFIX_ . 'order_detail`
(`id_order`, `product_id`, `product_attribute_id`, `product_name`, `product_quantity`, `product_quantity_in_stock`, `product_price`, `reduction_percent`, `reduction_amount`, `group_reduction`, `product_quantity_discount`, `product_ean13`, `product_upc`, `product_reference`, `product_supplier_reference`, `product_weight`, `tax_name`, `tax_rate`, `ecotax`, `ecotax_tax_rate`, `discount_quantity_applied`, `download_deadline`, `download_hash`, `customization`)
VALUES ';
$customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
Product::addCustomizationPrice($products, $customizedDatas);
$outOfStock = false;
foreach ($products as $key => $product) {
$productQuantity = (int) Product::getQuantity((int) $product['id_product'], $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL);
$quantityInStock = $productQuantity - (int) $product['cart_quantity'] < 0 ? $productQuantity : (int) $product['cart_quantity'];
if ($id_order_state != _PS_OS_CANCELED_ and $id_order_state != _PS_OS_ERROR_) {
if (Product::updateQuantity($product, (int) $order->id)) {
$product['stock_quantity'] -= $product['cart_quantity'];
}
if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
$outOfStock = true;
}
if ($product['stock_quantity'] < 1) {
SolrSearch::updateProduct((int) $product['id_product']);
}
Product::updateDefaultAttribute($product['id_product']);
}
$price = Product::getPriceStatic((int) $product['id_product'], false, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 6, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, 2, NULL, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
// Add some informations for virtual products
$deadline = '0000-00-00 00:00:00';
$download_hash = NULL;
if ($id_product_download = ProductDownload::getIdFromIdProduct((int) $product['id_product'])) {
$productDownload = new ProductDownload((int) $id_product_download);
$deadline = $productDownload->getDeadLine();
$download_hash = $productDownload->getHash();
}
// Exclude VAT
if (Tax::excludeTaxeOption()) {
$product['tax'] = 0;
$product['rate'] = 0;
$tax_rate = 0;
} else {
$tax_rate = Tax::getProductTaxRate((int) $product['id_product'], $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
$ecotaxTaxRate = 0;
if (!empty($product['ecotax'])) {
$ecotaxTaxRate = Tax::getProductEcotaxRate($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}