本文整理汇总了PHP中OrderCarrier类的典型用法代码示例。如果您正苦于以下问题:PHP OrderCarrier类的具体用法?PHP OrderCarrier怎么用?PHP OrderCarrier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OrderCarrier类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_cart_by_junglee_xml
//.........这里部分代码省略.........
`total_products` = ' . $total_principal . ',
`total_products_wt` = ' . $total_principal . ',
`invoice_date` = "0000-00-00 00:00:00",
`delivery_date` = "0000-00-00 00:00:00"
where `id_order` = ' . $order_id . ' ';
//`round_mode` = '.Configuration::get('PS_PRICE_ROUND_MODE').',
/*`total_wrapping_tax_incl` = '.$WrappingAmount.',
`total_wrapping_tax_excl` = '.$WrappingAmount.',
`total_wrapping` = '.$WrappingAmount.',*/
Db::getInstance()->Execute($sql);
$acknowledge_arr = array();
$i = 0;
foreach ($xml->ProcessedOrder->ProcessedOrderItems->ProcessedOrderItem as $item) {
$product_id = (string) $item->SKU;
$product = new Product((int) $product_id);
$SKU = $product->reference;
$AmazonOrderItemCode = (string) $item->AmazonOrderItemCode;
$Title = (string) $item->Title;
$Amount = (double) $item->Price->Amount;
$acknowledge_arr['items'][$i]['AmazonOrderItemCode'] = $AmazonOrderItemCode;
$acknowledge_arr['items'][$i]['product_id'] = $product_id;
$CurrencyCode = (string) $item->Price->CurrencyCode;
$Quantity = (int) $item->Quantity;
$other_promo = 0;
foreach ($item->ItemCharges->Component as $amount_type) {
$item_charge_type = (string) $amount_type->Type;
if ($item_charge_type == 'Principal') {
$principal = (string) $amount_type->Charge->Amount;
}
if ($item_charge_type == 'Shipping') {
$Shipping = (string) $amount_type->Charge->Amount;
}
if ($item_charge_type == 'PrincipalPromo') {
$principal_promo = (string) $amount_type->Charge->Amount;
}
if ($item_charge_type == 'ShippingPromo') {
$shipping_promo = (string) $amount_type->Charge->Amount;
}
if ($item_charge_type == 'OtherPromo') {
$other_promo = (string) $amount_type->Charge->Amount;
}
}
$sql = 'INSERT into `' . $prefix . 'order_detail` set
`id_order` = ' . $order_id . ',
`product_id` = ' . $product_id . ',
`product_name` = "' . $Title . '",
`product_quantity` = ' . $Quantity . ',
`product_quantity_in_stock` = ' . $Quantity . ',
`product_price` = ' . $Amount . ',
`product_reference` = "' . $SKU . '",
`total_price_tax_incl` = ' . $Amount * $Quantity . ',
`total_price_tax_excl` = ' . $Amount * $Quantity . ',
`unit_price_tax_incl` = ' . $Amount . ',
`unit_price_tax_excl` = ' . $Amount . ',
`original_product_price` = ' . $Amount . '
';
Db::getInstance()->Execute($sql);
$sql = 'UPDATE `' . $prefix . 'stock_available` set
`quantity` = `quantity` - ' . $Quantity . '
where `id_product` = ' . $product_id . ' and
`id_product_attribute` = 0
';
Db::getInstance()->Execute($sql);
$date = date('Y-m-d');
$sql = 'UPDATE `' . $prefix . 'product_sale` set
`quantity` = `quantity` + ' . $Quantity . ',
`sale_nbr` = `sale_nbr` + ' . $Quantity . ',
`date_upd` = ' . $date . '
where `id_product` = ' . $product_id . '
';
Db::getInstance()->Execute($sql);
$i++;
}
// Adding an entry in order_carrier table
if (!is_null($carrier)) {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = '0';
$order_carrier->shipping_cost_tax_excl = (double) $shipping_amount;
$order_carrier->shipping_cost_tax_incl = (double) $shipping_amount;
$order_carrier->add();
} else {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = '0';
$order_carrier->shipping_cost_tax_excl = (double) $shipping_amount;
$order_carrier->shipping_cost_tax_incl = (double) $shipping_amount;
$order_carrier->add();
}
// Set the order status
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$history->changeIdOrderState((int) $id_order_state, $order->id, true);
$history->addWithemail(true, array());
$acknowledge_arr['MerchantOrderID'] = (int) $order->id;
}
示例2: setWsShippingNumber
public function setWsShippingNumber($shipping_number)
{
$id_order_carrier = Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `' . _DB_PREFIX_ . 'order_carrier`
WHERE `id_order` = ' . (int) $this->id);
if ($id_order_carrier) {
$order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier->tracking_number = $shipping_number;
$order_carrier->update();
} else {
$this->shipping_number = $shipping_number;
}
return true;
}
示例3: hookNewOrder
public function hookNewOrder($params)
{
$current_email = $this->context->customer->email;
// Get value.
$send24_consumer_key = Configuration::get('send24_consumer_key');
$send24_consumer_secret = Configuration::get('send24_consumer_secret');
// Get shipping value.
$address = new Address($this->context->cart->id_address_delivery);
$select_country = $this->express;
// get/check Express.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://send24.com/wc-api/v3/get_products");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERPWD, $send24_consumer_key . ":" . $send24_consumer_secret);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$send24_countries = Tools::jsonDecode(curl_exec($ch));
curl_close($ch);
$n = count($send24_countries);
for ($i = 0; $i < $n; $i++) {
if ($send24_countries[$i]->title == $select_country) {
$send24_product_id = $send24_countries[$i]->product_id;
$i = $n;
$is_available = true;
} else {
$is_available = false;
}
}
if ($is_available == true) {
$insurance_price = 0;
$discount = "false";
$ship_total = $type = $price_need = '';
if ($select_country == $this->express) {
$select_country = 'Danmark';
$where_shop_id = 'ekspres';
}
// Create order.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://send24.com/wc-api/v3/create_order");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, $send24_consumer_key . ":" . $send24_consumer_secret);
curl_setopt($ch, CURLOPT_POSTFIELDS, '
{
"TO_company": "' . $address->company . '",
"TO_first_name": "' . $address->firstname . '",
"TO_last_name": "' . $address->lastname . '",
"TO_phone": "' . $address->phone . '",
"TO_email": "' . $current_email . '",
"TO_country": "' . $select_country . '",
"TO_city": "' . $address->city . '",
"TO_postcode": "' . $address->postcode . '",
"Insurance" : "' . $insurance_price . '",
"Weight": "5",
"TO_address": "' . $address->address1 . '",
"WHAT_product_id": "' . $send24_product_id . '",
"WHERE_shop_id": "' . $where_shop_id . '",
"discount": "' . $discount . '",
"type": "' . $type . '",
"need_points": "' . $price_need . '",
"total": "' . $ship_total . '",
"ship_mail": "' . $current_email . '",
"bill_mail": "' . $current_email . '"
}
');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$response = curl_exec($ch);
$response_order = Tools::jsonDecode($response, JSON_FORCE_OBJECT);
if (!empty($response_order)) {
$tracking_number = explode('?', $response_order['track']);
$objOrder = $params['order'];
$history = new OrderHistory();
$history->id_order = (int) $objOrder->id;
$order_carrier = new OrderCarrier($history->id_order);
$order_carrier->tracking_number = $tracking_number['1'];
Db::getInstance()->insert('send24order_value', array('id_order' => (int) $history->id_order, 'order_number' => $response_order['order_number'], 'link_to_pdf' => $response_order['link_to_pdf'], 'link_to_doc' => $response_order['link_to_doc'], 'link_to_zpl' => $response_order['link_to_zpl'], 'link_to_epl' => $response_order['link_to_epl'], 'track' => $response_order['track'], 'date_add' => date('Y-m-d H:i:s')));
$order_carrier->update();
}
// Delete Carriers.
// self::deleteCarriers();
foreach ($this->carriers as $value) {
$carriers = new Carrier((int) Configuration::get(self::PREFIX . $value));
$carriers->delay = array('1' => '(viser leveringstid i dag)');
$carriers->deleted = 0;
$carriers->update();
}
curl_close($ch);
}
return true;
}
示例4: validateOrder
//.........这里部分代码省略.........
$order->total_wrapping_tax_incl = (double) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping = $order->total_wrapping_tax_incl;
$order->total_paid_tax_excl = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid = $order->total_paid_tax_incl;
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
// Creating order
$result = $order->add();
if (!$result) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t save Order');
}
// Amount paid by customer is not the right one -> Status = payment error
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
// if ($order->total_paid != $order->total_paid_real)
// We use number_format in order to compare two string
if ($order_status->logable && number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
$id_order_state = Configuration::get('PS_OS_ERROR');
}
$order_list[] = $order;
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
// Insert new Order detail list using cart for the current order
$order_detail = new OrderDetail(null, null, $this->context);
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
$order_detail_list[] = $order_detail;
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
// Adding an entry in order_carrier table
if (!is_null($carrier)) {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = (double) $order->getTotalWeight();
$order_carrier->shipping_cost_tax_excl = (double) $order->total_shipping_tax_excl;
$order_carrier->shipping_cost_tax_incl = (double) $order->total_shipping_tax_incl;
$order_carrier->add();
}
}
}
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$this->context->country = $context_country;
}
if (!$this->context->country->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('The order address country is not active.');
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
// Register Payment only if the order status validate the order
if ($order_status->logable) {
// $order is the last order loop in the foreach
// The method addOrderPayment of the class Order make a create a paymentOrder
// linked to the order reference and not to the order id
if (isset($extra_vars['transaction_id'])) {
$transaction_id = $extra_vars['transaction_id'];
} else {
示例5: renderList
//.........这里部分代码省略.........
$this->confirmations[] = ' <a target="_blank" href="' . $pdf_link . '" alt="invoices">' . $this->l('Download all invoices') . '</br></a>';
}
if ($delivery != '') {
$pdf_link = new Link();
$pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateDeliverySlipsPDF2&id_orders=' . Tools::substr($delivery, 0, -1);
$this->confirmations[] = ' <a target="_blank" href="' . $pdf_link . '" alt="delivery">' . $this->l('Download all delivery slip') . '</br></a>';
}
if ($invoices == '' && $delivery == '') {
$this->errors[] = $this->l('The selected orders have no invoice or delivery !') . '<br/>';
}
}
}
if (Tools::getValue('etiquettesMR') != '') {
// Downlad all pdf and zip then delete and display link to zip file
$etiquettesMR = explode(' ', Tools::getValue('etiquettesMR'));
unset($etiquettesMR[count($etiquettesMR) - 1]);
$zipPath = '../modules/erpillicopresta/export/mondialrelay.zip';
$zip = new ZipArchive();
if ($zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
throw new Exception($this->l('Impossible to create the zip archive containing the shipping labels to Mondial Relay carrier !') . '<br/>');
}
foreach ($etiquettesMR as $key => $i) {
$zip->addFromString('mondialrelay_' . $key . '.pdf', Tools::file_get_contents($i));
}
$zip->close();
//Display link to dl zip file
$this->confirmations[] = ' <a target="_blank" href="' . $zipPath . '" alt="zip_file">' . $this->l('Download zip archive which contents all labels for Mondial Relay shipment') . '<br/></a>';
if (Tools::getValue('deliveryNumbersMR') != '') {
// Get all tracking numbers
$numbers = explode(" ", Tools::getValue('deliveryNumbersMR'));
unset($numbers[count($numbers) - 1]);
foreach ($numbers as $number) {
$tabNumber = explode("-", $number);
$order_carrier = new OrderCarrier(ErpOrder::getIdCarrierbyIdOrder((int) $tabNumber[1]));
$order = new ErpOrder((int) $tabNumber[1]);
// Update carrier
$order->shipping_number = $tabNumber[0];
$order->update();
// Update order_carrier
$order_carrier->tracking_number = pSQL($tabNumber[0]);
$order_carrier->update();
}
}
}
if (Tools::getValue('expeditorCSV') != '') {
// CSV file creation
$csvPath = '../modules/erpillicopresta/export/expeditor_inet.csv';
$fileCSV = fopen($csvPath, 'w');
// Fill in file
fwrite($fileCSV, str_replace(',', '', Tools::getValue('expeditorCSV')));
//Close
fclose($fileCSV);
// link creation
$this->confirmations[] = ' <a target="_blank" href="' . $csvPath . '" alt="csv_file">' . $this->l('Download export file (CSV) for ExpeditorInet') . '</br></a>';
}
if (Tools::getValue('idOthers') != '') {
//BEGIN Initialisations for TNT
if (Module::isEnabled('tntcarrier')) {
$TNTCheck = false;
require_once _PS_MODULE_DIR_ . '/tntcarrier/classes/PackageTnt.php';
if (class_exists('ZipArchive', false) && ($tnt_zip = new ZipArchive())) {
// Protection du ZIP
$dateday = new DateTime();
$uniqid_file = uniqid('file_');
$token = md5($dateday->getTimestamp() . $uniqid_file);
// Put all tnt pdf into a zip
示例6: setInvoice
/**
* This method allows to generate first invoice of the current order
*/
public function setInvoice($use_existing_payment = false)
{
if (Configuration::get('PS_INVOICE') && !$this->hasInvoice()) {
if ($id = (int) $this->hasDelivery()) {
$order_invoice = new OrderInvoice($id);
} else {
$order_invoice = new OrderInvoice();
}
$order_invoice->id_order = $this->id;
if (!$id) {
$order_invoice->number = 0;
}
$address = new Address((int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$carrier = new Carrier((int) $this->id_carrier);
$tax_calculator = $carrier->getTaxCalculator($address);
$order_invoice->total_discount_tax_excl = $this->total_discounts_tax_excl;
$order_invoice->total_discount_tax_incl = $this->total_discounts_tax_incl;
$order_invoice->total_paid_tax_excl = $this->total_paid_tax_excl;
$order_invoice->total_paid_tax_incl = $this->total_paid_tax_incl;
$order_invoice->total_products = $this->total_products;
$order_invoice->total_products_wt = $this->total_products_wt;
$order_invoice->total_shipping_tax_excl = $this->total_shipping_tax_excl;
$order_invoice->total_shipping_tax_incl = $this->total_shipping_tax_incl;
$order_invoice->shipping_tax_computation_method = $tax_calculator->computation_method;
$order_invoice->total_wrapping_tax_excl = $this->total_wrapping_tax_excl;
$order_invoice->total_wrapping_tax_incl = $this->total_wrapping_tax_incl;
// Save Order invoice
$order_invoice->save();
$this->setLastInvoiceNumber($order_invoice->id, $this->id_shop);
$order_invoice->saveCarrierTaxCalculator($tax_calculator->getTaxesAmount($order_invoice->total_shipping_tax_excl));
// Update order_carrier
$id_order_carrier = Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `' . _DB_PREFIX_ . 'order_carrier`
WHERE `id_order` = ' . (int) $order_invoice->id_order . '
AND (`id_order_invoice` IS NULL OR `id_order_invoice` = 0)');
if ($id_order_carrier) {
$order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier->id_order_invoice = (int) $order_invoice->id;
$order_carrier->update();
}
// Update order detail
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_detail`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Update order payment
if ($use_existing_payment) {
$id_order_payments = Db::getInstance()->executeS('
SELECT DISTINCT op.id_order_payment
FROM `' . _DB_PREFIX_ . 'order_payment` op
INNER JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.reference = op.order_reference)
LEFT JOIN `' . _DB_PREFIX_ . 'order_invoice_payment` oip ON (oip.id_order_payment = op.id_order_payment)
WHERE (oip.id_order != ' . (int) $order_invoice->id_order . ' OR oip.id_order IS NULL) AND o.id_order = ' . (int) $order_invoice->id_order);
if (count($id_order_payments)) {
foreach ($id_order_payments as $order_payment) {
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment`
SET
`id_order_invoice` = ' . (int) $order_invoice->id . ',
`id_order_payment` = ' . (int) $order_payment['id_order_payment'] . ',
`id_order` = ' . (int) $order_invoice->id_order);
}
// Clear cache
Cache::clean('order_invoice_paid_*');
}
}
// Update order cart rule
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_cart_rule`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Keep it for backward compatibility, to remove on 1.6 version
$this->invoice_date = $order_invoice->date_add;
$this->invoice_number = $this->getInvoiceNumber($order_invoice->id);
$this->update();
}
}
示例7: 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;
}
示例8: updateOrder
private function updateOrder($id_address, $id_method, Order &$order)
{
$id_carrier = $this->getIdcarrierFromIdMethod($id_method);
if ($id_carrier && Validate::isLoadedObject(new Carrier($id_carrier))) {
if ($order->id_address_delivery != $id_address || $order->id_carrier != $id_carrier || $order->shipping_number != $this->id_shipment) {
$order->id_address_delivery = (int) $id_address;
$order->id_carrier = (int) $id_carrier;
if (version_compare(_PS_VERSION_, '1.5', '>=') && ($id_order_carrier = (int) $order->getIdOrderCarrier())) {
$order_carrier = new OrderCarrier((int) $id_order_carrier);
$order_carrier->id_carrier = $order->id_carrier;
$order_carrier->update();
}
if (!$order->update()) {
self::$errors[] = $this->l('Order could not be updated');
return false;
}
}
return true;
} else {
self::$errors[] = $this->l('Carrier does not exists. Order could not be updated.');
return false;
}
}
示例9: validateOrder
//.........这里部分代码省略.........
$order->total_shipping_tax_excl = (double) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list);
$order->total_shipping_tax_incl = (double) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list);
$order->total_shipping = $order->total_shipping_tax_incl;
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
}
$order->total_wrapping_tax_excl = (double) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping_tax_incl = (double) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping = $order->total_wrapping_tax_incl;
$order->total_paid_tax_excl = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), 2);
$order->total_paid_tax_incl = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), 2);
$order->total_paid = $order->total_paid_tax_incl;
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
// Creating order
$result = $order->add();
if (!$result) {
throw new PrestaShopException('Can\'t save Order');
}
// Amount paid by customer is not the right one -> Status = payment error
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
// if ($order->total_paid != $order->total_paid_real)
// We use number_format in order to compare two string
if ($order_status->logable && number_format($cart_total_paid, 2) != number_format($amount_paid, 2)) {
$id_order_state = Configuration::get('PS_OS_ERROR');
}
$order_list[] = $order;
// Insert new Order detail list using cart for the current order
$order_detail = new OrderDetail(null, null, $this->context);
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
$order_detail_list[] = $order_detail;
// Adding an entry in order_carrier table
if (!is_null($carrier)) {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = (double) $order->getTotalWeight();
$order_carrier->shipping_cost_tax_excl = (double) $order->total_shipping_tax_excl;
$order_carrier->shipping_cost_tax_incl = (double) $order->total_shipping_tax_incl;
$order_carrier->add();
}
}
}
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$this->context->country = $context_country;
}
// Register Payment only if the order status validate the order
if ($order_status->logable) {
// $order is the last order loop in the foreach
// The method addOrderPayment of the class Order make a create a paymentOrder
// linked to the order reference and not to the order id
if (isset($extra_vars['transaction_id'])) {
$transaction_id = $extra_vars['transaction_id'];
} else {
$transaction_id = null;
}
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
throw new PrestaShopException('Can\'t save Order Payment');
}
}
// Next !
$only_one_gift = false;
$cart_rule_used = array();
$products = $this->context->cart->getProducts();
$cart_rules = $this->context->cart->getCartRules();
示例10: setInvoice
/**
* This method allows to generate first invoice of the current order
*/
public function setInvoice($use_existing_payment = false)
{
if (!$this->hasInvoice()) {
$order_invoice = new OrderInvoice();
$order_invoice->id_order = $this->id;
$order_invoice->number = Configuration::get('PS_INVOICE_START_NUMBER');
// If invoice start number has been set, you clean the value of this configuration
if ($order_invoice->number) {
Configuration::updateValue('PS_INVOICE_START_NUMBER', false);
} else {
$order_invoice->number = Order::getLastInvoiceNumber() + 1;
}
$invoice_address = new Address((int) $this->id_address_invoice);
$carrier = new Carrier((int) $this->id_carrier);
$tax_calculator = $carrier->getTaxCalculator($invoice_address);
$order_invoice->total_discount_tax_excl = $this->total_discounts_tax_excl;
$order_invoice->total_discount_tax_incl = $this->total_discounts_tax_incl;
$order_invoice->total_paid_tax_excl = $this->total_paid_tax_excl;
$order_invoice->total_paid_tax_incl = $this->total_paid_tax_incl;
$order_invoice->total_products = $this->total_products;
$order_invoice->total_products_wt = $this->total_products_wt;
$order_invoice->total_shipping_tax_excl = $this->total_shipping_tax_excl;
$order_invoice->total_shipping_tax_incl = $this->total_shipping_tax_incl;
$order_invoice->shipping_tax_computation_method = $tax_calculator->computation_method;
$order_invoice->total_wrapping_tax_excl = $this->total_wrapping_tax_excl;
$order_invoice->total_wrapping_tax_incl = $this->total_wrapping_tax_incl;
// Save Order invoice
$order_invoice->add();
$order_invoice->saveCarrierTaxCalculator($tax_calculator->getTaxesAmount($order_invoice->total_shipping_tax_excl));
// Update order_carrier
$id_order_carrier = Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `' . _DB_PREFIX_ . 'order_carrier`
WHERE `id_order` = ' . (int) $order_invoice->id_order . '
AND (`id_order_invoice` IS NULL OR `id_order_invoice` = 0)');
if ($id_order_carrier) {
$order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier->id_order_invoice = (int) $order_invoice->id;
$order_carrier->update();
}
// Update order detail
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_detail`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Update order payment
if ($use_existing_payment) {
$id_order_payments = Db::getInstance()->executeS('
SELECT op.id_order_payment
FROM `' . _DB_PREFIX_ . 'order_payment` op
INNER JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.reference = op.order_reference)
LEFT JOIN `' . _DB_PREFIX_ . 'order_invoice_payment` oip ON (oip.id_order_payment = op.id_order_payment)
WHERE oip.id_order_payment IS NULL AND o.id_order = ' . (int) $order_invoice->id_order);
if (count($id_order_payments)) {
foreach ($id_order_payments as $order_payment) {
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment`
SET
`id_order_invoice` = ' . (int) $order_invoice->id . ',
`id_order_payment` = ' . (int) $order_payment['id_order_payment'] . ',
`id_order` = ' . (int) $order_invoice->id_order);
}
}
}
// Update order cart rule
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'order_cart_rule`
SET `id_order_invoice` = ' . (int) $order_invoice->id . '
WHERE `id_order` = ' . (int) $order_invoice->id_order);
// Keep it for backward compatibility, to remove on 1.6 version
$this->invoice_date = $order_invoice->date_add;
$this->invoice_number = $order_invoice->number;
$this->update();
}
}
示例11: cronOrdersSync
function cronOrdersSync()
{
$orders = $this->client->getOrders(array(7));
foreach ($orders as $order) {
$channelOrderId = $order->getId();
$billingAddress = $order->getBillingAddress();
$shippingAddress = $order->getShippingAddress();
if (empty($billingAddress)) {
continue;
}
$id_customer = $this->createPrestashopCustomer($billingAddress, $order->getEmail());
$lines = $order->getLines();
$AddressObject = new Address();
$AddressObject->id_customer = $id_customer;
$AddressObject->firstname = $billingAddress->getfirstName();
$AddressObject->lastname = $billingAddress->getlastName();
$AddressObject->address1 = " " . $billingAddress->getHouseNr();
$AddressObject->address1 .= " " . $billingAddress->getHouseNrAddition();
$AddressObject->address1 .= " " . $billingAddress->getStreetName();
$AddressObject->address1 .= " " . $billingAddress->getZipCode();
$AddressObject->address1 .= " " . $billingAddress->getCity();
$AddressObject->city = $billingAddress->getCity();
$AddressObject->id_customer = $id_customer;
$AddressObject->id_country = Country::getByIso($billingAddress->getCountryIso());
$AddressObject->alias = $billingAddress->getcompanyName() != "" ? "Company" : "Home";
$AddressObject->add();
$CarrierObject = new Carrier();
$CarrierObject->delay[1] = "2-4";
$CarrierObject->active = 1;
$CarrierObject->name = "ChannelEngine Order";
$CarrierObject->add();
$id_carrier = $CarrierObject->id;
$currency_object = new Currency();
$default_currency_object = $currency_object->getDefaultCurrency();
$id_currency = $default_currency_object->id;
$id_address = $AddressObject->id;
// Create Cart Object
$cart = new Cart();
$cart->id_customer = (int) $id_customer;
$cart->id_address_delivery = $id_address;
$cart->id_address_invoice = $id_address;
$cart->id_lang = 1;
$cart->id_currency = (int) $id_address;
$cart->id_carrier = $id_carrier;
$cart->recyclable = 0;
$cart->id_shop_group = 1;
$cart->gift = 0;
$cart->add();
if (!empty($lines)) {
foreach ($lines as $item) {
$quantity = $item->getQuantity();
if (strpos($item->getmerchantProductNo(), '-') !== false) {
$getMerchantProductNo = explode("-", $item->getMerchantProductNo());
$cart->updateQty($quantity, $getMerchantProductNo[0], $getMerchantProductNo[1]);
} else {
$cart->updateQty($quantity, $item->getmerchantProductNo());
}
}
}
$cart->update();
$order_object = new Order();
$order_object->id_address_delivery = $id_address;
$order_object->id_address_invoice = $id_address;
$order_object->id_cart = $cart->id;
$order_object->id_currency = $id_currency;
$order_object->id_customer = $id_customer;
$order_object->id_carrier = $id_carrier;
$order_object->payment = "ChannelEngine Order";
$order_object->module = "1";
$order_object->valid = 1;
$order_object->total_paid_tax_excl = $order->getTotalInclVat();
$order_object->total_discounts_tax_incl = 0;
$order_object->total_paid = $order->getTotalInclVat();
$order_object->total_paid_real = $order->getTotalInclVat();
$order_object->total_products = $order->getSubTotalInclVat() - $order->getSubTotalVat();
$order_object->total_products_wt = $order->getSubTotalInclVat();
$order_object->total_paid_tax_incl = $order->getSubTotalInclVat();
$order_object->conversion_rate = 1;
$order_object->id_shop = 1;
$order_object->id_lang = 1;
$order_object->id_shop_group = 1;
$order_object->secure_key = md5(uniqid(rand(), true));
$order_id = $order_object->add();
// Insert new Order detail list using cart for the current order
$order_detail = new OrderDetail();
$orderClass = new Order();
$order_detail->createList($order_object, $cart, 1, $cart->getProducts(), 1);
$order_detail_list[] = $order_detail;
// Adding an entry in order_carrier table
if (!is_null($CarrierObject)) {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order_object->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = (double) $order_object->getTotalWeight();
$order_carrier->shipping_cost_tax_excl = (double) $order_object->total_shipping_tax_excl;
$order_carrier->shipping_cost_tax_incl = (double) $order_object->total_shipping_tax_incl;
$order_carrier->add();
}
foreach ($lines as $item) {
$getMerchantProductNo = explode("-", $item->getMerchantProductNo());
//.........这里部分代码省略.........
示例12: trackingStatus
public static function trackingStatus($id_order, $shipping_number)
{
// MAIL::SEND is bugged in 1.5 !
// http://forge.prestashop.com/browse/PNM-754 (Unresolved as of 2013-04-15)
// Context fix (it's that easy)
Context::getContext()->link = new Link();
// Fix context by adding employee
$cookie = new Cookie('psAdmin');
Context::getContext()->employee = new Employee($cookie->id_employee);
$o = new Order($id_order);
$o->shipping_number = $shipping_number;
$o->save();
// New in 1.5
$id_order_carrier = Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `' . _DB_PREFIX_ . 'order_carrier`
WHERE `id_order` = ' . (int) $id_order);
$order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier->tracking_number = $shipping_number;
$order_carrier->id_order = $id_order;
$order_carrier->id_carrier = $o->id_carrier;
$order_carrier->update();
// No, there is no method in Order to retrieve the orderCarrier object(s)
$history = new OrderHistory();
$history->id_order = (int) $o->id;
$history->id_order_state = _PS_OS_SHIPPING_;
$history->changeIdOrderState(_PS_OS_SHIPPING_);
$history->save();
$customer = new Customer($o->id_customer);
$carrier = new Carrier($o->id_carrier);
$tracking_url = str_replace('@', $o->shipping_number, $carrier->url);
$templateVars = array('{tracking_link}' => '<a href = "' . $tracking_url . '">' . $o->shipping_number . '</a>', '{tracking_code}' => $o->shipping_number, '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{id_order}' => (int) $o->id);
Mail::Send($o->id_lang, 'tracking', 'Tracking number for your order', $templateVars, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _MYDIR_ . '/mails/', true);
}
示例13: update_cart_by_junglee_xml
//.........这里部分代码省略.........
`total_paid_real` = 0,
`total_shipping` = ' . $shipping_amount . ',
`total_shipping_tax_incl` = ' . $shipping_amount . ',
`total_shipping_tax_excl` = ' . $shipping_amount . ',
`total_discounts` = ' . (double) $total_promo . ',
`total_discounts_tax_incl` = ' . (double) $total_promo . ',
`total_discounts_tax_excl` = ' . (double) $total_promo . ',
`total_products` = ' . $total_principal . ',
`total_products_wt` = ' . $total_principal . ',
`invoice_date` = "0000-00-00 00:00:00",
`delivery_date` = "0000-00-00 00:00:00"
where `id_order` = ' . $order_id . '';
// `round_mode` = '.Configuration::get('PS_PRICE_ROUND_MODE').',
Db::getInstance()->Execute($sql);
$i = 0;
foreach ($orderdetail->OrderReport->Item as $item) {
$id_product = (string) $item->SKU;
$product = new Product((int) $product_id);
$SKU = $product->reference;
$AmazonOrderItemCode = (string) $item->AmazonOrderItemCode;
$Title = (string) $item->Title;
$Quantity = (int) $item->Quantity;
foreach ($item->ItemPrice->Component as $amount_type) {
$item_charge_type = (string) $amount_type->Type;
if ($item_charge_type == 'Principal') {
$Amount = (double) $amount_type->Amount;
}
}
$Amount = $Amount / $Quantity;
$Amount = round($Amount, 3);
$acknowledge_arr['items'][$i]['AmazonOrderItemCode'] = $AmazonOrderItemCode;
$acknowledge_arr['items'][$i]['product_id'] = $id_product;
$i++;
$sql = 'INSERT into `' . $prefix . 'order_detail` set
`id_order` = ' . $order_id . ',
`product_id` = ' . $id_product . ',
`product_name` = "' . $Title . '",
`product_quantity` = ' . $Quantity . ',
`product_quantity_in_stock` = ' . $Quantity . ',
`product_price` = ' . $Amount . ',
`product_reference` = "' . $SKU . '",
`total_price_tax_incl` = ' . $Amount * $Quantity . ',
`total_price_tax_excl` = ' . $Amount * $Quantity . ',
`unit_price_tax_incl` = ' . $Amount . ',
`unit_price_tax_excl` = ' . $Amount . ',
`original_product_price` = ' . $Amount . '
';
Db::getInstance()->Execute($sql);
$sql = 'UPDATE `' . $prefix . 'stock_available` set
`quantity` = `quantity` - ' . $Quantity . '
where `id_product` = ' . $id_product . ' and
`id_product_attribute` = 0
';
Db::getInstance()->Execute($sql);
/*$sql = 'UPDATE `'.$prefix.'stock_available` set
`quantity` = `quantity` - '.$Quantity.'
where `id_product` = '.$product_id.' and
`id_product_attribute` = '.$product_attribute_id.'
';
Db::getInstance()->Execute($sql);*/
$date = date('Y-m-d');
$sql = 'UPDATE `' . $prefix . 'product_sale` set
`quantity` = `quantity` + ' . $Quantity . ',
`sale_nbr` = `sale_nbr` + ' . $Quantity . ',
`date_upd` = ' . $date . '
where `id_product` = ' . $id_product . '
';
Db::getInstance()->Execute($sql);
}
// Adding an entry in order_carrier table
if (!is_null($carrier)) {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = '0';
$order_carrier->shipping_cost_tax_excl = (double) $shipping_amount;
$order_carrier->shipping_cost_tax_incl = (double) $shipping_amount;
$order_carrier->add();
} else {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = '0';
$order_carrier->shipping_cost_tax_excl = (double) $shipping_amount;
$order_carrier->shipping_cost_tax_incl = (double) $shipping_amount;
$order_carrier->add();
}
// Acknowledge the order in seller central using MWS FEED API
$acknowledge_arr['MerchantOrderID'] = (int) $order->id;
$obj = new Pwapresta();
$obj->pwa_acknowledge_feed($acknowledge_arr);
$history = new OrderHistory();
$history->id_order = $order->id;
$history->changeIdOrderState((int) $id_order_state, $order->id, true);
$history->addWithemail(true, array());
}
示例14: refreshShippingCost
/**
* Re calculate shipping cost
* @return object $order
*/
public function refreshShippingCost()
{
if (empty($this->id)) {
return false;
}
if (!Configuration::get('PS_ORDER_RECALCULATE_SHIPPING')) {
return $this;
}
$fake_cart = new Cart((int) $this->id_cart);
$new_cart = $fake_cart->duplicate();
$new_cart = $new_cart['cart'];
// assign order id_address_delivery to cart
$new_cart->id_address_delivery = (int) $this->id_address_delivery;
// assign id_carrier
$new_cart->id_carrier = (int) $this->id_carrier;
//remove all products : cart (maybe change in the meantime)
foreach ($new_cart->getProducts() as $product) {
$new_cart->deleteProduct((int) $product['id_product'], (int) $product['id_product_attribute']);
}
// add real order products
foreach ($this->getProducts() as $product) {
$new_cart->updateQty($product['product_quantity'], (int) $product['product_id']);
}
// get new shipping cost
$base_total_shipping_tax_incl = (double) $new_cart->getPackageShippingCost((int) $new_cart->id_carrier, true, null);
$base_total_shipping_tax_excl = (double) $new_cart->getPackageShippingCost((int) $new_cart->id_carrier, false, null);
// calculate diff price, then apply new order totals
$diff_shipping_tax_incl = $this->total_shipping_tax_incl - $base_total_shipping_tax_incl;
$diff_shipping_tax_excl = $this->total_shipping_tax_excl - $base_total_shipping_tax_excl;
$this->total_shipping_tax_excl = $this->total_shipping_tax_excl - $diff_shipping_tax_excl;
$this->total_shipping_tax_incl = $this->total_shipping_tax_incl - $diff_shipping_tax_incl;
$this->total_shipping = $this->total_shipping_tax_incl;
$this->total_paid_tax_excl = $this->total_paid_tax_excl - $diff_shipping_tax_excl;
$this->total_paid_tax_incl = $this->total_paid_tax_incl - $diff_shipping_tax_incl;
$this->total_paid = $this->total_paid_tax_incl;
$this->update();
// save order_carrier prices, we'll save order right after this in update() method
$order_carrier = new OrderCarrier((int) $this->getIdOrderCarrier());
$order_carrier->shipping_cost_tax_excl = $this->total_shipping_tax_excl;
$order_carrier->shipping_cost_tax_incl = $this->total_shipping_tax_incl;
$order_carrier->update();
// remove fake cart
$new_cart->delete();
return $this;
}