本文整理匯總了PHP中OrderHistory::sendEmail方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderHistory::sendEmail方法的具體用法?PHP OrderHistory::sendEmail怎麽用?PHP OrderHistory::sendEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OrderHistory
的用法示例。
在下文中一共展示了OrderHistory::sendEmail方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postProcess
//.........這裏部分代碼省略.........
$cart_rules[$order_invoice->id]['value_tax_excl'] = $order_invoice->total_shipping_tax_excl;
// Update OrderInvoice
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} elseif ($order->hasInvoice()) {
$order_invoices_collection = $order->getInvoicesCollection();
foreach ($order_invoices_collection as $order_invoice) {
/** @var OrderInvoice $order_invoice */
if ($order_invoice->total_shipping_tax_incl <= 0) {
continue;
}
$cart_rules[$order_invoice->id]['value_tax_incl'] = $order_invoice->total_shipping_tax_incl;
$cart_rules[$order_invoice->id]['value_tax_excl'] = $order_invoice->total_shipping_tax_excl;
// Update OrderInvoice
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} else {
$cart_rules[0]['value_tax_incl'] = $order->total_shipping_tax_incl;
$cart_rules[0]['value_tax_excl'] = $order->total_shipping_tax_excl;
}
break;
default:
$this->errors[] = Tools::displayError('The discount type is invalid.');
}
$res = true;
foreach ($cart_rules as &$cart_rule) {
$cartRuleObj = new CartRule();
$cartRuleObj->date_from = date('Y-m-d H:i:s', strtotime('-1 hour', strtotime($order->date_add)));
$cartRuleObj->date_to = date('Y-m-d H:i:s', strtotime('+1 hour'));
$cartRuleObj->name[Configuration::get('PS_LANG_DEFAULT')] = Tools::getValue('discount_name');
$cartRuleObj->quantity = 0;
$cartRuleObj->quantity_per_user = 1;
if (Tools::getValue('discount_type') == 1) {
$cartRuleObj->reduction_percent = $discount_value;
} elseif (Tools::getValue('discount_type') == 2) {
$cartRuleObj->reduction_amount = $cart_rule['value_tax_excl'];
} elseif (Tools::getValue('discount_type') == 3) {
$cartRuleObj->free_shipping = 1;
}
$cartRuleObj->active = 0;
if ($res = $cartRuleObj->add()) {
$cart_rule['id'] = $cartRuleObj->id;
} else {
break;
}
}
if ($res) {
foreach ($cart_rules as $id_order_invoice => $cart_rule) {
// Create OrderCartRule
$order_cart_rule = new OrderCartRule();
$order_cart_rule->id_order = $order->id;
$order_cart_rule->id_cart_rule = $cart_rule['id'];
$order_cart_rule->id_order_invoice = $id_order_invoice;
$order_cart_rule->name = Tools::getValue('discount_name');
$order_cart_rule->value = $cart_rule['value_tax_incl'];
$order_cart_rule->value_tax_excl = $cart_rule['value_tax_excl'];
$res &= $order_cart_rule->add();
$order->total_discounts += $order_cart_rule->value;
$order->total_discounts_tax_incl += $order_cart_rule->value;
$order->total_discounts_tax_excl += $order_cart_rule->value_tax_excl;
$order->total_paid -= $order_cart_rule->value;
$order->total_paid_tax_incl -= $order_cart_rule->value;
$order->total_paid_tax_excl -= $order_cart_rule->value_tax_excl;
}
// Update Order
$res &= $order->update();
}
if ($res) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('An error occurred during the OrderCartRule creation');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('sendStateEmail') && Tools::getValue('sendStateEmail') > 0 && Tools::getValue('id_order') > 0) {
if ($this->tabAccess['edit'] === '1') {
$order_state = new OrderState((int) Tools::getValue('sendStateEmail'));
if (!Validate::isLoadedObject($order_state)) {
$this->errors[] = Tools::displayError('An error occurred while loading order status.');
} else {
$history = new OrderHistory((int) Tools::getValue('id_order_history'));
$carrier = new Carrier($order->id_carrier, $order->id_lang);
$templateVars = array();
if ($order_state->id == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number) {
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
}
if ($history->sendEmail($order, $templateVars)) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=10&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('An error occurred while sending the e-mail to the customer.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
parent::postProcess();
}