本文整理汇总了PHP中OrderInvoice::update方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderInvoice::update方法的具体用法?PHP OrderInvoice::update怎么用?PHP OrderInvoice::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderInvoice
的用法示例。
在下文中一共展示了OrderInvoice::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyDiscountOnInvoice
/**
* @param OrderInvoice $order_invoice
* @param float $value_tax_incl
* @param float $value_tax_excl
*/
protected function applyDiscountOnInvoice($order_invoice, $value_tax_incl, $value_tax_excl)
{
// Update OrderInvoice
$order_invoice->total_discount_tax_incl += $value_tax_incl;
$order_invoice->total_discount_tax_excl += $value_tax_excl;
$order_invoice->total_paid_tax_incl -= $value_tax_incl;
$order_invoice->total_paid_tax_excl -= $value_tax_excl;
$order_invoice->update();
}
示例2: processChangeCarrier
public function processChangeCarrier()
{
$id_order = (int) Tools::getValue('id_o');
$id_new_carrier = (int) Tools::getValue('new_carrier');
$price_incl = (double) Tools::getValue('pr_incl');
$price_excl = (double) Tools::getValue('pr_excl');
$order = new Order($id_order);
$result = array();
$result['error'] = '';
if ($id_new_carrier == 0) {
$result['error'] = $this->l('Error: cannot select carrier');
} else {
if ($order->id < 1) {
$result['error'] = $this->l('Error: cannot find order');
} else {
$total_carrierwt = (double) $order->total_products_wt + (double) $price_incl;
$total_carrier = (double) $order->total_products + (double) $price_excl;
$order->total_paid = (double) $total_carrierwt;
$order->total_paid_tax_incl = (double) $total_carrierwt;
$order->total_paid_tax_excl = (double) $total_carrier;
$order->total_paid_real = (double) $total_carrierwt;
$order->total_shipping = (double) $price_incl;
$order->total_shipping_tax_excl = (double) $price_excl;
$order->total_shipping_tax_incl = (double) $price_incl;
$order->carrier_tax_rate = (double) $order->carrier_tax_rate;
$order->id_carrier = (int) $id_new_carrier;
if (!$order->update()) {
$result['error'] = $this->l('Error: cannot update order');
$result['status'] = false;
} else {
if ($order->invoice_number > 0) {
$order_invoice = new OrderInvoice($order->invoice_number);
$order_invoice->total_paid_tax_incl = (double) $total_carrierwt;
$order_invoice->total_paid_tax_excl = (double) $total_carrier;
$order_invoice->total_shipping_tax_excl = (double) $price_excl;
$order_invoice->total_shipping_tax_incl = (double) $price_incl;
if (!$order_invoice->update()) {
$result['error'] = $this->l('Error: cannot update order invoice');
$result['status'] = false;
}
}
$id_order_carrier = Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `' . _DB_PREFIX_ . 'order_carrier`
WHERE `id_order` = ' . (int) $order->id);
if ($id_order_carrier) {
$order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier->id_carrier = $order->id_carrier;
$order_carrier->shipping_cost_tax_excl = (double) $price_excl;
$order_carrier->shipping_cost_tax_incl = (double) $price_incl;
if (!$order_carrier->update()) {
$result['error'] = $this->l('Error: cannot update order carrier');
$result['status'] = false;
}
}
$result['status'] = true;
}
}
}
if ($result['status']) {
$this->sendCarrierToYandex($order);
}
return $result;
}
示例3: ajaxProcessDeleteProductLine
public function ajaxProcessDeleteProductLine()
{
$res = true;
$order_detail = new OrderDetail(Tools::getValue('id_order_detail'));
$order = new Order(Tools::getValue('id_order'));
$this->doDeleteProductLineValidation($order_detail, $order);
// Update OrderInvoice of this OrderDetail
if ($order_detail->id_order_invoice != 0) {
$order_invoice = new OrderInvoice($order_detail->id_order_invoice);
$order_invoice->total_paid_tax_excl -= $order_detail->total_price_tax_excl;
$order_invoice->total_paid_tax_incl -= $order_detail->total_price_tax_incl;
$order_invoice->total_products -= $order_detail->total_price_tax_excl;
$order_invoice->total_products_wt -= $order_detail->total_price_tax_incl;
$res &= $order_invoice->update();
}
// Update Order
$order->total_paid -= $order_detail->total_price_tax_incl;
$order->total_paid_tax_incl -= $order_detail->total_price_tax_incl;
$order->total_paid_tax_excl -= $order_detail->total_price_tax_excl;
$order->total_products -= $order_detail->total_price_tax_excl;
$order->total_products_wt -= $order_detail->total_price_tax_incl;
$res &= $order->update();
// Delete OrderDetail
$res &= $order_detail->delete();
if (!$res) {
die(Tools::jsonEncode(array('result' => $res, 'error' => Tools::displayError('Error occurred on deletion of this product line'))));
}
// Get invoices collection
$invoice_collection = $order->getInvoicesCollection();
$invoice_array = array();
foreach ($invoice_collection as $invoice) {
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id);
$invoice_array[] = $invoice;
}
// Assign to smarty informations in order to show the new product line
$this->context->smarty->assign(array('order' => $order, 'currency' => new Currency($order->id_currency), 'invoices_collection' => $invoice_collection, 'current_id_lang' => Context::getContext()->language->id, 'link' => Context::getContext()->link, 'current_index' => self::$currentIndex));
$this->sendChangedNotification($order);
die(Tools::jsonEncode(array('result' => $res, 'order' => $order, 'invoices' => $invoice_array, 'documents_html' => $this->createTemplate('_documents.tpl')->fetch(), 'shipping_html' => $this->createTemplate('_shipping.tpl')->fetch())));
}
示例4: ajaxProcessEditProductOnOrder
public function ajaxProcessEditProductOnOrder()
{
// Return value
$res = true;
$order = new Order((int) Tools::getValue('id_order'));
$order_detail = new OrderDetail((int) Tools::getValue('product_id_order_detail'));
if (Tools::isSubmit('product_invoice')) {
$order_invoice = new OrderInvoice((int) Tools::getValue('product_invoice'));
}
// Check fields validity
$this->doEditProductValidation($order_detail, $order, isset($order_invoice) ? $order_invoice : null);
// If multiple product_quantity, the order details concern a product customized
$qty_behavior = PP::qtyBehavior($order_detail, $order_detail->product_quantity) && !is_array(Tools::getValue('product_quantity'));
$product_quantity = 0;
if (is_array(Tools::getValue('product_quantity'))) {
foreach (Tools::getValue('product_quantity') as $id_customization => $qty) {
// Update quantity of each customization
Db::getInstance()->update('customization', array('quantity' => (int) $qty), 'id_customization = ' . (int) $id_customization);
// Calculate the real quantity of the product
$product_quantity += $qty;
}
} else {
$product_quantity = str_replace(',', '.', Tools::getValue('product_quantity'));
}
$product_price_tax_incl = Tools::ps_round(Tools::getValue('product_price_tax_incl'), 2);
$product_price_tax_excl = Tools::ps_round(Tools::getValue('product_price_tax_excl'), 2);
$total_products_tax_incl = PP::calcPrice($product_price_tax_incl, $qty_behavior ? $order_detail->product_quantity : $product_quantity, $qty_behavior ? $product_quantity : $order_detail->product_quantity_fractional, $order_detail->product_id);
$total_products_tax_excl = PP::calcPrice($product_price_tax_excl, $qty_behavior ? $order_detail->product_quantity : $product_quantity, $qty_behavior ? $product_quantity : $order_detail->product_quantity_fractional, $order_detail->product_id);
// Calculate differences of price (Before / After)
$diff_price_tax_incl = $total_products_tax_incl - $order_detail->total_price_tax_incl;
$diff_price_tax_excl = $total_products_tax_excl - $order_detail->total_price_tax_excl;
$ppropertiessmartprice_hook1 = null;
// Apply change on OrderInvoice
if (isset($order_invoice)) {
// If OrderInvoice to use is different, we update the old invoice and new invoice
if ($order_detail->id_order_invoice != $order_invoice->id) {
$old_order_invoice = new OrderInvoice($order_detail->id_order_invoice);
// We remove cost of products
$old_order_invoice->total_products -= $order_detail->total_price_tax_excl;
$old_order_invoice->total_products_wt -= $order_detail->total_price_tax_incl;
$old_order_invoice->total_paid_tax_excl -= $order_detail->total_price_tax_excl;
$old_order_invoice->total_paid_tax_incl -= $order_detail->total_price_tax_incl;
$res &= $old_order_invoice->update();
$order_invoice->total_products += $order_detail->total_price_tax_excl;
$order_invoice->total_products_wt += $order_detail->total_price_tax_incl;
$order_invoice->total_paid_tax_excl += $order_detail->total_price_tax_excl;
$order_invoice->total_paid_tax_incl += $order_detail->total_price_tax_incl;
$order_detail->id_order_invoice = $order_invoice->id;
}
}
if ($diff_price_tax_incl != 0 && $diff_price_tax_excl != 0) {
$order_detail->unit_price_tax_excl = $product_price_tax_excl;
$order_detail->unit_price_tax_incl = $product_price_tax_incl;
$order_detail->total_price_tax_incl += $diff_price_tax_incl;
$order_detail->total_price_tax_excl += $diff_price_tax_excl;
if (isset($order_invoice)) {
// Apply changes on OrderInvoice
$order_invoice->total_products += $diff_price_tax_excl;
$order_invoice->total_products_wt += $diff_price_tax_incl;
$order_invoice->total_paid_tax_excl += $diff_price_tax_excl;
$order_invoice->total_paid_tax_incl += $diff_price_tax_incl;
}
// Apply changes on Order
$order = new Order($order_detail->id_order);
$order->total_products += $diff_price_tax_excl;
$order->total_products_wt += $diff_price_tax_incl;
$order->total_paid += $diff_price_tax_incl;
$order->total_paid_tax_excl += $diff_price_tax_excl;
$order->total_paid_tax_incl += $diff_price_tax_incl;
$res &= $order->update();
}
$old_quantity = PP::resolveQty($order_detail->product_quantity, $order_detail->product_quantity_fractional);
if ($qty_behavior) {
$order_detail->product_quantity_fractional = $product_quantity;
} else {
$order_detail->product_quantity = $product_quantity;
}
// update taxes
$res &= $order_detail->updateTaxAmount($order);
// Save order detail
$res &= $order_detail->update();
// Update weight SUM
$order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier)) {
$order_carrier->weight = (double) $order->getTotalWeight();
$res &= $order_carrier->update();
if ($res) {
$order->weight = sprintf('%.3f ' . Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
}
// Save order invoice
if (isset($order_invoice)) {
$res &= $order_invoice->update();
}
// Update product available quantity
StockAvailable::updateQuantity($order_detail->product_id, $order_detail->product_attribute_id, $old_quantity - PP::resolveQty($order_detail->product_quantity, $order_detail->product_quantity_fractional), $order->id_shop);
$products = $this->getProducts($order);
// Get the last product
$product = $products[$order_detail->id];
$resume = OrderSlip::getProductSlipResume($order_detail->id);
//.........这里部分代码省略.........