本文整理汇总了PHP中OrderReturn类的典型用法代码示例。如果您正苦于以下问题:PHP OrderReturn类的具体用法?PHP OrderReturn怎么用?PHP OrderReturn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OrderReturn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
public function preProcess()
{
parent::preProcess();
if (Tools::isSubmit('submitReturnMerchandise')) {
$customizationQtyInput = Tools::getValue('customization_qty_input');
if (!($id_order = (int) Tools::getValue('id_order'))) {
Tools::redirect('history.php');
}
if (!($order_qte_input = Tools::getValue('order_qte_input'))) {
Tools::redirect('order-follow.php?errorDetail1');
}
if ($customizationIds = Tools::getValue('customization_ids') and !$customizationQtyInput) {
Tools::redirect('order-follow.php?errorDetail1');
}
if (!($ids_order_detail = Tools::getValue('ids_order_detail')) and !$customizationIds) {
Tools::redirect('order-follow.php?errorDetail2');
}
$order = new Order((int) $id_order);
if (!$order->isReturnable()) {
Tools::redirect('order-follow.php?errorNotReturnable');
}
if ($order->id_customer != self::$cookie->id_customer) {
die(Tools::displayError());
}
$orderReturn = new OrderReturn();
$orderReturn->id_customer = (int) self::$cookie->id_customer;
$orderReturn->id_order = $id_order;
$orderReturn->question = strval(Tools::getValue('returnText'));
if (empty($orderReturn->question)) {
Tools::redirect('order-follow.php?errorMsg');
}
if (!$orderReturn->checkEnoughProduct($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput)) {
Tools::redirect('order-follow.php?errorQuantity');
}
$orderReturn->state = 1;
$orderReturn->add();
$orderReturn->addReturnDetail($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput);
Module::hookExec('orderReturn', array('orderReturn' => $orderReturn));
Tools::redirect('order-follow.php');
}
$ordersReturn = OrderReturn::getOrdersReturn((int) self::$cookie->id_customer);
if (Tools::isSubmit('errorQuantity')) {
self::$smarty->assign('errorQuantity', true);
} elseif (Tools::isSubmit('errorMsg')) {
self::$smarty->assign('errorMsg', true);
} elseif (Tools::isSubmit('errorDetail1')) {
self::$smarty->assign('errorDetail1', true);
} elseif (Tools::isSubmit('errorDetail2')) {
self::$smarty->assign('errorDetail2', true);
} elseif (Tools::isSubmit('errorNotReturnable')) {
self::$smarty->assign('errorNotReturnable', true);
}
self::$smarty->assign('ordersReturn', $ordersReturn);
}
示例2: getContent
/**
* Returns the template's HTML content
* @return string HTML content
*/
public function getContent()
{
$delivery_address = new Address((int) $this->order->id_address_delivery);
$formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' ');
$formatted_invoice_address = '';
if ($this->order->id_address_delivery != $this->order->id_address_invoice) {
$invoice_address = new Address((int) $this->order->id_address_invoice);
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' ');
}
$this->smarty->assign(array('order_return' => $this->order_return, 'return_nb_days' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS'), 'products' => OrderReturn::getOrdersReturnProducts((int) $this->order_return->id, $this->order), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'shop_address' => AddressFormat::generateAddress($this->shop->getAddress(), array(), '<br />', ' ')));
return $this->smarty->fetch($this->getTemplate('order-return'));
}
示例3: hookOrderReturn
public function hookOrderReturn($params)
{
$sEmail = Configuration::get('NOW_ORDER_RETURN_EMAIL');
if (Configuration::get('NOW_ORDER_RETURN_ACTIVE') && $sEmail) {
$oOrderReturn = $params['orderReturn'];
$oOrder = new Order((int) $oOrderReturn->id_order);
if (Validate::isLoadedObject($oOrderReturn)) {
$context = Context::getContext();
$aProducts = OrderReturn::getOrdersReturnProducts((int) $oOrderReturn->id, $oOrder);
$aParamsEmail = array('{firstname}' => $context->customer->firstname, '{lastname}' => $context->customer->lastname, '{id_order_return}' => $oOrderReturn->id, '{id_order}' => $oOrderReturn->id_order, '{product_html}' => $this->getProductListforEmailHTML($aProducts), '{product_txt}' => $this->getProductListforEmailTXT($aProducts));
$return = Mail::Send($context->language->id, 'order_return', Mail::l('Order Return', $context->language->id), $aParamsEmail, $sEmail, 'Administrator', $context->customer->email, $context->customer->lastname . ' - ' . $context->customer->firstname, NULL, NULL, $this->module_dir . 'mails/');
return $return;
}
}
}
示例4: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$ordersReturn = OrderReturn::getOrdersReturn($this->context->customer->id);
if (Tools::isSubmit('errorQuantity')) {
$this->context->smarty->assign('errorQuantity', true);
} elseif (Tools::isSubmit('errorMsg')) {
$this->context->smarty->assign(array('errorMsg' => true, 'ids_order_detail' => Tools::getValue('ids_order_detail', array()), 'order_qte_input' => Tools::getValue('order_qte_input', array()), 'id_order' => Tools::getValue('id_order')));
} elseif (Tools::isSubmit('errorDetail1')) {
$this->context->smarty->assign('errorDetail1', true);
} elseif (Tools::isSubmit('errorDetail2')) {
$this->context->smarty->assign('errorDetail2', true);
} elseif (Tools::isSubmit('errorNotReturnable')) {
$this->context->smarty->assign('errorNotReturnable', true);
}
$this->context->smarty->assign('ordersReturn', $ordersReturn);
$this->setTemplate(_PS_THEME_DIR_ . 'order-follow.tpl');
}
示例5: preProcess
public function preProcess()
{
parent::preProcess();
if (!isset($_GET['id_order_return']) or !Validate::isUnsignedId($_GET['id_order_return'])) {
$this->errors[] = Tools::displayError('Order ID required');
} else {
$orderRet = new OrderReturn((int) $_GET['id_order_return']);
if (Validate::isLoadedObject($orderRet) and $orderRet->id_customer == self::$cookie->id_customer) {
$order = new Order((int) $orderRet->id_order);
if (Validate::isLoadedObject($order)) {
$state = new OrderReturnState((int) $orderRet->state);
self::$smarty->assign(array('orderRet' => $orderRet, 'order' => $order, 'state_name' => $state->name[(int) self::$cookie->id_lang], 'return_allowed' => false, 'products' => OrderReturn::getOrdersReturnProducts((int) $orderRet->id, $order), 'returnedCustomizations' => OrderReturn::getReturnedCustomizedProducts((int) $orderRet->id_order), 'customizedDatas' => Product::getAllCustomizedDatas((int) $order->id_cart)));
} else {
$this->errors[] = Tools::displayError('Cannot find this order return');
}
} else {
$this->errors[] = Tools::displayError('Cannot find this order return');
}
}
self::$smarty->assign(array('errors' => $this->errors, 'nbdaysreturn' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS')));
}
示例6: init
/**
* Initialize order return controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
if (!isset($_GET['id_order_return']) || !Validate::isUnsignedId($_GET['id_order_return'])) {
$this->errors[] = Tools::displayError('Order ID required');
} else {
$orderRet = new OrderReturn((int) $_GET['id_order_return']);
if (Validate::isLoadedObject($orderRet) && $orderRet->id_customer == $this->context->cookie->id_customer) {
$order = new Order((int) $orderRet->id_order);
if (Validate::isLoadedObject($order)) {
$state = new OrderReturnState((int) $orderRet->state);
$this->context->smarty->assign(array('orderRet' => $orderRet, 'order' => $order, 'state_name' => $state->name[(int) $this->context->language->id], 'return_allowed' => false, 'products' => OrderReturn::getOrdersReturnProducts((int) $orderRet->id, $order), 'returnedCustomizations' => OrderReturn::getReturnedCustomizedProducts((int) $orderRet->id_order), 'customizedDatas' => Product::getAllCustomizedDatas((int) $order->id_cart)));
} else {
$this->errors[] = Tools::displayError('Cannot find the order return.');
}
} else {
$this->errors[] = Tools::displayError('Cannot find the order return.');
}
}
}
示例7: cronReturnSync
public function cronReturnSync()
{
// Check if client is initialized
if (is_null($this->client)) {
return false;
}
//Retrieve returns
$returns = $this->client->getReturns(array(0));
//Check declared returns
if (is_null($returns) || $returns->count() == 0) {
return false;
}
$customizationQtyInput = Tools::getValue('customization_qty_input');
$customizationIds = Tools::getValue('customization_ids');
foreach ($returns as $return) {
$return_lines = $return->getLines();
$channelengine_order_id = $return->getOrderId();
$sql = "SELECT id_order FROM " . _DB_PREFIX_ . "orders WHERE id_channelengine_order ='" . $channelengine_order_id . "'";
$prestashop_order_id = Db::getInstance()->getValue($sql);
$sql = "SELECT id_order_detail FROM" . _DB_PREFIX_ . "order_detail WHERE id_order ='" . $prestashop_order_id . "'";
$ids_order_details = Db::getInstance()->executeS($sql);
$ids_order_detail_array = array();
foreach ($ids_order_details as $key => $ids_order_detail) {
$ids_order_detail_array[$ids_order_detail['id_order_detail']] = $ids_order_detail['id_order_detail'];
}
$quantity_array = array();
$keys = array_keys($ids_order_detail_array);
foreach ($return_lines as $i => $return_line) {
$quantity_array[$keys[$i]] = $return_line->getQuantity();
$order = new Order((int) $prestashop_order_id);
$orderReturn = new OrderReturn();
$orderReturn->id_customer = (int) $order->id_customer;
$orderReturn->id_order = $prestashop_order_id;
$orderReturn->question = htmlspecialchars(Tools::getValue('returnText'));
if (empty($orderReturn->question)) {
http_build_query(array('ids_order_detail' => $ids_order_detail_array, 'order_qte_input' => $quantity_array, 'id_order' => $prestashop_order_id));
}
}
$orderReturn->state = 1;
$orderReturn->add();
$orderReturn->addReturnDetail($ids_order_detail_array, $quantity_array, $customizationIds, $customizationQtyInput);
Hook::exec('actionOrderReturn', array('orderReturn' => $orderReturn));
}
}
示例8: hookOrderReturn
public function hookOrderReturn($params)
{
$result = Db::getInstance()->getRow('
SELECT f.id_loyalty
FROM `' . _DB_PREFIX_ . 'loyalty` f
WHERE f.id_customer = ' . intval($params['orderReturn']->id_customer) . '
AND f.id_order = ' . intval($params['orderReturn']->id_order));
$loyalty = new LoyaltyModule(intval($result['id_loyalty']));
if (!Validate::isLoadedObject($loyalty)) {
return false;
}
$totalPrice = 0;
$details = OrderReturn::getOrdersReturnDetail($params['orderReturn']->id);
foreach ($details as $detail) {
$result = Db::getInstance()->getRow('
SELECT product_price * (1 + (tax_rate / 100)) AS ttc
FROM ' . _DB_PREFIX_ . 'order_detail od
WHERE id_order_detail = ' . intval($detail['id_order_detail']));
$totalPrice += $result['ttc'] * $detail['product_quantity'];
}
$canceledTotal = floor($totalPrice / floatval(Configuration::get('PS_LOYALTY_POINT_RATE')));
if ($canceledTotal > $loyalty->points) {
$canceledTotal = $loyalty->points;
}
Db::getInstance()->Execute('
INSERT INTO `' . _DB_PREFIX_ . 'loyalty_history` (`id_loyalty`, `id_loyalty_state`, `points`, `date_add`)
VALUES (' . intval($loyalty->id) . ', ' . intval(LoyaltyStateModule::getCancelId()) . ', -' . intval($canceledTotal) . ', NOW())');
$loyalty->points -= $canceledTotal;
$loyalty->update();
Db::getInstance()->Execute('
INSERT INTO `' . _DB_PREFIX_ . 'loyalty_history` (`id_loyalty`, `id_loyalty_state`, `points`, `date_add`)
VALUES (' . intval($loyalty->id) . ', ' . intval(LoyaltyStateModule::getValidationId()) . ', ' . intval($loyalty->points) . ', NOW())');
}
示例9: hookOrderReturn
public function hookOrderReturn($params)
{
include_once dirname(__FILE__) . '/LoyaltyStateModule.php';
include_once dirname(__FILE__) . '/LoyaltyModule.php';
$total_price = 0;
$details = OrderReturn::getOrdersReturnDetail((int) $params['orderReturn']->id);
foreach ($details as $detail) {
$total_price += Db::getInstance()->getValue('
SELECT ROUND(total_price_tax_incl, 2)
FROM ' . _DB_PREFIX_ . 'order_detail od
WHERE id_order_detail = ' . (int) $detail['id_order_detail']);
}
$loyalty_new = new LoyaltyModule();
$loyalty_new->points = (int) (-1 * LoyaltyModule::getNbPointsByPrice($total_price));
$loyalty_new->id_loyalty_state = (int) LoyaltyStateModule::getCancelId();
$loyalty_new->id_order = (int) $params['orderReturn']->id_order;
$loyalty_new->id_customer = (int) $params['orderReturn']->id_customer;
$loyalty_new->save();
}
示例10: getTemplateVarOrdersReturns
public function getTemplateVarOrdersReturns()
{
$orders_returns = array();
$orders_return = OrderReturn::getOrdersReturn($this->context->customer->id);
$orderReturnPresenter = new OrderReturnPresenter(Configuration::get('PS_RETURN_PREFIX', $this->context->language->id), $this->context->link);
foreach ($orders_return as $id_order_return => $order_return) {
$orders_returns[$id_order_return] = $orderReturnPresenter->present($order_return);
}
return $orders_returns;
}
示例11: getOrdersReturnProducts
public static function getOrdersReturnProducts($orderReturnId, $order)
{
$productsRet = OrderReturn::getOrdersReturnDetail($orderReturnId);
$products = $order->getProducts();
$tmp = array();
foreach ($productsRet as $return_detail) {
$tmp[$return_detail['id_order_detail']]['quantity'] = isset($tmp[$return_detail['id_order_detail']]['quantity']) ? $tmp[$return_detail['id_order_detail']]['quantity'] + (int) $return_detail['product_quantity'] : (int) $return_detail['product_quantity'];
$tmp[$return_detail['id_order_detail']]['customizations'] = (int) $return_detail['id_customization'];
}
$resTab = array();
foreach ($products as $key => $product) {
if (isset($tmp[$product['id_order_detail']])) {
$resTab[$key] = $product;
$resTab[$key]['product_quantity'] = $tmp[$product['id_order_detail']]['quantity'];
$resTab[$key]['customizations'] = $tmp[$product['id_order_detail']]['customizations'];
}
}
return $resTab;
}
示例12: array
/* JS files calls */
$js_files = array(__PS_BASE_URI__ . 'js/jquery/jquery.scrollto.js', _THEME_JS_DIR_ . 'history.js');
if (Tools::isSubmit('submitReturnMerchandise')) {
if (!($id_order = intval(Tools::getValue('id_order')))) {
Tools::redirect('history.php');
}
if (!($order_qte_input = Tools::getValue('order_qte_input'))) {
Tools::redirect('order-follow.php?errorDetail1');
}
if ($customizationIds = Tools::getValue('customization_ids') and !($customizationQtyInput = Tools::getValue('customization_qty_input'))) {
Tools::redirect('order-follow.php?errorDetail1');
}
if (!($ids_order_detail = Tools::getValue('ids_order_detail')) and !$customizationIds) {
Tools::redirect('order-follow.php?errorDetail2');
}
$orderReturn = new OrderReturn();
$orderReturn->id_customer = intval($cookie->id_customer);
$orderReturn->id_order = $id_order;
$orderReturn->question = strval(Tools::getValue('returnText'));
if (empty($orderReturn->question)) {
Tools::redirect('order-follow.php?errorMsg');
}
if (!$orderReturn->checkEnoughProduct($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput)) {
Tools::redirect('order-follow.php?errorQuantity');
}
$orderReturn->state = 1;
$orderReturn->add();
$orderReturn->addReturnDetail($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput);
Module::hookExec('orderReturn', array('orderReturn' => $orderReturn));
Tools::redirect('order-follow.php');
}
示例13: getReturn
public function getReturn()
{
return OrderReturn::getOrdersReturn($this->id_customer, $this->id);
}
示例14: hookOrderReturn
public function hookOrderReturn($params)
{
include_once dirname(__FILE__) . '/LoyaltyStateModule.php';
include_once dirname(__FILE__) . '/LoyaltyModule.php';
$totalPrice = 0;
$details = OrderReturn::getOrdersReturnDetail((int) $params['orderReturn']->id);
foreach ($details as $detail) {
$price_wt = Db::getInstance()->getValue('
SELECT product_price * (1 + (tax_rate / 100)) price
FROM ' . _DB_PREFIX_ . 'order_detail od
WHERE id_order_detail = ' . (int) $detail['id_order_detail']);
$totalPrice += number_format($price_wt, 2, '.', '') * $detail['product_quantity'];
}
$loyaltyNew = new LoyaltyModule();
$loyaltyNew->points = (int) (-1 * LoyaltyModule::getNbPointsByPrice($totalPrice));
$loyaltyNew->id_loyalty_state = (int) LoyaltyStateModule::getCancelId();
$loyaltyNew->id_order = (int) $params['orderReturn']->id_order;
$loyaltyNew->id_customer = (int) $params['orderReturn']->id_customer;
$loyaltyNew->save();
}
示例15: hookActionOrderReturn
/**
* Send a mail when a customer return an order.
*
* @param array $params Hook params.
*/
public function hookActionOrderReturn($params)
{
if (!$this->return_slip || empty($this->return_slip)) {
return;
}
$context = Context::getContext();
$id_lang = (int) $context->language->id;
$id_shop = (int) $context->shop->id;
$configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME', 'PS_MAIL_COLOR'), $id_lang, null, $id_shop);
// Shop iso
$iso = Language::getIsoById((int) Configuration::get('PS_LANG_DEFAULT'));
$order = new Order((int) $params['orderReturn']->id_order);
$customer = new Customer((int) $params['orderReturn']->id_customer);
$delivery = new Address((int) $order->id_address_delivery);
$invoice = new Address((int) $order->id_address_invoice);
$order_date_text = Tools::displayDate($order->date_add);
if ($delivery->id_state) {
$delivery_state = new State((int) $delivery->id_state);
}
if ($invoice->id_state) {
$invoice_state = new State((int) $invoice->id_state);
}
$order_return_products = OrderReturn::getOrdersReturnProducts($params['orderReturn']->id, $order);
$items_table = '';
foreach ($order_return_products as $key => $product) {
$url = $context->link->getProductLink($product['product_id']);
$items_table .= '<tr style="background-color:' . ($key % 2 ? '#DDE2E6' : '#EBECEE') . ';">
<td style="padding:0.6em 0.4em;">' . $product['product_reference'] . '</td>
<td style="padding:0.6em 0.4em;">
<strong><a href="' . $url . '">' . $product['product_name'] . '</a>
</strong>
</td>
<td style="padding:0.6em 0.4em; text-align:center;">' . (int) $product['product_quantity'] . '</td>
</tr>';
}
$template_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{delivery_block_txt}' => MailAlert::getFormatedAddress($delivery, "\n"), '{invoice_block_txt}' => MailAlert::getFormatedAddress($invoice, "\n"), '{delivery_block_html}' => MailAlert::getFormatedAddress($delivery, '<br />', array('firstname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>', 'lastname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>')), '{invoice_block_html}' => MailAlert::getFormatedAddress($invoice, '<br />', array('firstname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>', 'lastname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; 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_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}' => $order->reference, '{shop_name}' => $configuration['PS_SHOP_NAME'], '{date}' => $order_date_text, '{items}' => $items_table, '{message}' => Tools::purifyHTML($params['orderReturn']->question));
// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->merchant_mails);
foreach ($merchant_mails as $merchant_mail) {
// Default language
$mail_id_lang = $id_lang;
$mail_iso = $iso;
// Use the merchant lang if he exists as an employee
$results = Db::getInstance()->executeS('
SELECT `id_lang` FROM `' . _DB_PREFIX_ . 'employee`
WHERE `email` = \'' . pSQL($merchant_mail) . '\'
');
if ($results) {
$user_iso = Language::getIsoById((int) $results[0]['id_lang']);
if ($user_iso) {
$mail_id_lang = (int) $results[0]['id_lang'];
$mail_iso = $user_iso;
}
}
$dir_mail = false;
if (file_exists(dirname(__FILE__) . '/mails/' . $mail_iso . '/return_slip.txt') && file_exists(dirname(__FILE__) . '/mails/' . $mail_iso . '/return_slip.html')) {
$dir_mail = dirname(__FILE__) . '/mails/';
}
if (file_exists(_PS_MAIL_DIR_ . $mail_iso . '/return_slip.txt') && file_exists(_PS_MAIL_DIR_ . $mail_iso . '/return_slip.html')) {
$dir_mail = _PS_MAIL_DIR_;
}
if ($dir_mail) {
Mail::Send($mail_id_lang, 'return_slip', sprintf(Mail::l('New return from order #%d - %s', $mail_id_lang), $order->id, $order->reference), $template_vars, $merchant_mail, null, $configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME'], null, null, $dir_mail, null, $id_shop);
}
}
}