本文整理汇总了PHP中OrderSlip::add方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderSlip::add方法的具体用法?PHP OrderSlip::add怎么用?PHP OrderSlip::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderSlip
的用法示例。
在下文中一共展示了OrderSlip::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createPartialOrderSlip
public static function createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list)
{
$currency = new Currency($order->id_currency);
$orderSlip = new OrderSlip();
$orderSlip->id_customer = (int) $order->id_customer;
$orderSlip->id_order = (int) $order->id;
$orderSlip->amount = (double) $amount;
$orderSlip->shipping_cost = false;
$orderSlip->shipping_cost_amount = (double) $shipping_cost_amount;
$orderSlip->conversion_rate = $currency->conversion_rate;
$orderSlip->partial = 1;
if (!$orderSlip->add()) {
return false;
}
$orderSlip->addPartialSlipDetail($order_detail_list);
return true;
}
示例2: createOrderSlip
public static function createOrderSlip($order, $productList, $qtyList, $shipping_cost = false)
{
// create orderSlip
$orderSlip = new OrderSlip();
$orderSlip->id_customer = intval($order->id_customer);
$orderSlip->id_order = intval($order->id);
$orderSlip->shipping_cost = intval($shipping_cost);
if (!$orderSlip->add()) {
return false;
}
// add details
$orderSlip->addSlipDetail($productList, $qtyList);
return true;
}
示例3: createOrderSlip
public static function createOrderSlip($order, $productList, $qtyList, $shipping_cost = false)
{
$currency = new Currency($order->id_currency);
$orderSlip = new OrderSlip();
$orderSlip->id_customer = (int) $order->id_customer;
$orderSlip->id_order = (int) $order->id;
$orderSlip->shipping_cost = (int) $shipping_cost;
$orderSlip->conversion_rate = $currency->conversion_rate;
if (!$orderSlip->add()) {
return false;
}
$orderSlip->addSlipDetail($productList, $qtyList);
return true;
}
示例4: create
public static function create(Order $order, $product_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true)
{
$currency = new Currency((int) $order->id_currency);
$order_slip = new OrderSlip();
$order_slip->id_customer = (int) $order->id_customer;
$order_slip->id_order = (int) $order->id;
$order_slip->conversion_rate = $currency->conversion_rate;
if ($add_tax) {
$add_or_remove = 'add';
$inc_or_ex_1 = 'excl';
$inc_or_ex_2 = 'incl';
} else {
$add_or_remove = 'remove';
$inc_or_ex_1 = 'incl';
$inc_or_ex_2 = 'excl';
}
$order_slip->{'total_shipping_tax_' . $inc_or_ex_1} = 0;
$order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = 0;
$order_slip->partial = 0;
if ($shipping_cost !== false) {
$order_slip->shipping_cost = true;
$carrier = new Carrier((int) $order->id_carrier);
$address = Address::initialize($order->id_address_delivery, false);
$tax_calculator = $carrier->getTaxCalculator($address);
$order_slip->{'total_shipping_tax_' . $inc_or_ex_1} = $shipping_cost === null ? $order->{'total_shipping_tax_' . $inc_or_ex_1} : (double) $shipping_cost;
if ($tax_calculator instanceof TaxCalculator) {
$order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($order_slip->{'total_shipping_tax_' . $inc_or_ex_1}), _PS_PRICE_COMPUTE_PRECISION_);
} else {
$order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = $order_slip->{'total_shipping_tax_' . $inc_or_ex_1};
}
} else {
$order_slip->shipping_cost = false;
}
$order_slip->amount = 0;
$order_slip->{'total_products_tax_' . $inc_or_ex_1} = 0;
$order_slip->{'total_products_tax_' . $inc_or_ex_2} = 0;
foreach ($product_list as &$product) {
$order_detail = new OrderDetail((int) $product['id_order_detail']);
$price = (double) $product['unit_price'];
$quantity = (int) $product['quantity'];
$order_slip_resume = OrderSlip::getProductSlipResume((int) $order_detail->id);
if ($quantity + $order_slip_resume['product_quantity'] > $order_detail->product_quantity) {
$quantity = $order_detail->product_quantity - $order_slip_resume['product_quantity'];
}
if ($quantity == 0) {
continue;
}
$order_detail->product_quantity_refunded += $quantity;
$order_detail->save();
$address = Address::initialize($order->id_address_invoice, false);
$id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $order_detail->product_id);
$tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
$order_slip->{'total_products_tax_' . $inc_or_ex_1} += $price * $quantity;
if (in_array(Configuration::get('PS_ROUND_TYPE'), array(Order::ROUND_ITEM, Order::ROUND_LINE))) {
if (!isset($total_products[$id_tax_rules_group])) {
$total_products[$id_tax_rules_group] = 0;
} else {
if (!isset($total_products[$id_tax_rules_group . '_' . $id_address])) {
$total_products[$id_tax_rules_group . '_' . $id_address] = 0;
}
}
}
$product_tax_incl_line = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price) * $quantity, _PS_PRICE_COMPUTE_PRECISION_);
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_ITEM:
$product_tax_incl = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_) * $quantity;
$total_products[$id_tax_rules_group] += $product_tax_incl;
break;
case Order::ROUND_LINE:
$product_tax_incl = $product_tax_incl_line;
$total_products[$id_tax_rules_group] += $product_tax_incl;
break;
case Order::ROUND_TOTAL:
$product_tax_incl = $product_tax_incl_line;
$total_products[$id_tax_rules_group . '_' . $id_address] += $price * $quantity;
break;
}
$product['unit_price_tax_' . $inc_or_ex_1] = $price;
$product['unit_price_tax_' . $inc_or_ex_2] = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
$product['total_price_tax_' . $inc_or_ex_1] = Tools::ps_round($price * $quantity, _PS_PRICE_COMPUTE_PRECISION_);
$product['total_price_tax_' . $inc_or_ex_2] = Tools::ps_round($product_tax_incl, _PS_PRICE_COMPUTE_PRECISION_);
$product['product_id'] = $order_detail->product_id;
}
unset($product);
foreach ($total_products as $key => $price) {
if (Configuration::get('PS_ROUND_TYPE') == Order::ROUND_TOTAL) {
$tmp = explode('_', $key);
$address = Address::initialize((int) $tmp[1], true);
$tax_calculator = TaxManagerFactory::getManager($address, $tmp[0])->getTaxCalculator();
$order_slip->{'total_products_tax_' . $inc_or_ex_2} += Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
} else {
$order_slip->{'total_products_tax_' . $inc_or_ex_2} += $price;
}
}
$order_slip->{'total_products_tax_' . $inc_or_ex_2} -= (double) $amount && !$amount_choosen ? (double) $amount : 0;
$order_slip->amount = $amount_choosen ? (double) $amount : $order_slip->{'total_products_tax_' . $inc_or_ex_1};
$order_slip->shipping_cost_amount = $order_slip->{'total_shipping_tax_' . $inc_or_ex_1};
if ((double) $amount && !$amount_choosen) {
$order_slip->order_slip_type = 1;
}
//.........这里部分代码省略.........