- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
当我在模板文件中回显 $test_text 时,确认调用了以下函数。
PHP 也不再对我大喊大叫,但“订单”并未处理。
public function process_cart() {
$this->load->model('sale/order');
$this->data['test_text'] = "I'm here."
$order_details = array(
'store_id' => 1,
'customer_id' => $this->address['customer_id'],
'customer_group_id' => 1,
'firstname' => $this->address['firstname'],
'lastname' => $this->address['lastname'],
'email' => $this->address['email'],
'telephone' => $this->address['telephone'],
'fax' => $this->address['fax'],
'payment_firstname' => $this->address['firstname'],
'payment_lastname' => $this->address['lastname'],
'payment_company' => '',
'payment_company_id' => '',
'payment_tax_id' => '',
'payment_address_1' => '',
'payment_address_2' => '',
'payment_city' => '',
'payment_postcode' => '',
'payment_country_id' => '',
'payment_zone_id' => '',
'payment_method' => '',
'payment_code' => '',
'shipping_firstname' => '',
'shipping_lastname' => '',
'shipping_company' => '',
'shipping_address_1' => '',
'shipping_address_2' => '',
'shipping_city' => '',
'shipping_postcode' => '',
'shipping_country_id' => '',
'shipping_zone_id' => '',
'shipping_method' => '',
'shipping_code' => '',
'comment' => '',
'order_status_id' => 1,
'affiliate_id' => '',
'products' => $this->data['products']
);
$this->model_sale_order->addOrder($order_details);
}
谁能看到我错过了什么?
最佳答案
$order_id = $this->db->getLastId();
foreach ($data['products'] as $product) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET
order_id = '" . (int)$order_id . "',
product_id = '" . (int)$product['product_id'] . "',
name = '" . $this->db->escape($product['name']) . "',
model = '" . $this->db->escape($product['model']) . "',
quantity = '" . (int)$product['quantity'] . "',
price = '" . (float)$product['price'] . "',
total = '" . (float)$product['total'] . "',
tax = '" . (float)$product['tax'] . "',
reward = '" . (int)$product['reward'] . "'");
$order_product_id = $this->db->getLastId();
foreach ($product['option'] as $option) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_option SET
order_id = '" . (int)$order_id . "',
order_product_id = '" . (int)$order_product_id . "',
product_option_id = '" . (int)$option['product_option_id'] . "',
product_option_value_id = '" . (int)$option['product_option_value_id'] . "',
name = '" . $this->db->escape($option['name']) . "',
`value` = '" . $this->db->escape($option['value']) . "',
`type` = '" . $this->db->escape($option['type']) . "'");
}
foreach ($product['download'] as $download) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_download SET
order_id = '" . (int)$order_id . "',
order_product_id = '" . (int)$order_product_id . "',
name = '" . $this->db->escape($download['name']) . "',
filename = '" . $this->db->escape($download['filename']) . "',
mask = '" . $this->db->escape($download['mask']) . "',
remaining = '" . (int)($download['remaining'] * $product['quantity']) . "'");
}
}
foreach ($data['vouchers'] as $voucher) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_voucher SET
order_id = '" . (int)$order_id . "',
description = '" . $this->db->escape($voucher['description']) . "',
code = '" . $this->db->escape($voucher['code']) . "',
from_name = '" . $this->db->escape($voucher['from_name']) . "',
from_email = '" . $this->db->escape($voucher['from_email']) . "',
to_name = '" . $this->db->escape($voucher['to_name']) . "',
to_email = '" . $this->db->escape($voucher['to_email']) . "',
voucher_theme_id = '" . (int)$voucher['voucher_theme_id'] . "',
message = '" . $this->db->escape($voucher['message']) . "',
amount = '" . (float)$voucher['amount'] . "'");
}
foreach ($data['totals'] as $total) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_total SET
order_id = '" . (int)$order_id . "',
code = '" . $this->db->escape($total['code']) . "',
title = '" . $this->db->escape($total['title']) . "',
text = '" . $this->db->escape($total['text']) . "',
`value` = '" . (float)$total['value'] . "',
sort_order = '" . (int)$total['sort_order'] . "'");
}
return $order_id;
尝试在现有代码之后添加这个。
关于php - 通过 OpenCart addOrder 方法处理订单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24792053/
我使用 asp.net core 和 cosmos db 创建了一个目录 api。我发布了一个目录数据集。但我收到以下错误。我使用断点对其进行调试,问题是我的结果正文为空。 {"errors":{"i
我使用 asp.net core 和 cosmos db 创建了一个目录 api。我发布了一个目录数据集。但我收到以下错误。我使用断点对其进行调试,问题是我的结果正文为空。 {"errors":{"i
API AddOrder() 命令是否支持限价订单的 expiretm ?当我设置此参数时,我总是收到 EGeneral:Invalid Arguments:expiretm 错误。 我尝试使用以下设
我的用户表如下所示: USER ( "USER_ID" NUMBER(15,0) NOT NULL, "TYPE" NUMBER(2,0), "DOMAIN_ID" NUMBE
当我在模板文件中回显 $test_text 时,确认调用了以下函数。 PHP 也不再对我大喊大叫,但“订单”并未处理。 public function process_cart() {
我有一个 OrderEntity,它有一个属性 OrderStatistics,该属性有一个属性 CreateDate。它看起来像 Order.OrderStatistics.CreateDate。
我一直在开发: public List getAllDepartmentTypes() { return session.getCurrentSession()
我是一名优秀的程序员,十分优秀!