本文整理汇总了PHP中Message::getMessageByCartId方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::getMessageByCartId方法的具体用法?PHP Message::getMessageByCartId怎么用?PHP Message::getMessageByCartId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::getMessageByCartId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayOrderStep
function displayOrderStep($params)
{
global $smarty, $cart, $errors;
require_once dirname(__FILE__) . "/OrderProductVendor.php";
$smarty->assign("product_lines", OrderProductVendor::getProductsWithVendors($cart));
if ($oldMessage = Message::getMessageByCartId(intval($cart->id))) {
$smarty->assign('oldMessage', $oldMessage['message']);
}
$smarty->assign('cart', $cart);
$smarty->assign('back', strval(Tools::getValue('back')));
Tools::safePostVars();
include_once dirname(__FILE__) . '/../../header.php';
echo $this->display(__FILE__, 'ordervendor.tpl');
}
示例2: displayOrderStep
function displayOrderStep($params)
{
global $smarty, $cart, $errors, $currency;
Module::hookExec('orderPriceAdjustment', array());
$smarty->assign("currency_iso_code", $currency->iso_code);
$smarty->assign("currency_name", $currency->name);
$smarty->assign('errors', $errors);
$smarty->assign('mdl_dir', dirname(__FILE__) . '/');
if (file_exists(_PS_SHIP_IMG_DIR_ . intval($cart->id_carrier) . '.jpg')) {
$smarty->assign('carrierPicture', 1);
}
$summary = $cart->getSummaryDetails();
$customizedDatas = Product::getAllCustomizedDatas(intval($cart->id));
Product::addCustomizationPrice($summary['products'], $customizedDatas);
if ($free_ship = intval(Configuration::get('PS_SHIPPING_FREE_PRICE'))) {
$discounts = $cart->getDiscounts();
$total_free_ship = $free_ship - ($summary['total_products_wt'] + $summary['total_discounts']);
foreach ($discounts as $discount) {
if ($discount['id_discount_type'] == 3) {
$total_free_ship = 0;
break;
}
}
$smarty->assign('free_ship', $total_free_ship);
}
$smarty->assign($summary);
$token = Tools::getToken(false);
$smarty->assign(array('token_cart' => $token, 'voucherAllowed' => Configuration::get('PS_VOUCHERS'), 'HOOK_SHOPPING_CART' => Module::hookExec('shoppingCart', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Module::hookExec('shoppingCartExtra', $summary), 'shippingCost' => $cart->getOrderTotalLC(true, 5), 'shippingCostTaxExc' => $cart->getOrderTotalLC(false, 5), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'lastProductAdded' => $cart->getLastProduct()));
Tools::safePostVars();
if ($oldMessage = Message::getMessageByCartId(intval($cart->id))) {
$smarty->assign('oldMessage', $oldMessage['message']);
}
$smarty->assign('cart', $cart);
$smarty->assign('back', strval(Tools::getValue('back')));
Tools::safePostVars();
include_once dirname(__FILE__) . '/../../header.php';
echo $this->display(__FILE__, 'orderpriceadjustment.tpl');
}
示例3: _assignAddress
protected function _assignAddress()
{
//if guest checkout disabled and flag is_guest in cookies is actived
if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED') == 0 && (int) $this->context->customer->is_guest != Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
$this->context->customer->logout();
Tools::redirect('');
} else {
if (!Customer::getAddressesTotalById($this->context->customer->id)) {
Tools::redirect('index.php?controller=address&back=' . urlencode('order.php?step=1&multi-shipping=' . (int) Tools::getValue('multi-shipping')));
}
}
$customer = $this->context->customer;
if (Validate::isLoadedObject($customer)) {
/* Getting customer addresses */
$customerAddresses = $customer->getAddresses($this->context->language->id);
// Getting a list of formated address fields with associated values
$formatedAddressFieldsValuesList = array();
foreach ($customerAddresses as $i => $address) {
if (!Address::isCountryActiveById((int) $address['id_address'])) {
unset($customerAddresses[$i]);
}
$tmpAddress = new Address($address['id_address']);
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']);
$formatedAddressFieldsValuesList[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues($tmpAddress, $formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields']);
unset($tmpAddress);
}
if (key($customerAddresses) != 0) {
$customerAddresses = array_values($customerAddresses);
}
if (!count($customerAddresses)) {
$bad_delivery = false;
if (($bad_delivery = (bool) (!Address::isCountryActiveById((int) $this->context->cart->id_address_delivery))) || !Address::isCountryActiveById((int) $this->context->cart->id_address_invoice)) {
$back_url = $this->context->link->getPageLink('order', true, (int) $this->context->language->id, array('step' => Tools::getValue('step'), 'multi-shipping' => (int) Tools::getValue('multi-shipping')));
$params = array('multi-shipping' => (int) Tools::getValue('multi-shipping'), 'id_address' => $bad_delivery ? (int) $this->context->cart->id_address_delivery : (int) $this->context->cart->id_address_invoice, 'back' => $back_url);
Tools::redirect($this->context->link->getPageLink('address', true, (int) $this->context->language->id, $params));
}
}
$this->context->smarty->assign(array('addresses' => $customerAddresses, 'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList));
/* Setting default addresses for cart */
if ((!isset($this->context->cart->id_address_delivery) || empty($this->context->cart->id_address_delivery)) && count($customerAddresses)) {
$this->context->cart->id_address_delivery = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
if ((!isset($this->context->cart->id_address_invoice) || empty($this->context->cart->id_address_invoice)) && count($customerAddresses)) {
$this->context->cart->id_address_invoice = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
/* Update cart addresses only if needed */
if (isset($update) && $update) {
$this->context->cart->update();
// Address has changed, so we check if the cart rules still apply
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);
}
/* If delivery address is valid in cart, assign it to Smarty */
if (isset($this->context->cart->id_address_delivery)) {
$deliveryAddress = new Address((int) $this->context->cart->id_address_delivery);
if (Validate::isLoadedObject($deliveryAddress) && $deliveryAddress->id_customer == $customer->id) {
$this->context->smarty->assign('delivery', $deliveryAddress);
}
}
/* If invoice address is valid in cart, assign it to Smarty */
if (isset($this->context->cart->id_address_invoice)) {
$invoiceAddress = new Address((int) $this->context->cart->id_address_invoice);
if (Validate::isLoadedObject($invoiceAddress) && $invoiceAddress->id_customer == $customer->id) {
$this->context->smarty->assign('invoice', $invoiceAddress);
}
}
}
if ($oldMessage = Message::getMessageByCartId((int) $this->context->cart->id)) {
$this->context->smarty->assign('oldMessage', $oldMessage['message']);
}
}
示例4: create_subcart_for_seller
public static function create_subcart_for_seller($id_seller)
{
$huthpxo = "bigcart_total_products";
${"GLOBALS"}["mojmmchx"] = "bigcart_discount";
${"GLOBALS"}["ehwlkyjp"] = "id_cart";
$pmcwqmo = "bigcart_discount";
${"GLOBALS"}["jnylgaksltbe"] = "bigcart_total_products";
$qfpnnoef = "id_cart";
$xtdnxvn = "bigcart";
global $cart;
${"GLOBALS"}["fhrfrkr"] = "message";
${"GLOBALS"}["amjywbmqdhor"] = "message";
${"GLOBALS"}["icktqhybvwlj"] = "id_message";
${${"GLOBALS"}["frpscuel"]} = $cart->id;
${$xtdnxvn} = new Cart(${${"GLOBALS"}["ehwlkyjp"]});
${$pmcwqmo} = abs(floatval($bigcart->getOrderTotal(true, Cart::ONLY_DISCOUNTS)));
$ibpmxifhcbee = "sql";
${${"GLOBALS"}["jnylgaksltbe"]} = $bigcart->getOrderTotal(true, Cart::ONLY_PRODUCTS, null, null, false);
${${"GLOBALS"}["wghoseimj"]} = Message::getMessageByCartId(${${"GLOBALS"}["frpscuel"]});
$prhfxdc = "id_message";
${$prhfxdc} = 0;
if (isset(${${"GLOBALS"}["amjywbmqdhor"]}["id_message"])) {
${${"GLOBALS"}["icktqhybvwlj"]} = intval(${${"GLOBALS"}["fhrfrkr"]}["id_message"]);
}
${${"GLOBALS"}["ybrkjhi"]} = self::get_subcart_id(${${"GLOBALS"}["frpscuel"]}, ${${"GLOBALS"}["qcrytsf"]});
${"GLOBALS"}["wahompyhhfb"] = "cartinfo";
${${"GLOBALS"}["oclbkvhtf"]} = self::generate_subacart(${${"GLOBALS"}["frpscuel"]}, ${${"GLOBALS"}["ybrkjhi"]}, ${${"GLOBALS"}["qyxonid"]}, ${${"GLOBALS"}["mojmmchx"]}, ${$huthpxo}, ${${"GLOBALS"}["qcrytsf"]});
${${"GLOBALS"}["fajsjwqsq"]} = "REPLACE INTO " . _DB_PREFIX_ . "agile_subcart (id_cart, id_cart_parent,id_seller,id_order,progress,date_add) VALUES (" . ${${"GLOBALS"}["wahompyhhfb"]}["id_cart"] . "," . ${$qfpnnoef} . "," . intval(${${"GLOBALS"}["qcrytsf"]}) . ",0,0,'" . date("Y-m-d H:i:s") . "')";
Db::getInstance()->Execute(${$ibpmxifhcbee});
return ${${"GLOBALS"}["oclbkvhtf"]};
}
示例5: number_format
$gofpay->validateOrder($cart->id, _PS_OS_PREPARATION_, $orderAmount, $gofpay->displayName, NULL, NULL);
$orderNo = $gofpay->currentOrder;
$discount = number_format($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS), 2, '.', '');
$discount = sprintf('%.2f', $discount);
//获取交易参数
$order = new Order($orderNo);
$customer = new Customer(intval($cart->id_customer));
$email = $customer->email;
$mycurrency = new Currency($cart->id_currency);
$orderCurrency = $mycurrency->iso_code;
$shipFee = number_format($cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 2, '.', '');
$shipFee = sprintf('%.2f', $shipFee);
//订单信息
$billInfo = new Address(intval($cart->id_address_invoice));
$shipInfo = new Address(intval($cart->id_address_delivery));
$message = Message::getMessageByCartId(intval($cart->id));
//账单信息
$billingFirstName = $billInfo->firstname;
$billingLastName = $billInfo->lastname;
$billingAddress1 = $billInfo->address1;
$billingAddress2 = $billInfo->address2;
$billingCity = $billInfo->city;
$billingCountry = $billInfo->country;
$_billingState = new State((int) $billInfo->id_state);
$billingState = $_billingState->iso_code;
$billingZipcode = $billInfo->postcode;
$billingTelephone = !empty($billInfo->phone_mobile) ? $billInfo->phone_mobile : $billInfo->phone;
//发货信息
$shippingFirstName = trim($shipInfo->lastname);
$shippingLastName = trim($shipInfo->lastname);
$shippingAddress1 = $shipInfo->address1;
示例6: _getCarrierList
protected function _getCarrierList()
{
$address_delivery = new Address($this->context->cart->id_address_delivery);
$cms = new CMS(Configuration::get('PS_CONDITIONS_CMS_ID'), $this->context->language->id);
$link_conditions = $this->context->link->getCMSLink($cms, $cms->link_rewrite);
if (!strpos($link_conditions, '?')) {
$link_conditions .= '?content_only=1';
} else {
$link_conditions .= '&content_only=1';
}
$carriers = $this->context->cart->simulateCarriersOutput();
$delivery_option = $this->context->cart->getDeliveryOption(null, false, false);
$wrapping_fees = $this->context->cart->getGiftWrappingPrice(false);
$wrapping_fees_tax_inc = $wrapping_fees = $this->context->cart->getGiftWrappingPrice();
$oldMessage = Message::getMessageByCartId((int) $this->context->cart->id);
$free_shipping = false;
foreach ($this->context->cart->getCartRules() as $rule) {
if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
$free_shipping = true;
break;
}
}
$this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart());
$vars = array('free_shipping' => $free_shipping, 'checkedTOS' => (int) $this->context->cookie->checkedTOS, 'recyclablePackAllowed' => (int) Configuration::get('PS_RECYCLABLE_PACK'), 'giftAllowed' => (int) Configuration::get('PS_GIFT_WRAPPING'), 'cms_id' => (int) Configuration::get('PS_CONDITIONS_CMS_ID'), 'conditions' => (int) Configuration::get('PS_CONDITIONS'), 'link_conditions' => $link_conditions, 'recyclable' => (int) $this->context->cart->recyclable, 'gift_wrapping_price' => (double) $wrapping_fees, 'total_wrapping_cost' => Tools::convertPrice($wrapping_fees_tax_inc, $this->context->currency), 'total_wrapping_tax_exc_cost' => Tools::convertPrice($wrapping_fees, $this->context->currency), 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), 'carriers' => $carriers, 'checked' => $this->context->cart->simulateCarrierSelectedOutput(), 'delivery_option' => $delivery_option, 'address_collection' => $this->context->cart->getAddressCollection(), 'opc' => true, 'oldMessage' => isset($oldMessage['message']) ? $oldMessage['message'] : '', 'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array('carriers' => $carriers, 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), 'delivery_option' => $delivery_option)));
Cart::addExtraCarriers($vars);
$this->context->smarty->assign($vars);
if (!Address::isCountryActiveById((int) $this->context->cart->id_address_delivery) && $this->context->cart->id_address_delivery != 0) {
$this->errors[] = Tools::displayError('This address is not in a valid area.');
} elseif ((!Validate::isLoadedObject($address_delivery) || $address_delivery->deleted) && $this->context->cart->id_address_delivery != 0) {
$this->errors[] = Tools::displayError('This address is invalid.');
} else {
$result = array('HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array('carriers' => $carriers, 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), 'delivery_option' => $this->context->cart->getDeliveryOption(null, true))), 'carrier_block' => $this->context->smarty->fetch(_PS_THEME_DIR_ . 'order-carrier.tpl'));
Cart::addExtraCarriers($result);
return $result;
}
if (count($this->errors)) {
return array('hasError' => true, 'errors' => $this->errors, 'carrier_block' => $this->context->smarty->fetch(_PS_THEME_DIR_ . 'order-carrier.tpl'));
}
}
示例7: hookPayment
public function hookPayment($params)
{
global $cookie;
$this->_validateErrors = array();
session_start();
$_SESSION['params1'] = '';
$_SESSION['cart_currency'] = '';
$_SESSION['cart_amount'] = '';
$_SESSION['params1'] = $params;
if (!$this->active) {
return;
}
global $smarty;
$address = new Address(intval($params['cart']->id_address_invoice));
$customer = new Customer(intval($params['cart']->id_customer));
$merchant_id = trim(Configuration::get('CCAVENUE_MERCHANT_ID'));
$access_code = trim(Configuration::get('CCAVENUE_ACCESS_CODE'));
$encryption_key = trim(Configuration::get('CCAVENUE_ENCRYPTION_KEY'));
$ccavenue_title = trim(Configuration::get('CCAVENUE_TITLE'));
$Redirect_Url = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/ccavenue/validation.php';
$Cancel_Url = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/ccavenue/validation.php';
$language = 'EN';
$currency = $this->getCurrency('INR');
$OrderId = date('Ymdhis') . '-' . intval($params['cart']->id);
$Amount = $params['cart']->getOrderTotal(true, 3);
$_SESSION['cart_amount'] = $Amount;
$default_currency_support_ccavnenue = 'INR';
$default_currency_id = Db::getInstance()->getValue("\n\t\t\t\t\t\tSELECT `id_currency`\n\t\t\t\t\t\tFROM `" . _DB_PREFIX_ . "currency`\n\t\t\t\t\t\tWHERE `iso_code` = '" . $default_currency_support_ccavnenue . "'");
$base_currency_id = Configuration::get('PS_CURRENCY_DEFAULT');
$default_currency = new Currency((int) $default_currency_id);
$base_currency = new Currency((int) $base_currency_id);
$base_currency_code = $base_currency->iso_code;
$current_currency = new Currency((int) $params['cart']->id_currency);
$_SESSION['cart_currency'] = $params['cart']->id_currency;
$current_currency_code = $current_currency->iso_code;
$billing_name = $address->firstname . $address->lastname;
$billing_address = $address->address1 . $address->address2;
$billing_city = $address->city;
$billing_zip = $address->postcode;
$billing_tel = $address->phone;
$billing_email = $customer->email;
$country = new Country(intval($address->id_country));
$state = new State(intval($address->id_state));
$billing_state = $state->getNameById($address->id_state);
$land_id = $params['cart']->id_lang;
$billing_country = $country->getNameById($land_id, $address->id_country);
$merchant_param1 = (int) $params['cart']->id;
$merchant_param2 = date('YmdHis');
$merchant_param3 = $params['cart']->secure_key;
$cust_notes_message = Message::getMessageByCartId(intval($params['cart']->id));
$cust_notes = $cust_notes_message['message'];
$billing_cust_notes = $cust_notes;
$delivery_name = '';
$delivery_address = '';
$delivery_city = '';
$delivery_state = '';
$delivery_tel = '';
$delivery_zip = '';
$delivery_country = '';
$delivery_name = $address->firstname . $address->lastname;
$delivery_address = $address->address1 . $address->address2;
$delivery_city = $address->city;
$delivery_zip = $address->postcode;
$delivery_tel = $address->phone;
$delivery_state = $billing_state;
$delivery_country = $billing_country;
$merchant_data_array = array();
$merchant_data_array['merchant_id'] = $merchant_id;
$merchant_data_array['order_id'] = $OrderId;
$merchant_data_array['currency'] = 'INR';
$merchant_data_array['amount'] = $Amount;
$merchant_data_array['redirect_url'] = $Redirect_Url;
$merchant_data_array['cancel_url'] = $Cancel_Url;
$merchant_data_array['language'] = $language;
$merchant_data_array['billing_name'] = $billing_name;
$merchant_data_array['billing_address'] = $billing_address;
$merchant_data_array['billing_city'] = $billing_city;
$merchant_data_array['billing_state'] = $billing_state;
$merchant_data_array['billing_zip'] = $billing_zip;
$merchant_data_array['billing_country'] = $billing_country;
$merchant_data_array['billing_tel'] = $billing_tel;
$merchant_data_array['billing_email'] = $billing_email;
$merchant_data_array['delivery_name'] = $delivery_name;
$merchant_data_array['delivery_address'] = $delivery_address;
$merchant_data_array['delivery_city'] = $delivery_city;
$merchant_data_array['delivery_state'] = $delivery_state;
$merchant_data_array['delivery_zip'] = $delivery_zip;
$merchant_data_array['delivery_country'] = $delivery_country;
$merchant_data_array['delivery_tel'] = $delivery_tel;
$merchant_data_array['merchant_param1'] = $merchant_param1;
$merchant_data_array['merchant_param2'] = $merchant_param2;
$merchant_data_array['merchant_param3'] = $merchant_param3;
$merchant_data = implode("&", $merchant_data_array);
$ccavenue_post_data = '';
$ccavenue_post_data_array = array();
foreach ($merchant_data_array as $key => $value) {
$ccavenue_post_data_array[] .= $key . '=' . urlencode($value);
}
$ccavenue_post_data = implode("&", $ccavenue_post_data_array);
$encrypted_data = $this->encrypt($ccavenue_post_data, $encryption_key);
//.........这里部分代码省略.........
示例8: _assignAddress
protected function _assignAddress()
{
if (!Customer::getAddressesTotalById((int) self::$cookie->id_customer)) {
Tools::redirect('address.php?back=order.php?step=1');
}
$customer = new Customer((int) self::$cookie->id_customer);
if (Validate::isLoadedObject($customer)) {
/* Getting customer addresses */
$customerAddresses = $customer->getAddresses((int) self::$cookie->id_lang);
self::$smarty->assign('addresses', $customerAddresses);
/* Setting default addresses for cart */
if ((!isset(self::$cart->id_address_delivery) or empty(self::$cart->id_address_delivery)) and sizeof($customerAddresses)) {
self::$cart->id_address_delivery = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
if ((!isset(self::$cart->id_address_invoice) or empty(self::$cart->id_address_invoice)) and sizeof($customerAddresses)) {
self::$cart->id_address_invoice = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
/* Update cart addresses only if needed */
if (isset($update) and $update) {
self::$cart->update();
}
/* If delivery address is valid in cart, assign it to Smarty */
if (isset(self::$cart->id_address_delivery)) {
$deliveryAddress = new Address((int) self::$cart->id_address_delivery);
if (Validate::isLoadedObject($deliveryAddress) and $deliveryAddress->id_customer == $customer->id) {
self::$smarty->assign('delivery', $deliveryAddress);
}
}
/* If invoice address is valid in cart, assign it to Smarty */
if (isset(self::$cart->id_address_invoice)) {
$invoiceAddress = new Address((int) self::$cart->id_address_invoice);
if (Validate::isLoadedObject($invoiceAddress) and $invoiceAddress->id_customer == $customer->id) {
self::$smarty->assign('invoice', $invoiceAddress);
}
}
}
if ($oldMessage = Message::getMessageByCartId((int) self::$cart->id)) {
self::$smarty->assign('oldMessage', $oldMessage['message']);
}
}
示例9: validateOrder
//.........这里部分代码省略.........
}
// Set the new voucher value
if ($voucher->reduction_tax) {
$voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt;
} else {
$voucher->reduction_amount = $values['tax_excl'] - $order->total_products;
}
$voucher->id_customer = $order->id_customer;
$voucher->quantity = 1;
if ($voucher->add()) {
// If the voucher has conditions, they are now copied to the new voucher
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
$params = array('{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false), '{voucher_num}' => $voucher->code, '{firstname}' => $this->context->customer->firstname, '{lastname}' => $this->context->customer->lastname, '{id_order}' => $order->reference, '{order_name}' => $order->getUniqReference());
Mail::Send((int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher regarding your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop);
}
$values['tax_incl'] -= $values['tax_incl'] - $order->total_products_wt;
$values['tax_excl'] -= $values['tax_excl'] - $order->total_products;
}
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
$cart_rule_used[] = $cart_rule['obj']->id;
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
$cart_rule_to_update->update();
}
$cart_rules_list .= '
<tr>
<td colspan="4" style="padding:0.6em 0.4em;text-align:right">' . Tools::displayError('Voucher name:') . ' ' . $cart_rule['obj']->name . '</td>
<td style="padding:0.6em 0.4em;text-align:right">' . ($values['tax_incl'] != 0.0 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false) . '</td>
</tr>';
}
// Specify order id for message
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
if ($old_message) {
$update_message = new Message((int) $old_message['id_message']);
$update_message->id_order = (int) $order->id;
$update_message->update();
// Add this message in the customer thread
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_customer = (int) $order->id_customer;
$customer_thread->id_shop = (int) $this->context->shop->id;
$customer_thread->id_order = (int) $order->id;
$customer_thread->id_lang = (int) $this->context->language->id;
$customer_thread->email = $this->context->customer->email;
$customer_thread->status = 'open';
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = 0;
$customer_message->message = $update_message->message;
$customer_message->private = 0;
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving message');
}
}
// Hook validate order
Hook::exec('actionValidateOrder', array('cart' => $this->context->cart, 'order' => $order, 'customer' => $this->context->customer, 'currency' => $this->context->currency, 'orderStatus' => $order_status));
foreach ($this->context->cart->getProducts() as $product) {
if ($order_status->logable) {
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
}
}
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
示例10: validateOrder
//.........这里部分代码省略.........
}
if ($shrunk and $total_discount_value + $value > $order->total_products_wt + $order->total_shipping + $order->total_wrapping) {
$amount_to_add = $order->total_products_wt + $order->total_shipping + $order->total_wrapping - $total_discount_value;
if ($objDiscount->id_discount_type == 2 and $objDiscount->behavior_not_exhausted == 2) {
$voucher = new Discount();
foreach ($objDiscount as $key => $discountValue) {
$voucher->{$key} = $discountValue;
}
$voucher->name = 'VSRK' . (int) $order->id_customer . 'O' . (int) $order->id;
$voucher->value = (double) $value - $amount_to_add;
$voucher->add();
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
$params['{voucher_num}'] = $voucher->name;
$params['{firstname}'] = $customer->firstname;
$params['{lastname}'] = $customer->lastname;
$params['{id_order}'] = $order->id;
$params['{order_name}'] = sprintf("#%06d", (int) $order->id);
@Mail::Send((int) $order->id_lang, 'voucher', Mail::l('New voucher regarding your order #', (int) $order->id_lang) . sprintf("%06d", (int) $order->id), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname);
}
} else {
$amount_to_add = $value;
}
$order->addDiscount($objDiscount->id, $objDiscount->name, $amount_to_add);
$total_discount_value += $amount_to_add;
if ($id_order_state != Configuration::get('PS_OS_ERROR') and $id_order_state != Configuration::get('PS_OS_CANCELED')) {
$objDiscount->quantity = $objDiscount->quantity - 1;
}
$objDiscount->update();
$discountsList .= '<tr style="background-color:#EBECEE;">
<td colspan="4" style="padding: 0.6em 0.4em; text-align: right;">' . $this->l('Voucher code:') . ' ' . $objDiscount->name . '</td>
<td style="padding: 0.6em 0.4em; text-align: right;">' . ($value != 0.0 ? '-' : '') . Tools::displayPrice($value, $currency, false) . '</td>
</tr>';
}
// Specify order id for message
$oldMessage = Message::getMessageByCartId((int) $cart->id);
if ($oldMessage) {
$message = new Message((int) $oldMessage['id_message']);
$message->id_order = (int) $order->id;
$message->update();
}
// Hook new order
$orderStatus = new OrderState((int) $id_order_state, (int) $order->id_lang);
if (Validate::isLoadedObject($orderStatus)) {
Hook::newOrder($cart, $order, $customer, $currency, $orderStatus);
foreach ($cart->getProducts() as $product) {
if ($orderStatus->logable) {
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
}
}
}
if (isset($outOfStock) && $outOfStock && Configuration::get('PS_STOCK_MANAGEMENT')) {
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$history->changeIdOrderState(Configuration::get('PS_OS_OUTOFSTOCK'), (int) $order->id);
$history->addWithemail();
}
// Set order state in order history ONLY even if the "out of stock" status has not been yet reached
// So you migth have two order states
$new_history = new OrderHistory();
$new_history->id_order = (int) $order->id;
$new_history->changeIdOrderState((int) $id_order_state, (int) $order->id);
$new_history->addWithemail(true, $extraVars);
// Order is reloaded because the status just changed
$order = new Order($order->id);
// Send an e-mail to customer
if ($id_order_state != Configuration::get('PS_OS_ERROR') and $id_order_state != Configuration::get('PS_OS_CANCELED') and $customer->id) {
$invoice = new Address((int) $order->id_address_invoice);
$delivery = new Address((int) $order->id_address_delivery);
$carrier = new Carrier((int) $order->id_carrier, $order->id_lang);
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
$data = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"), '{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"), '{delivery_block_html}' => $this->_getFormatedAddress($delivery, "<br />", array('firstname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>', 'lastname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>')), '{invoice_block_html}' => $this->_getFormatedAddress($invoice, "<br />", array('firstname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>', 'lastname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>')), '{delivery_company}' => $delivery->company, '{delivery_firstname}' => $delivery->firstname, '{delivery_lastname}' => $delivery->lastname, '{delivery_address1}' => $delivery->address1, '{delivery_address2}' => $delivery->address2, '{delivery_city}' => $delivery->city, '{delivery_postal_code}' => $delivery->postcode, '{delivery_country}' => $delivery->country, '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '', '{delivery_phone}' => $delivery->phone ? $delivery->phone : $delivery->phone_mobile, '{delivery_other}' => $delivery->other, '{invoice_company}' => $invoice->company, '{invoice_vat_number}' => $invoice->vat_number, '{invoice_firstname}' => $invoice->firstname, '{invoice_lastname}' => $invoice->lastname, '{invoice_address2}' => $invoice->address2, '{invoice_address1}' => $invoice->address1, '{invoice_city}' => $invoice->city, '{invoice_postal_code}' => $invoice->postcode, '{invoice_country}' => $invoice->country, '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', '{invoice_phone}' => $invoice->phone ? $invoice->phone : $invoice->phone_mobile, '{invoice_other}' => $invoice->other, '{order_name}' => sprintf("#%06d", (int) $order->id), '{date}' => Tools::displayDate(date('Y-m-d H:i:s'), (int) $order->id_lang, 1), '{carrier}' => $carrier->name, '{payment}' => Tools::substr($order->payment, 0, 32), '{products}' => $productsList, '{discounts}' => $discountsList, '{total_paid}' => Tools::displayPrice($order->total_paid, $currency, false), '{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $currency, false), '{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency, false), '{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency, false), '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency, false));
if (is_array($extraVars)) {
$data = array_merge($data, $extraVars);
}
// Join PDF invoice
if ((int) Configuration::get('PS_INVOICE') and Validate::isLoadedObject($orderStatus) and $orderStatus->invoice and $order->invoice_number) {
$fileAttachment['content'] = PDF::invoice($order, 'S');
$fileAttachment['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang) . sprintf('%06d', $order->invoice_number) . '.pdf';
$fileAttachment['mime'] = 'application/pdf';
} else {
$fileAttachment = null;
}
if (Validate::isEmail($customer->email)) {
Mail::Send((int) $order->id_lang, 'order_conf', Mail::l('Order confirmation', (int) $order->id_lang), $data, $customer->email, $customer->firstname . ' ' . $customer->lastname, NULL, NULL, $fileAttachment);
}
}
$this->currentOrder = (int) $order->id;
return true;
} else {
$errorMessage = Tools::displayError('Order creation failed');
Logger::addLog($errorMessage, 4, '0000002', 'Cart', intval($order->id_cart));
die($errorMessage);
}
} else {
$errorMessage = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
Logger::addLog($errorMessage, 4, '0000001', 'Cart', intval($cart->id));
die($errorMessage);
}
}
示例11: hookAdminOrder
//.........这里部分代码省略.........
$form .= '<p style="" class="error">
<a style="position: relative; top: -100px;" id="hipay"></a>
' . Tools::getValue('hipay_err') . '
</p>';
}
}
// v1.5 // $form_action = '../index.php?fc=module&module=' . $this->name . '&controller=capture';
$form_action = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/14capture.php';
$form .= '
<div style="height:10px"></div>
<fieldset>
<legend>' . $this->l('Capture this order') . '</legend>';
// v1.5 // $orderTotal = $orderLoaded->total_products_wt + $orderLoaded->total_shipping_tax_incl + $orderLoaded->total_wrapping_tax_incl;
$orderTotal = $orderLoaded->total_products_wt + $orderLoaded->total_shipping + $orderLoaded->total_wrapping;
$totalEncaissement = $this->getOrderTotalAmountCaptured($orderLoaded->id);
$stillToCapture = $orderTotal - $totalEncaissement;
// Modif ajout texte warning si montant pas completement capture
if ($stillToCapture) {
if (version_compare(_PS_VERSION_, '1.5', '>')) {
$cookie = $this->context->cookie;
} else {
global $cookie;
}
// Retrieve _PS_OS_PAYMENT_ real name
$tmpOS = new OrderState((int) _PS_OS_PAYMENT_, $cookie->id_lang);
$form .= '
<table class="table" width="100%" cellspacing="0" cellpadding="0">
<tr>
<th>' . $this->l('The order has not been fully captured.') . '</th>
</tr><tr>
<th>' . $this->l('To generate the invoice, you must capture the remaining amount due which will generate an invoice once the order full amount has been captured.') . '</th>
</tr>
</table>
<p> </p>
';
}
// summary of amount captured, still to capture
$form .= '
<table class="table" width="100%" cellspacing="0" cellpadding="0">
<tr>
<th>' . $this->l('Amount already captured') . '</th>
<th>' . $this->l('Amount still to be captured') . '</th>
</tr>
<tr>
<td class="value"><span class="badge badge-success">' . Tools::displayPrice($totalEncaissement) . '</span></td>
<td class="value"><span class="badge badge-info">' . Tools::displayPrice($stillToCapture) . '</span></td>
</tr>
</table>';
$form .= '<div style="font-size: 12px;">
<sup>*</sup> ' . $this->l('Amounts will be updated once the capture will be confirmed by HiPay Fullservice') . '</div>';
$old_message = Message::getMessageByCartId((int) Tools::getValue('id_order'));
$adminDir = _PS_ADMIN_DIR_;
$adminDir = Tools::substr($adminDir, strrpos($adminDir, '/'));
$adminDir = Tools::substr($adminDir, strrpos($adminDir, '\\'));
$adminDir = str_replace('\\', '', $adminDir);
$adminDir = str_replace('/', '', $adminDir);
$context = Context::getContext();
// Last check
// If state should not allow user to manually capture then disable display
if ($currentState == _PS_OS_ERROR_ || $currentState == _PS_OS_CANCELED_ || $currentState == Configuration::get('HIPAY_EXPIRED') || $currentState == Configuration::get('HIPAY_REFUND_REQUESTED') || $currentState == Configuration::get('HIPAY_REFUNDED')) {
$stillToCapture = false;
}
if ($stillToCapture && $hide_capture == false) {
$form .= "<script>\r\n\t \$( document ).ready(function() {\r\n\t \t\$('#hipay_capture_form').submit( function(){\r\n\t \t\tvar type=\$('[name=hipay_capture_type]:checked').val();\r\n\t \t\tvar proceed = 'true';\r\n\t \t\t/*if(type=='partial')\r\n\t \t\t{\r\n\t \t\t\tvar amount=\$('#hidden4').val();\r\n\t \t\t\tif(amount == '')\r\n\t \t\t\t{\r\n\t \t\t\t\talert('" . $this->l('Please enter an amount') . "');\r\n\t \t\t\t\tproceed = 'false';\r\n\t \t\t\t}\r\n\t \t\t\tif(amount<=0)\r\n\t \t\t\t{\r\n\t \t\t\t\talert('" . $this->l('Please enter an amount greater than zero') . "');\r\n\t \t\t\t\tproceed = 'false';\r\n\t \t\t\t}\r\n\t \t\t\tif(amount>" . $stillToCapture . ")\r\n\t \t\t\t{\r\n\t \t\t\t\talert('" . $this->l('Amount exceeding authorized amount') . "');\r\n\t \t\t\t\tproceed = 'false';\r\n\t \t\t\t}\r\n\t \t\t}*/\r\n\r\n\t \t\tif(proceed == 'false')\r\n\t \t\t{\r\n\t \t\t\treturn false;\r\n\t \t\t}else{\r\n\t \t\t\treturn true;\r\n\t \t\t}\r\n\r\n\t \t\treturn false;\r\n\t \t});\r\n\t\t\t\t\t});\r\n </script>";
$form .= '<form action="' . $form_action . '" method="post" id="hipay_capture_form">';
$form .= '<input type="hidden" name="id_order" value="' . Tools::getValue('id_order') . '" />';
$form .= '<input type="hidden" name="id_emp" value="' . $context->employee->id . '" />';
$form .= '<input type="hidden" name="token" value="' . Tools::getValue('token') . '" />';
$form .= '<input type="hidden" name="adminDir" value="' . $adminDir . '" />';
$form .= '<p><table>';
$form .= '<tr><td><label for="hipay_capture_type">' . $this->l('Capture type') . '</label></td><td> </td>';
if ((bool) $orderLoaded->getHistory($context->language->id, Configuration::get('HIPAY_PARTIALLY_CAPTURED'))) {
$form .= '<td>';
$form .= '<input type="radio" onclick="javascript:document.getElementById(\'hidden3\').style.display=\'inline\';javascript:document.getElementById(\'hidden4\').style.display=\'inline\';" name="hipay_capture_type" id="hipay_capture_type" value="partial" checked />' . $this->l('Partial') . '</td></tr>';
} else {
$form .= '<td><input type="radio" onclick="javascript:document.getElementById(\'hidden3\').style.display=\'none\';javascript:document.getElementById(\'hidden4\').style.display=\'none\';" name="hipay_capture_type" value="complete" checked />' . $this->l('Complete') . '<br>';
$form .= '<input type="radio" onclick="javascript:document.getElementById(\'hidden3\').style.display=\'inline\';javascript:document.getElementById(\'hidden4\').style.display=\'inline\';" name="hipay_capture_type" id="hipay_capture_type" value="partial" />' . $this->l('Partial') . '</td></tr>';
}
$form .= '</table></p>';
$form .= '<p>';
if ((bool) $orderLoaded->getHistory($context->language->id, Configuration::get('HIPAY_PARTIALLY_CAPTURED'))) {
$form .= '<label style="display:block;" id="hidden3" >' . $this->l('Capture amount') . '</label>';
$form .= '<input style="display:block;" id="hidden4" type="text" name="hipay_capture_amount" value="' . round($stillToCapture, 2) . '" />';
} else {
$form .= '<label style="display:none;" id="hidden3" >' . $this->l('Capture amount') . '</label>';
$form .= '<input style="display:none;" id="hidden4" type="text" name="hipay_capture_amount" value="' . round($stillToCapture, 2) . '" />';
}
$form .= '</p>';
$form .= '<label> </label><input type="submit" name="hipay_capture_submit" class="btn btn-primary" value="' . $this->l('Capture') . '" />';
$form .= '</form>';
} else {
$form .= '<p>' . $this->l('This order has already been fully captured, cannot be captured or waiting authorization for capture') . '</p>';
}
$form .= '</fieldset>';
}
$form .= '</fieldset></div>';
}
return $form;
}
}
示例12: _assignAddress
protected function _assignAddress()
{
//if guest checkout disabled and flag is_guest in cookies is actived
if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED') == 0 and (int) self::$cookie->is_guest != Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
self::$cookie->logout();
Tools::redirect('');
} elseif (!Customer::getAddressesTotalById((int) self::$cookie->id_customer)) {
//Tools::redirect('address.php?back=order.php?step=1');
//self::$smarty->assign('no_address', 1);
}
$customer = new Customer((int) self::$cookie->id_customer);
if (Validate::isLoadedObject($customer)) {
/* Getting customer addresses */
$customerAddresses = $customer->getAddresses((int) self::$cookie->id_lang);
// Getting a list of formated address fields with associated values
$formatedAddressFieldsValuesList = array();
foreach ($customerAddresses as $address) {
$tmpAddress = new Address($address['id_address']);
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']);
$formatedAddressFieldsValuesList[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues($tmpAddress, $formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields']);
unset($tmpAddress);
}
self::$smarty->assign(array('addresses' => $customerAddresses, 'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList));
/* Setting default addresses for cart */
if ((!isset(self::$cart->id_address_delivery) or empty(self::$cart->id_address_delivery)) and sizeof($customerAddresses)) {
self::$cart->id_address_delivery = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
if ((!isset(self::$cart->id_address_invoice) or empty(self::$cart->id_address_invoice)) and sizeof($customerAddresses)) {
self::$cart->id_address_invoice = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
/* Update cart addresses only if needed */
if (isset($update) and $update) {
self::$cart->update();
}
/* If delivery address is valid in cart, assign it to Smarty */
if (isset(self::$cart->id_address_delivery)) {
$deliveryAddress = new Address((int) self::$cart->id_address_delivery);
if ($deliveryAddress->id_state) {
$deliveryAddress->state = State::getNameById($deliveryAddress->id_state);
}
if (Validate::isLoadedObject($deliveryAddress) and $deliveryAddress->id_customer == $customer->id) {
self::$smarty->assign('delivery', $deliveryAddress);
}
}
/* If invoice address is valid in cart, assign it to Smarty */
if (isset(self::$cart->id_address_invoice)) {
$invoiceAddress = new Address((int) self::$cart->id_address_invoice);
if ($invoiceAddress->id_state) {
$invoiceAddress->state = State::getNameById($invoiceAddress->id_state);
}
if (Validate::isLoadedObject($invoiceAddress) and $invoiceAddress->id_customer == $customer->id) {
self::$smarty->assign('invoice', $invoiceAddress);
}
}
//assign countries
$countries = Country::getCountries(1);
$country_names = Country::getActiveCountries();
self::$smarty->assign('countries', $countries);
self::$smarty->assign('country_names', $country_names);
if (isset(self::$cookie->id_country)) {
$id_current_country = self::$cookie->id_country;
} else {
$id_current_country = Tools::getValue('id_country', (int) $customer->id_country);
}
self::$smarty->assign('current_country', $id_current_country);
//default to USA
if (!$id_current_country) {
$id_current_country = 21;
}
//assign states
$country = new Country($id_current_country);
if ($country->contains_states) {
$stateData = State::getStatesByIdCountry($customer->id_country);
self::$smarty->assign('states', $stateData);
}
}
if ($oldMessage = Message::getMessageByCartId((int) self::$cart->id)) {
self::$smarty->assign('oldMessage', $oldMessage['message']);
}
//Assign token for new address
self::$smarty->assign('token', Tools::getToken(false));
self::$smarty->assign('id_carrier', self::$cart->id_carrier);
}
示例13: displayAddress
function displayAddress()
{
global $smarty, $cookie, $cart;
if (!Customer::getAddressesTotalById(intval($cookie->id_customer))) {
Tools::redirect('address.php?back=order.php?step=1');
}
$customer = new Customer(intval($cookie->id_customer));
if (Validate::isLoadedObject($customer)) {
/* Getting customer addresses */
$customerAddresses = $customer->getAddresses(intval($cookie->id_lang));
$smarty->assign('addresses', $customerAddresses);
/* Setting default addresses for cart */
if ((!isset($cart->id_address_delivery) or empty($cart->id_address_delivery)) and sizeof($customerAddresses)) {
$cart->id_address_delivery = intval($customerAddresses[0]['id_address']);
$update = 1;
}
if ((!isset($cart->id_address_invoice) or empty($cart->id_address_invoice)) and sizeof($customerAddresses)) {
$cart->id_address_invoice = intval($customerAddresses[0]['id_address']);
$update = 1;
}
/* Update cart addresses only if needed */
if (isset($update) and $update) {
$cart->update();
}
/* If delivery address is valid in cart, assign it to Smarty */
if (isset($cart->id_address_delivery)) {
$deliveryAddress = new Address(intval($cart->id_address_delivery));
if (Validate::isLoadedObject($deliveryAddress) and $deliveryAddress->id_customer == $customer->id) {
$smarty->assign('delivery', $deliveryAddress);
}
}
/* If invoice address is valid in cart, assign it to Smarty */
if (isset($cart->id_address_invoice)) {
$invoiceAddress = new Address(intval($cart->id_address_invoice));
if (Validate::isLoadedObject($invoiceAddress) and $invoiceAddress->id_customer == $customer->id) {
$smarty->assign('invoice', $invoiceAddress);
}
}
}
if ($oldMessage = Message::getMessageByCartId(intval($cart->id))) {
$smarty->assign('oldMessage', $oldMessage['message']);
}
$smarty->assign('cart', $cart);
Tools::safePostVars();
include_once dirname(__FILE__) . '/header.php';
$smarty->display(_PS_THEME_DIR_ . 'order-address.tpl');
}
示例14: _updateMessage
protected function _updateMessage($message_content)
{
if ($message_content) {
if (!Validate::isMessage($message_content)) {
$this->errors[] = Tools::displayError('Invalid message');
} else {
if ($old_message = Message::getMessageByCartId((int) $this->context->cart->id)) {
$message = new Message((int) $old_message['id_message']);
$message->message = $message_content;
$message->update();
} else {
$message = new Message();
$message->message = $message_content;
$message->id_cart = (int) $this->context->cart->id;
$message->id_customer = (int) $this->context->cart->id_customer;
$message->add();
}
}
} else {
if ($old_message = Message::getMessageByCartId($this->context->cart->id)) {
$message = new Message($old_message['id_message']);
$message->delete();
}
}
return true;
}
示例15: validateOrder
//.........这里部分代码省略.........
}
$voucher->id_customer = $order->id_customer;
$voucher->quantity = 1;
$voucher->quantity_per_user = 1;
$voucher->free_shipping = 0;
if ($voucher->add()) {
// If the voucher has conditions, they are now copied to the new voucher
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
$params = array('{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false), '{voucher_num}' => $voucher->code, '{firstname}' => $this->context->customer->firstname, '{lastname}' => $this->context->customer->lastname, '{id_order}' => $order->reference, '{order_name}' => $order->getUniqReference());
Mail::Send((int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop);
}
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
}
$total_reduction_value_ti += $values['tax_incl'];
$total_reduction_value_tex += $values['tax_excl'];
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
$cart_rule_used[] = $cart_rule['obj']->id;
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
$cart_rule_to_update->update();
}
$cart_rules_list[] = array('voucher_name' => $cart_rule['obj']->name, 'voucher_reduction' => ($values['tax_incl'] != 0.0 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false));
}
$cart_rules_list_txt = '';
$cart_rules_list_html = '';
if (count($cart_rules_list) > 0) {
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
}
// Specify order id for message
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
if ($old_message) {
$update_message = new Message((int) $old_message['id_message']);
$update_message->id_order = (int) $order->id;
$update_message->update();
// Add this message in the customer thread
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_customer = (int) $order->id_customer;
$customer_thread->id_shop = (int) $this->context->shop->id;
$customer_thread->id_order = (int) $order->id;
$customer_thread->id_lang = (int) $this->context->language->id;
$customer_thread->email = $this->context->customer->email;
$customer_thread->status = 'open';
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = 0;
$customer_message->message = $update_message->message;
$customer_message->private = 0;
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving message');
}
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
}
// Hook validate order
Hook::exec('actionValidateOrder', array('cart' => $this->context->cart, 'order' => $order, 'customer' => $this->context->customer, 'currency' => $this->context->currency, 'orderStatus' => $order_status));
foreach ($this->context->cart->getProducts() as $product) {
if ($order_status->logable) {
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);