本文整理汇总了PHP中Cart::getCartIdByOrderId方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::getCartIdByOrderId方法的具体用法?PHP Cart::getCartIdByOrderId怎么用?PHP Cart::getCartIdByOrderId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::getCartIdByOrderId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCartByOrderId
/**
* Build cart object from provided id_order
*
* @param int $id_order
* @return Cart|bool
*/
public static function getCartByOrderId($id_order)
{
if ($id_cart = Cart::getCartIdByOrderId($id_order)) {
return new Cart((int) $id_cart);
}
return false;
}
示例2: postProcess
//.........这里部分代码省略.........
} elseif ($message->private) {
Tools::redirectAdmin($currentIndex . '&id_order=' . $id_order . '&vieworder&conf=11' . '&token=' . $this->token);
} elseif (Validate::isLoadedObject($customer = new Customer($id_customer))) {
$order = new Order((int) $message->id_order);
if (Validate::isLoadedObject($order)) {
$varsTpl = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order}' => $message->id_order, '{message}' => Configuration::get('PS_MAIL_TYPE') == 2 ? $message->message : nl2br2($message->message));
if (@Mail::Send((int) $order->id_lang, 'order_merchant_comment', Mail::l('New message regarding your order'), $varsTpl, $customer->email, $customer->firstname . ' ' . $customer->lastname, NULL, NULL, NULL, NULL, _PS_MAIL_DIR_, true)) {
Tools::redirectAdmin($currentIndex . '&id_order=' . $id_order . '&vieworder&conf=11' . '&token=' . $this->token);
}
}
}
$this->_errors[] = Tools::displayError('An error occurred while sending e-mail to customer.');
}
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} elseif (Tools::isSubmit('cancelProduct') and Validate::isLoadedObject($order = new Order((int) 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');
$full_product_list = $productList;
$full_quantity_list = $qtyList;
if ($customizationList) {
foreach ($customizationList as $key => $id_order_detail) {
$full_product_list[$id_order_detail] = $id_order_detail;
$full_quantity_list[$id_order_detail] = $customizationQtyList[$key];
}
}
if ($productList or $customizationList) {
if ($productList) {
$id_cart = Cart::getCartIdByOrderId($order->id);
$customization_quantities = Customization::countQuantityByCart($id_cart);
foreach ($productList as $key => $id_order_detail) {
$qtyCancelProduct = abs($qtyList[$key]);
if (!$qtyCancelProduct) {
$this->_errors[] = Tools::displayError('No quantity selected for product.');
}
// check actionable quantity
$order_detail = new OrderDetail($id_order_detail);
$customization_quantity = 0;
if (array_key_exists($order_detail->product_id, $customization_quantities) && array_key_exists($order_detail->product_attribute_id, $customization_quantities[$order_detail->product_id])) {
$customization_quantity = (int) $customization_quantities[$order_detail->product_id][$order_detail->product_attribute_id];
}
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) {
示例3: renderView
//.........这里部分代码省略.........
$module = Module::getInstanceByName($payment['name']);
if (Validate::isLoadedObject($module) && $module->active) {
$payment_methods[] = $module->displayName;
}
}
// display warning if there are products out of stock
$display_out_of_stock_warning = false;
$current_order_state = $order->getCurrentOrderState();
if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) {
$display_out_of_stock_warning = true;
}
// products current stock (from stock_available)
foreach ($products as &$product) {
// Get total customized quantity for current product
$customized_product_quantity = 0;
if (is_array($product['customizedDatas'])) {
foreach ($product['customizedDatas'] as $customizationPerAddress) {
foreach ($customizationPerAddress as $customizationId => $customization) {
$customized_product_quantity += (int) $customization['quantity'];
}
}
}
$product['customized_product_quantity'] = $customized_product_quantity;
$product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']);
$resume = OrderSlip::getProductSlipResume($product['id_order_detail']);
$product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity'];
$product['amount_refundable'] = $product['total_price_tax_excl'] - $resume['amount_tax_excl'];
$product['amount_refundable_tax_incl'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl'];
$product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl'], $currency);
$product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']);
$product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']);
// if the current stock requires a warning
if ($product['current_stock'] == 0 && $display_out_of_stock_warning) {
$this->displayWarning($this->l('This product is out of stock: ') . ' ' . $product['product_name']);
}
if ($product['id_warehouse'] != 0) {
$warehouse = new Warehouse((int) $product['id_warehouse']);
$product['warehouse_name'] = $warehouse->name;
$warehouse_location = WarehouseProductLocation::getProductLocation($product['product_id'], $product['product_attribute_id'], $product['id_warehouse']);
if (!empty($warehouse_location)) {
$product['warehouse_location'] = $warehouse_location;
} else {
$product['warehouse_location'] = false;
}
} else {
$product['warehouse_name'] = '--';
$product['warehouse_location'] = false;
}
}
$gender = new Gender((int) $customer->id_gender, $this->context->language->id);
$history = $order->getHistory($this->context->language->id);
foreach ($history as &$order_state) {
$order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black';
}
//by webkul to get data to show hotel rooms order data on order detail page
$cart_id = Cart::getCartIdByOrderId(Tools::getValue('id_order'));
$cart_detail_data = array();
$cart_detail_data_obj = new HotelCartBookingData();
$cart_detail_data = $cart_detail_data_obj->getCartCurrentDataByCartId((int) $cart_id);
if ($cart_detail_data) {
foreach ($cart_detail_data as $key => $value) {
$product_image_id = Product::getCover($value['id_product']);
$link_rewrite = (new Product((int) $value['id_product'], Configuration::get('PS_LANG_DEFAULT')))->link_rewrite[Configuration::get('PS_LANG_DEFAULT')];
if ($product_image_id) {
$cart_detail_data[$key]['image_link'] = $this->context->link->getImageLink($link_rewrite, $product_image_id['id_image'], 'small_default');
} else {
$cart_detail_data[$key]['image_link'] = $this->context->link->getImageLink($link_rewrite, $this->context->language->iso_code . "-default", 'small_default');
}
$cart_detail_data[$key]['room_type'] = (new Product((int) $value['id_product']))->name[Configuration::get('PS_LANG_DEFAULT')];
$cart_detail_data[$key]['room_num'] = (new HotelRoomInformation((int) $value['id_room']))->room_num;
$cart_detail_data[$key]['date_from'] = (new DateTime($value['date_from']))->format('d-M Y');
$cart_detail_data[$key]['date_to'] = (new DateTime($value['date_to']))->format('d-M Y');
$cust_obj = new Customer($value['id_customer']);
$cart_detail_data[$key]['alloted_cust_name'] = $cust_obj->firstname . ' ' . $cust_obj->lastname;
$cart_detail_data[$key]['alloted_cust_email'] = $cust_obj->email;
$cart_detail_data[$key]['avail_rooms_to_swap'] = (new HotelBookingDetail())->getAvailableRoomsForSwaping($value['date_from'], $value['date_to'], $value['id_product'], $value['id_hotel']);
$obj_booking_dtl = new HotelBookingDetail();
$num_days = $obj_booking_dtl->getNumberOfDays($cart_detail_data[$key]['date_from'], $cart_detail_data[$key]['date_to']);
//quantity of product
$cart_detail_data[$key]['amt_with_qty'] = $value['amount'] * $num_days;
}
}
//end
//by webkul to send order status on order detail page
$obj_bookin_detail = new HotelBookingDetail();
$htl_booking_data_order_id = $obj_bookin_detail->getBookingDataByOrderId(Tools::getValue('id_order'));
if ($htl_booking_data_order_id) {
foreach ($htl_booking_data_order_id as $key => $value) {
$htl_booking_data_order_id[$key]['room_num'] = (new HotelRoomInformation())->getHotelRoomInfoById($value['id_room']);
$htl_booking_data_order_id[$key]['order_status'] = $value['id_status'];
$htl_booking_data_order_id[$key]['date_from'] = (new DateTime($value['date_from']))->format('d-M Y');
$htl_booking_data_order_id[$key]['date_to'] = (new DateTime($value['date_to']))->format('d-M Y');
}
}
$htl_order_status = HotelOrderStatus::getAllHotelOrderStatus();
//end
// Smarty assign
$this->tpl_view_vars = array('htl_booking_order_data' => $htl_booking_data_order_id, 'hotel_order_status' => $htl_order_status, 'cart_detail_data' => $cart_detail_data, 'order' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array('delivery' => $addressDelivery, 'deliveryState' => isset($deliveryState) ? $deliveryState : null, 'invoice' => $addressInvoice, 'invoiceState' => isset($invoiceState) ? $invoiceState : null), 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), 'total_paid' => $order->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer, null, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, 'states' => OrderState::getOrderStates($this->context->language->id), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($order->id), 'currentState' => $order->getCurrentOrderState(), 'currency' => new Currency($order->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($order->id_shop), 'previousOrder' => $order->getPreviousOrderId(), 'nextOrder' => $order->getNextOrderId(), 'current_index' => self::$currentIndex, 'carrierModuleCall' => $carrier_module_call, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->tabAccess['edit'] == 1, 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $order->getInvoicesCollection(), 'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $order->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $order, 'products' => $products, 'customer' => $customer)));
return parent::renderView();
}
示例4: postProcess
//.........这里部分代码省略.........
} elseif ($message->private) {
Tools::redirectAdmin($currentIndex . '&id_order=' . $id_order . '&vieworder&conf=11' . '&token=' . $this->token);
} elseif (Validate::isLoadedObject($customer = new Customer($id_customer))) {
$order = new Order((int) $message->id_order);
if (Validate::isLoadedObject($order)) {
$varsTpl = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order}' => $message->id_order, '{message}' => Configuration::get('PS_MAIL_TYPE') == 2 ? $message->message : nl2br2($message->message));
if (@Mail::Send((int) $order->id_lang, 'order_merchant_comment', Mail::l('New message regarding your order'), $varsTpl, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
Tools::redirectAdmin($currentIndex . '&id_order=' . $id_order . '&vieworder&conf=11' . '&token=' . $this->token);
}
}
}
$this->_errors[] = Tools::displayError('An error occurred while sending e-mail to customer.');
}
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} elseif (Tools::isSubmit('cancelProduct') and Validate::isLoadedObject($order = new Order((int) 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');
$full_product_list = $productList;
$full_quantity_list = $qtyList;
if ($customizationList) {
foreach ($customizationList as $key => $id_order_detail) {
$full_product_list[$id_order_detail] = $id_order_detail;
$full_quantity_list[$id_order_detail] = $customizationQtyList[$key];
}
}
if ($productList or $customizationList) {
if ($productList) {
$id_cart = Cart::getCartIdByOrderId($order->id);
$customization_quantities = Customization::countQuantityByCart($id_cart);
foreach ($productList as $key => $id_order_detail) {
$qtyCancelProduct = abs($qtyList[$key]);
if (!$qtyCancelProduct) {
$this->_errors[] = Tools::displayError('No quantity selected for product.');
}
// check actionable quantity
$order_detail = new OrderDetail($id_order_detail);
$customization_quantity = 0;
if (array_key_exists($order_detail->product_id, $customization_quantities) && array_key_exists($order_detail->product_attribute_id, $customization_quantities[$order_detail->product_id])) {
$customization_quantity = (int) $customization_quantities[$order_detail->product_id][$order_detail->product_attribute_id];
}
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) {