本文整理汇总了PHP中OrderSlip::create方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderSlip::create方法的具体用法?PHP OrderSlip::create怎么用?PHP OrderSlip::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderSlip
的用法示例。
在下文中一共展示了OrderSlip::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
//.........这里部分代码省略.........
if (!empty($refunds)) {
$this->errors[] = Tools::displayError('Please enter a quantity to proceed with your refund.');
} else {
$this->errors[] = Tools::displayError('Please enter an amount to proceed with your refund.');
}
return false;
}
$choosen = false;
$voucher = 0;
if ((int) Tools::getValue('refund_voucher_off') == 1) {
$amount -= $voucher = (double) Tools::getValue('order_discount_price');
} elseif ((int) Tools::getValue('refund_voucher_off') == 2) {
$choosen = true;
$amount = $voucher = (double) Tools::getValue('refund_voucher_choose');
}
if ($shipping_cost_amount > 0) {
if (!Tools::getValue('TaxMethod')) {
$tax = new Tax();
$tax->rate = $order->carrier_tax_rate;
$tax_calculator = new TaxCalculator(array($tax));
$amount += $tax_calculator->addTaxes($shipping_cost_amount);
} else {
$amount += $shipping_cost_amount;
}
}
$order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier)) {
$order_carrier->weight = (double) $order->getTotalWeight();
if ($order_carrier->update()) {
$order->weight = sprintf("%.3f " . Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
}
if ($amount >= 0) {
if (!OrderSlip::create($order, $order_detail_list, $shipping_cost_amount, $voucher, $choosen, Tools::getValue('TaxMethod') ? false : true)) {
$this->errors[] = Tools::displayError('You cannot generate a partial credit slip.');
}
foreach ($order_detail_list as &$product) {
$order_detail = new OrderDetail((int) $product['id_order_detail']);
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
StockAvailable::synchronize($order_detail->product_id);
}
}
// Generate voucher
if (Tools::isSubmit('generateDiscountRefund') && !count($this->errors) && $amount > 0) {
$cart_rule = new CartRule();
$cart_rule->description = sprintf($this->l('Credit slip for order #%d'), $order->id);
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
// Define a temporary name
$cart_rule->name[$language['id_lang']] = sprintf('V0C%1$dO%2$d', $order->id_customer, $order->id);
}
// Define a temporary code
$cart_rule->code = sprintf('V0C%1$dO%2$d', $order->id_customer, $order->id);
$cart_rule->quantity = 1;
$cart_rule->quantity_per_user = 1;
// Specific to the customer
$cart_rule->id_customer = $order->id_customer;
$now = time();
$cart_rule->date_from = date('Y-m-d H:i:s', $now);
$cart_rule->date_to = date('Y-m-d H:i:s', strtotime('+1 year'));
$cart_rule->partial_use = 1;
$cart_rule->active = 1;
$cart_rule->reduction_amount = $amount;
$cart_rule->reduction_tax = true;
$cart_rule->minimum_amount_currency = $order->id_currency;
$cart_rule->reduction_currency = $order->id_currency;
示例2: createOrderSlip
/**
* @deprecated since 1.6.0.10 use OrderSlip::create() instead
*
*/
public static function createOrderSlip($order, $productList, $qtyList, $shipping_cost = false)
{
Tools::displayAsDeprecated();
$product_list = array();
foreach ($productList as $id_order_detail) {
$order_detail = new OrderDetail((int) $id_order_detail);
$product_list[$id_order_detail] = array('id_order_detail' => $id_order_detail, 'quantity' => $qtyList[$id_order_detail], 'unit_price' => $order_detail->unit_price_tax_excl, 'amount' => $order_detail->unit_price_tax_incl * $qtyList[$id_order_detail]);
$shipping = $shipping_cost ? null : false;
}
return OrderSlip::create($order, $product_list, $shipping);
}