本文整理汇总了PHP中Discount::createOrderDiscount方法的典型用法代码示例。如果您正苦于以下问题:PHP Discount::createOrderDiscount方法的具体用法?PHP Discount::createOrderDiscount怎么用?PHP Discount::createOrderDiscount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discount
的用法示例。
在下文中一共展示了Discount::createOrderDiscount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
//.........这里部分代码省略.........
if (!$order->deleteProduct($order, $orderDetail, $qtyCancelProduct)) {
$this->_errors[] = Tools::displayError('An error occurred during deletion of the product.') . ' <span class="bold">' . $orderDetail->product_name . '</span>';
}
Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $id_order_detail));
}
}
if (!sizeof($this->_errors) and $customizationList) {
foreach ($customizationList as $id_customization => $id_order_detail) {
$orderDetail = new OrderDetail((int) $id_order_detail);
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $orderDetail)) {
$this->_errors[] = Tools::displayError('An error occurred during deletion of product customization.') . ' ' . $id_customization;
}
}
}
// E-mail params
if ((isset($_POST['generateCreditSlip']) or isset($_POST['generateDiscount'])) and !sizeof($this->_errors)) {
$customer = new Customer((int) $order->id_customer);
$params['{lastname}'] = $customer->lastname;
$params['{firstname}'] = $customer->firstname;
$params['{id_order}'] = $order->id;
}
// Generate credit slip
if (isset($_POST['generateCreditSlip']) and !sizeof($this->_errors)) {
if (!OrderSlip::createOrderSlip($order, $full_product_list, $full_quantity_list, isset($_POST['shippingBack']))) {
$this->_errors[] = Tools::displayError('Cannot generate credit slip');
} else {
Module::hookExec('orderSlip', array('order' => $order, 'productList' => $full_product_list, 'qtyList' => $full_quantity_list));
@Mail::Send((int) $order->id_lang, 'credit_slip', Mail::l('New credit slip regarding your order'), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname);
}
}
// Generate voucher
if (isset($_POST['generateDiscount']) and !sizeof($this->_errors)) {
if (!($voucher = Discount::createOrderDiscount($order, $full_product_list, $full_quantity_list, $this->l('Credit Slip concerning the order #'), isset($_POST['shippingBack'])))) {
$this->_errors[] = Tools::displayError('Cannot generate voucher');
} else {
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
$params['{voucher_num}'] = $voucher->name;
@Mail::Send((int) $order->id_lang, 'voucher', Mail::l('New voucher regarding your order'), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname);
}
}
} else {
$this->_errors[] = Tools::displayError('No product or quantity selected.');
}
// Redirect if no errors
if (!sizeof($this->_errors)) {
Tools::redirectAdmin($currentIndex . '&id_order=' . $order->id . '&vieworder&conf=24&token=' . $this->token);
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} elseif (Tools::isSubmit('updateOrder') and Validate::isLoadedObject($order = new Order((int) Tools::getValue('id_order')))) {
$cart = Cart::getCartByOrderId($order->id);
$update = false;
if ($discountValue = Tools::getValue('addDiscount')) {
$discountVoucher = new Discount();
$discountVoucher->name = 'ADMIND-' . $order->id . date('mdHis');
$discountVoucher->id_discount_type = 2;
$discountVoucher->id_customer = $order->id_customer;
$discountVoucher->cumulable = 1;
$discountVoucher->cumulable_reduction = 1;
$discountVoucher->date_from = $order->date_add;
$discountVoucher->date_to = date('Y-m-d', time() + 86400);
$discountVoucher->quantity = 1;
$discountVoucher->quantity_per_user = 1;
示例2: postProcess
//.........这里部分代码省略.........
if ($order_detail->product_quantity - $customization_quantity - $order_detail->product_quantity_refunded - $order_detail->product_quantity_return < $qtyCancelProduct) {
$this->_errors[] = Tools::displayError('Invalid quantity selected for product.');
}
}
}
if ($customizationList) {
$customization_quantities = Customization::retrieveQuantitiesFromIds(array_keys($customizationList));
foreach ($customizationList as $id_customization => $id_order_detail) {
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
$customization_quantity = $customization_quantities[$id_customization];
if (!$qtyCancelProduct) {
$this->_errors[] = Tools::displayError('No quantity selected for product.');
}
if ($qtyCancelProduct > $customization_quantity['quantity'] - ($customization_quantity['quantity_refunded'] + $customization_quantity['quantity_returned'])) {
$this->_errors[] = Tools::displayError('Invalid quantity selected for product.');
}
}
}
if (!sizeof($this->_errors) and $productList) {
foreach ($productList as $key => $id_order_detail) {
$qtyCancelProduct = abs($qtyList[$key]);
$orderDetail = new OrderDetail((int) $id_order_detail);
// Reinject product
if (!$order->hasBeenDelivered() or $order->hasBeenDelivered() and Tools::isSubmit('reinjectQuantities')) {
$reinjectableQuantity = (int) $orderDetail->product_quantity - (int) $orderDetail->product_quantity_reinjected;
$quantityToReinject = $qtyCancelProduct > $reinjectableQuantity ? $reinjectableQuantity : $qtyCancelProduct;
if (!Product::reinjectQuantities($orderDetail, $quantityToReinject)) {
$this->_errors[] = Tools::displayError('Cannot re-stock product') . ' <span class="bold">' . $orderDetail->product_name . '</span>';
} else {
$updProductAttributeID = !empty($orderDetail->product_attribute_id) ? (int) $orderDetail->product_attribute_id : NULL;
$newProductQty = Product::getQuantity((int) $orderDetail->product_id, $updProductAttributeID);
$product = get_object_vars(new Product((int) $orderDetail->product_id, false, (int) $cookie->id_lang));
if (!empty($orderDetail->product_attribute_id)) {
$updProduct['quantity_attribute'] = (int) $newProductQty;
$product['quantity_attribute'] = $updProduct['quantity_attribute'];
} else {
$updProduct['stock_quantity'] = (int) $newProductQty;
$product['stock_quantity'] = $updProduct['stock_quantity'];
}
Hook::updateQuantity($product, $order);
}
}
// Delete product
if (!$order->deleteProduct($order, $orderDetail, $qtyCancelProduct)) {
$this->_errors[] = Tools::displayError('An error occurred during deletion of the product.') . ' <span class="bold">' . $orderDetail->product_name . '</span>';
}
Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $id_order_detail));
}
}
if (!sizeof($this->_errors) and $customizationList) {
foreach ($customizationList as $id_customization => $id_order_detail) {
$orderDetail = new OrderDetail((int) $id_order_detail);
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $orderDetail)) {
$this->_errors[] = Tools::displayError('An error occurred during deletion of product customization.') . ' ' . $id_customization;
}
}
}
// E-mail params
if ((isset($_POST['generateCreditSlip']) or isset($_POST['generateDiscount'])) and !sizeof($this->_errors)) {
$customer = new Customer((int) $order->id_customer);
$params['{lastname}'] = $customer->lastname;
$params['{firstname}'] = $customer->firstname;
$params['{id_order}'] = $order->id;
}
// Generate credit slip
if (isset($_POST['generateCreditSlip']) and !sizeof($this->_errors)) {
if (!OrderSlip::createOrderSlip($order, $full_product_list, $full_quantity_list, isset($_POST['shippingBack']))) {
$this->_errors[] = Tools::displayError('Cannot generate credit slip');
} else {
Module::hookExec('orderSlip', array('order' => $order, 'productList' => $full_product_list, 'qtyList' => $full_quantity_list));
@Mail::Send((int) $order->id_lang, 'credit_slip', Mail::l('New credit slip regarding your order', $order->id_lang), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname, NULL, NULL, NULL, NULL, _PS_MAIL_DIR_, true);
}
}
// Generate voucher
if (isset($_POST['generateDiscount']) and !sizeof($this->_errors)) {
if (!($voucher = Discount::createOrderDiscount($order, $full_product_list, $full_quantity_list, $this->l('Credit Slip concerning the order #'), isset($_POST['shippingBack'])))) {
$this->_errors[] = Tools::displayError('Cannot generate voucher');
} else {
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
$params['{voucher_num}'] = $voucher->name;
@Mail::Send((int) $order->id_lang, 'voucher', Mail::l('New voucher regarding your order'), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname, NULL, NULL, NULL, NULL, _PS_MAIL_DIR_, true);
}
}
} else {
$this->_errors[] = Tools::displayError('No product or quantity selected.');
}
// Redirect if no errors
if (!sizeof($this->_errors)) {
Tools::redirectAdmin($currentIndex . '&id_order=' . $order->id . '&vieworder&conf=24&token=' . $this->token);
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} elseif (isset($_GET['messageReaded'])) {
Message::markAsReaded((int) $_GET['messageReaded'], (int) $cookie->id_employee);
}
parent::postProcess();
}
示例3: postProcess
//.........这里部分代码省略.........
}
$this->_errors[] = Tools::displayError('an error occurred while sending e-mail to the customer');
}
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} elseif (Tools::isSubmit('cancelProduct') and Validate::isLoadedObject($order = new Order(intval(Tools::getValue('id_order'))))) {
if ($this->tabAccess['delete'] === '1') {
$productList = Tools::getValue('id_order_detail');
$customizationList = Tools::getValue('id_customization');
$qtyList = Tools::getValue('cancelQuantity');
$customizationQtyList = Tools::getValue('cancelCustomizationQuantity');
if ($productList or $customizationList) {
if ($productList) {
foreach ($productList as $key => $id_order_detail) {
$qtyCancelProduct = abs($qtyList[$key]);
if (!$qtyCancelProduct) {
$this->_errors[] = Tools::displayError('No quantity selected for product.');
}
}
}
if ($customizationList) {
foreach ($customizationList as $id_customization => $id_order_detail) {
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
if (!$qtyCancelProduct) {
$this->_errors[] = Tools::displayError('No quantity selected for product.');
}
}
}
if (!sizeof($this->_errors) and $productList) {
foreach ($productList as $key => $id_order_detail) {
$qtyCancelProduct = abs($qtyList[$key]);
$orderDetail = new OrderDetail(intval($id_order_detail));
// Reinject product
if (isset($_POST['reinjectQuantities']) or !$order->hasBeenDelivered() and !$order->hasBeenPaid()) {
$reinjectableQuantity = intval($orderDetail->product_quantity_in_stock) - intval($orderDetail->product_quantity_reinjected);
$quantityToReinject = $qtyCancelProduct > $reinjectableQuantity ? $reinjectableQuantity : $qtyCancelProduct;
if (!Product::reinjectQuantities($orderDetail, $quantityToReinject)) {
$this->_errors[] = Tools::displayError('Cannot re-stock product') . ' <span class="bold">' . $orderDetail->product_name . '</span>';
}
}
// Delete product
if (!$order->deleteProduct($order, $orderDetail, $qtyCancelProduct)) {
$this->_errors[] = Tools::displayError('an error occurred during deletion for the product') . ' <span class="bold">' . $orderDetail->product_name . '</span>';
}
Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $id_order_detail));
}
}
if (!sizeof($this->_errors) and $customizationList) {
foreach ($customizationList as $id_customization => $id_order_detail) {
$orderDetail = new OrderDetail(intval($id_order_detail));
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $orderDetail)) {
$this->_errors[] = Tools::displayError('an error occurred during deletion for the product customization') . ' ' . $id_customization;
}
}
}
// E-mail params
if ((isset($_POST['generateCreditSlip']) or isset($_POST['generateDiscount'])) and !sizeof($this->_errors)) {
$customer = new Customer(intval($order->id_customer));
$params['{lastname}'] = $customer->lastname;
$params['{firstname}'] = $customer->firstname;
$params['{id_order}'] = $order->id;
}
// Generate credit slip
if (isset($_POST['generateCreditSlip']) and !sizeof($this->_errors)) {
if (!OrderSlip::createOrderSlip($order, $productList, $qtyList, isset($_POST['shippingBack']))) {
$this->_errors[] = Tools::displayError('Cannot generate credit slip');
} else {
Module::hookExec('orderSlip', array('order' => $order, 'productList' => $productList, 'qtyList' => $qtyList));
@Mail::Send(intval($order->id_lang), 'credit_slip', html_entity_decode($this->l('New credit slip regarding your order #') . $order->id, ENT_NOQUOTES, 'UTF-8'), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname);
}
}
// Generate voucher
if (isset($_POST['generateDiscount']) and !sizeof($this->_errors)) {
if (!($voucher = Discount::createOrderDiscount($order, $productList, $qtyList, $this->l('Credit Slip concerning the order #'), isset($_POST['shippingBack'])))) {
$this->_errors[] = Tools::displayError('Cannot generate voucher');
} else {
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false, false);
$params['{voucher_num}'] = $voucher->name;
@Mail::Send(intval($order->id_lang), 'voucher', html_entity_decode($this->l('New voucher regarding your order #') . $order->id, ENT_NOQUOTES, 'UTF-8'), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname);
}
}
} else {
$this->_errors[] = Tools::displayError('No product or quantity selected.');
}
// Redirect if no errors
if (!sizeof($this->_errors)) {
Tools::redirectLink($currentIndex . '&id_order=' . $order->id . '&vieworder&conf=1&token=' . $this->token);
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} elseif (isset($_GET['messageReaded'])) {
Message::markAsReaded(intval($_GET['messageReaded']), intval($cookie->id_employee));
}
parent::postProcess();
}