我正在尝试在成功页面上显示成功订单的订单详细信息,但无法这样做。这里的另一个答案建议修改success.php和success.tpl,但它不适用于Opencart 2.
我尝试了什么?
目录/控制器/结帐/ success.php
并在以下代码中添加了新行:
public function index() {
$this->data['order_id'] = 0; // <-- NEW LINE
$this->data['total'] = 0; // <-- NEW LINE
if (isset($this->session->data['order_id'])) {
$this->data['order_id'] = $this->session->data['order_id']; // <-- NEW LINE
$this->data['total'] = $this->cart->getTotal(); // <-- NEW LINE
$this->cart->clear();
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['guest']);
unset($this->session->data['comment']);
unset($this->session->data['order_id']);
unset($this->session->data['coupon']);
unset($this->session->data['reward']);
unset($this->session->data['voucher']);
unset($this->session->data['vouchers']);
}
$this->language->load('checkout/success');
现在将以下代码添加到success.tpl
中<?php if($order_id) { ?>
<script type="text/javascript">
// Some code here
arr.push([
"create_order",
{order_id: '<?php echo $order_id; ?>', sum: '<?php echo $total; ?>'}
]);
但它在成功页面上没有显示任何内容。上面的代码是显示订单ID和总数,但我想显示订单的所有细节,包括名称,地址,产品,总数,运费等。就像订单发票一样。
任何帮助将不胜感激。谢谢
答案 0 :(得分:2)
我在pre 2.0版本上所做的是实际为订单ID的会话设置了一个新变量,因为我发现$this->session->data['order_id']
不一致,有时在用户到达{{{{ 1}}。
如果您想使用此方法,请修改ControllerCheckoutSuccess
文件。在第302行或附近(在addOrderHistory方法中),您将看到脚本检查订单状态ID的位置,以确定它是否应该完成订单。
在该声明中,将您选择的新会话变量设置为传入的订单ID,可能catalog/model/checkout/order.php
现在你有一个会话变量,你知道它会保持一致,因为你自己创建它并且OpenCart不会弄乱它。
如果您发现会话订单ID IS 在2.1&gt;中保持一致然后不要担心这一点,只需继续使用内置的默认会话顺序id变量。
下一步将是您通过PHP或Ajax决定如何加载发票数据。我不建议使用Ajax,因为这可以使用浏览器开发人员工具进行操作,并可能暴露其他客户的信息。通过使用PHP和会话,您可以消除这种风险,因为随机黑客无法访问其他客户的会话。
以下两个选项都需要:
打开$this->session->data['customer_order_id'] = $order_id
在索引方法中加载语言文件后,添加以下内容:
catalog/controller/checkout/success.php
如果您正在使用烘焙会话数据订单ID,请在该声明中设置您的订单ID:
$order_id = false;
// If NOT using the custom variable mentioned SKIP this
if (isset($this->session->data['customer_order_id'])) {
$order_id = $this->session->data['customer_order_id'];
}
选项1:
将收据数据添加到结帐/成功。
找到这一行:
if (isset($this->session->data['order_id'])) {
$this->cart->clear();
$order_id = $this->session->data['order_id'];
应该在77-84号左右或附近。
在这里,您将加载并格式化所有收据信息。
打开$data['button_continue'] = $this->language->get('button_continue');
在第108行,您将找到catalog/controller/account/order.php
方法。
这是有趣的开始:P
在上述info
行之后,将该方法的所有相关信息复制到结帐成功控制器中。
您需要逐行浏览并调整它,因为请记住这是专为登录客户设计的,因此您不需要返回或重新排序的链接等。
接下来,您将要制作一个新模板,因为$data['button_continue'] = $this->language->get('button_continue');
模板是通用的,并在整个地方使用。
复制common/success
至:catalog/view/theme/(your theme)/template/common/success.tpl
打开catalog/view/theme/(your theme)/template/checkout/success.tpl
您需要添加到成功模板的表格从第28行开始并延伸到第139行。如果您使用的是其他主题,则需要自行解决此问题。
不要忘记将catalog/view/theme/default/template/account/order_info.tpl
控制器中模板的路径更改为新的checkout/success
tpl文件。
注意:强>
重要的是要记住,所有这些应该在修改包中完成,而 NOT 在你的核心文件中,但我不知道你的情况,所以这取决于你决定。
选项2:
创建自己的模块。
在我看来,自1.4版本开始为此系统构建时,这是最佳选择。
在模块中创建新控制器,我们称之为checkout/success
:
ControllerModuleReceipt
<强> TEMPLATE:强>
接下来让我们在<?php
/**
* Controller class for displaying a receipt on checkout success.
*/
class ControllerModuleReceipt extends Controller
{
/**
* Replicates the ControllerAccountOrder::info
* method for displaying order info in our
* ControllerCheckoutSuccess::index method
*
* @param int $order_id our order id
* @return mixed receipt view
*/
public function index($setting)
{
$this->load->language('account/order');
$this->load->model('account/order');
if (empty($setting['order_id'])) {
return;
}
$order_id = $setting['order_id'];
$order_info = $this->model_account_order->getOrder($order_id);
if ($order_info) {
$data['text_order_detail'] = $this->language->get('text_order_detail');
$data['text_invoice_no'] = $this->language->get('text_invoice_no');
$data['text_order_id'] = $this->language->get('text_order_id');
$data['text_date_added'] = $this->language->get('text_date_added');
$data['text_shipping_method'] = $this->language->get('text_shipping_method');
$data['text_shipping_address'] = $this->language->get('text_shipping_address');
$data['text_payment_method'] = $this->language->get('text_payment_method');
$data['text_payment_address'] = $this->language->get('text_payment_address');
$data['text_history'] = $this->language->get('text_history');
$data['text_comment'] = $this->language->get('text_comment');
$data['column_name'] = $this->language->get('column_name');
$data['column_model'] = $this->language->get('column_model');
$data['column_quantity'] = $this->language->get('column_quantity');
$data['column_price'] = $this->language->get('column_price');
$data['column_total'] = $this->language->get('column_total');
$data['column_action'] = $this->language->get('column_action');
$data['column_date_added'] = $this->language->get('column_date_added');
$data['column_status'] = $this->language->get('column_status');
$data['column_comment'] = $this->language->get('column_comment');
$data['invoice_no'] = '';
if ($order_info['invoice_no']) {
$data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no'];
}
$data['order_id'] = $order_id;
$data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added']));
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
if ($order_info['payment_address_format']) {
$format = $order_info['payment_address_format'];
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['payment_firstname'],
'lastname' => $order_info['payment_lastname'],
'company' => $order_info['payment_company'],
'address_1' => $order_info['payment_address_1'],
'address_2' => $order_info['payment_address_2'],
'city' => $order_info['payment_city'],
'postcode' => $order_info['payment_postcode'],
'zone' => $order_info['payment_zone'],
'zone_code' => $order_info['payment_zone_code'],
'country' => $order_info['payment_country']
);
$data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
$data['payment_method'] = $order_info['payment_method'];
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
if ($order_info['shipping_address_format']) {
$format = $order_info['shipping_address_format'];
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['shipping_firstname'],
'lastname' => $order_info['shipping_lastname'],
'company' => $order_info['shipping_company'],
'address_1' => $order_info['shipping_address_1'],
'address_2' => $order_info['shipping_address_2'],
'city' => $order_info['shipping_city'],
'postcode' => $order_info['shipping_postcode'],
'zone' => $order_info['shipping_zone'],
'zone_code' => $order_info['shipping_zone_code'],
'country' => $order_info['shipping_country']
);
$data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
$data['shipping_method'] = $order_info['shipping_method'];
$this->load->model('catalog/product');
$this->load->model('tool/upload');
// Products
$data['products'] = array();
$products = $this->model_account_order->getOrderProducts($this->request->get['order_id']);
foreach ($products as $product) {
$option_data = array();
$options = $this->model_account_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']);
foreach ($options as $option) {
$value = false;
if ($option['type'] == 'file') {
$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
if ($upload_info) {
$value = $upload_info['name'];
}
}
if (! $value) {
$value = $option['value'];
}
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
);
}
$product_info = $this->model_catalog_product->getProduct($product['product_id']);
$data['products'][] = array(
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value'])
);
}
// Voucher
$data['vouchers'] = array();
$vouchers = $this->model_account_order->getOrderVouchers($this->request->get['order_id']);
foreach ($vouchers as $voucher) {
$data['vouchers'][] = array(
'description' => $voucher['description'],
'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value'])
);
}
// Totals
$data['totals'] = array();
$totals = $this->model_account_order->getOrderTotals($this->request->get['order_id']);
foreach ($totals as $total) {
$data['totals'][] = array(
'title' => $total['title'],
'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']),
);
}
$data['comment'] = nl2br($order_info['comment']);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/receipt.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/module/receipt.tpl', $data);
} else {
return $this->load->view('default/template/module/receipt.tpl', $data);
}
}
}
}
catalog/views/theme/default/module/receipt.tpl
再一次,如果你使用自己的主题,你需要调整它。
添加模块以检查成功
回到结账成功控制器,我们需要添加模块。
查找<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left" colspan="2"><?= $text_order_detail; ?></td>
</tr>
</thead>
<tbody>
<tr>
<td class="text-left" style="width: 50%;"><?php if ($invoice_no): ?>
<b><?= $text_invoice_no; ?></b> <?= $invoice_no; ?><br />
<?php endif; ?>
<b><?= $text_order_id; ?></b> #<?= $order_id; ?><br />
<b><?= $text_date_added; ?></b> <?= $date_added; ?></td>
<td class="text-left"><?php if ($payment_method): ?>
<b><?= $text_payment_method; ?></b> <?= $payment_method; ?><br />
<?php endif; ?>
<?php if ($shipping_method): ?>
<b><?= $text_shipping_method; ?></b> <?= $shipping_method; ?>
<?php endif; ?></td>
</tr>
</tbody>
</table>
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left" style="width: 50%;"><?= $text_payment_address; ?></td>
<?php if ($shipping_address): ?>
<td class="text-left"><?= $text_shipping_address; ?></td>
<?php endif; ?>
</tr>
</thead>
<tbody>
<tr>
<td class="text-left"><?= $payment_address; ?></td>
<?php if ($shipping_address): ?>
<td class="text-left"><?= $shipping_address; ?></td>
<?php endif; ?>
</tr>
</tbody>
</table>
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left"><?= $column_name; ?></td>
<td class="text-left"><?= $column_model; ?></td>
<td class="text-right"><?= $column_quantity; ?></td>
<td class="text-right"><?= $column_price; ?></td>
<td class="text-right"><?= $column_total; ?></td>
<?php if ($products): ?>
<td style="width: 20px;"></td>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php foreach ($products as $product): ?>
<tr>
<td class="text-left"><?= $product['name']; ?>
<?php foreach ($product['option'] as $option): ?>
<br />
<small> - <?= $option['name']; ?>: <?= $option['value']; ?></small>
<?php endforeach; ?></td>
<td class="text-left"><?= $product['model']; ?></td>
<td class="text-right"><?= $product['quantity']; ?></td>
<td class="text-right"><?= $product['price']; ?></td>
<td class="text-right"><?= $product['total']; ?></td>
<td class="text-right" style="white-space: nowrap;"><?php if ($product['reorder']): ?>
<a href="<?= $product['reorder']; ?>" data-toggle="tooltip" title="<?= $button_reorder; ?>" class="btn btn-primary"><i class="fa fa-shopping-cart"></i></a>
<?php endif; ?>
<a href="<?= $product['return']; ?>" data-toggle="tooltip" title="<?= $button_return; ?>" class="btn btn-danger"><i class="fa fa-reply"></i></a></td>
</tr>
<?php endforeach; ?>
<?php foreach ($vouchers as $voucher): ?>
<tr>
<td class="text-left"><?= $voucher['description']; ?></td>
<td class="text-left"></td>
<td class="text-right">1</td>
<td class="text-right"><?= $voucher['amount']; ?></td>
<td class="text-right"><?= $voucher['amount']; ?></td>
<?php if ($products): ?>
<td></td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<?php foreach ($totals as $total): ?>
<tr>
<td colspan="3"></td>
<td class="text-right"><b><?= $total['title']; ?></b></td>
<td class="text-right"><?= $total['text']; ?></td>
<?php if ($products): ?>
<td></td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tfoot>
</table>
</div>
<?php if ($comment): ?>
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left"><?= $text_comment; ?></td>
</tr>
</thead>
<tbody>
<tr>
<td class="text-left"><?= $comment; ?></td>
</tr>
</tbody>
</table>
<?php endif; ?>
在该行之后添加:
$data['content_bottom'] = $this->load->controller('common/content_bottom');
添加成功模板
打开$data['receipt'] = false;
if ($order_id) {
$data['receipt'] = $this->load->controller('module/receipt', array('order_id' => $order_id));
}
catalog/view/theme/default/common/success.tpl
之后添加:
<?php echo $text_message; ?>
那应该是它。再一次最好通过修改将更改添加到核心文件中,但通过创建自己的模块,可以更容易地添加修改,更不用说处理了。
我没有测试上面的代码,但它应该工作或具有最小的错误。随意发布任何错误,我很乐意帮助解决它们。
答案 1 :(得分:0)
Vince 发布的精彩代码!
但是我发现了一些错误和PHP通知并且产品表没有显示出来,所以我在代码中做了一些修改,它现在100%工作。
我使用OPTION 2和Opencart 2.2进行测试。
以下是代码:
CONTROLLER / MODULE中的Receipit.php
<?php
/**
* Controller class for displaying a receipt on checkout success.
*/
class ControllerModuleReceipt extends Controller
{
/**
* Replicates the ControllerAccountOrder::info
* method for displaying order info in our
* ControllerCheckoutSuccess::index method
*
* @param int $order_id our order id
* @return mixed receipt view
*/
public function index($setting)
{
$this->load->language('account/order');
$this->load->model('account/order');
if (empty($setting['order_id'])) {
return;
}
$order_id = $setting['order_id'];
$order_info = $this->model_account_order->getOrder($order_id);
if ($order_info) {
$data['text_order_detail'] = $this->language->get('text_order_detail');
$data['text_invoice_no'] = $this->language->get('text_invoice_no');
$data['text_order_id'] = $this->language->get('text_order_id');
$data['text_date_added'] = $this->language->get('text_date_added');
$data['text_shipping_method'] = $this->language->get('text_shipping_method');
$data['text_shipping_address'] = $this->language->get('text_shipping_address');
$data['text_payment_method'] = $this->language->get('text_payment_method');
$data['text_payment_address'] = $this->language->get('text_payment_address');
$data['text_history'] = $this->language->get('text_history');
$data['text_comment'] = $this->language->get('text_comment');
$data['column_name'] = $this->language->get('column_name');
$data['column_model'] = $this->language->get('column_model');
$data['column_quantity'] = $this->language->get('column_quantity');
$data['column_price'] = $this->language->get('column_price');
$data['column_total'] = $this->language->get('column_total');
$data['column_action'] = $this->language->get('column_action');
$data['column_date_added'] = $this->language->get('column_date_added');
$data['column_status'] = $this->language->get('column_status');
$data['column_comment'] = $this->language->get('column_comment');
$data['invoice_no'] = '';
if ($order_info['invoice_no']) {
$data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no'];
}
$data['order_id'] = $order_id;
$data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added']));
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
if ($order_info['payment_address_format']) {
$format = $order_info['payment_address_format'];
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['payment_firstname'],
'lastname' => $order_info['payment_lastname'],
'company' => $order_info['payment_company'],
'address_1' => $order_info['payment_address_1'],
'address_2' => $order_info['payment_address_2'],
'city' => $order_info['payment_city'],
'postcode' => $order_info['payment_postcode'],
'zone' => $order_info['payment_zone'],
'zone_code' => $order_info['payment_zone_code'],
'country' => $order_info['payment_country']
);
$data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
$data['payment_method'] = $order_info['payment_method'];
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
if ($order_info['shipping_address_format']) {
$format = $order_info['shipping_address_format'];
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['shipping_firstname'],
'lastname' => $order_info['shipping_lastname'],
'company' => $order_info['shipping_company'],
'address_1' => $order_info['shipping_address_1'],
'address_2' => $order_info['shipping_address_2'],
'city' => $order_info['shipping_city'],
'postcode' => $order_info['shipping_postcode'],
'zone' => $order_info['shipping_zone'],
'zone_code' => $order_info['shipping_zone_code'],
'country' => $order_info['shipping_country']
);
$data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
$data['shipping_method'] = $order_info['shipping_method'];
$this->load->model('catalog/product');
$this->load->model('tool/upload');
// Products
$data['products'] = array();
$products = $this->model_account_order->getOrderProducts($order_id);
foreach ($products as $product) {
$option_data = array();
$options = $this->model_account_order->getOrderOptions($order_id, $product['order_product_id']);
foreach ($options as $option) {
$value = false;
if ($option['type'] == 'file') {
$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
if ($upload_info) {
$value = $upload_info['name'];
}
}
if (! $value) {
$value = $option['value'];
}
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
);
}
$product_info = $this->model_catalog_product->getProduct($product['product_id']);
$data['products'][] = array(
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value'])
);
}
// Voucher
$data['vouchers'] = array();
$vouchers = $this->model_account_order->getOrderVouchers($order_id);
foreach ($vouchers as $voucher) {
$data['vouchers'][] = array(
'description' => $voucher['description'],
'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value'])
);
}
// Totals
$data['totals'] = array();
$totals = $this->model_account_order->getOrderTotals($order_id);
foreach ($totals as $total) {
$data['totals'][] = array(
'title' => $total['title'],
'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']),
);
}
$data['comment'] = nl2br($order_info['comment']);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/receipt.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/module/receipt.tpl', $data);
} else {
return $this->load->view('/module/receipt.tpl', $data);
}
}
}
}
TEMPLATES / MODULE中的Receipit.tpl
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left" colspan="2"><?= $text_order_detail; ?></td>
</tr>
</thead>
<tbody>
<tr>
<td class="text-left" style="width: 50%;"><?php if ($invoice_no): ?>
<b><?= $text_invoice_no; ?></b> <?= $invoice_no; ?><br />
<?php endif; ?>
<b><?= $text_order_id; ?></b> #<?= $order_id; ?><br />
<b><?= $text_date_added; ?></b> <?= $date_added; ?></td>
<td class="text-left"><?php if ($payment_method): ?>
<b><?= $text_payment_method; ?></b> <?= $payment_method; ?><br />
<?php endif; ?>
<?php if ($shipping_method): ?>
<b><?= $text_shipping_method; ?></b> <?= $shipping_method; ?>
<?php endif; ?></td>
</tr>
</tbody>
</table>
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left" style="width: 50%;"><?= $text_payment_address; ?></td>
<?php if ($shipping_address): ?>
<td class="text-left"><?= $text_shipping_address; ?></td>
<?php endif; ?>
</tr>
</thead>
<tbody>
<tr>
<td class="text-left"><?= $payment_address; ?></td>
<?php if ($shipping_address): ?>
<td class="text-left"><?= $shipping_address; ?></td>
<?php endif; ?>
</tr>
</tbody>
</table>
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left" style="display: table-cell"><?= $column_name; ?></td>
<td class="text-left" style="display: none"><?= $column_model; ?></td>
<td class="text-right" style="display: table-cell"><?= $column_quantity; ?></td>
<td class="text-right" style="display: table-cell"><?= $column_price; ?></td>
<td class="text-right" style="display: table-cell"><?= $column_total; ?></td>
</tr>
</thead>
<tbody>
<?php foreach ($products as $product): ?>
<tr>
<td class="text-left" style="display: table-cell"><?= $product['name']; ?>
<?php foreach ($product['option'] as $option): ?>
<br />
<small> - <?= $option['name']; ?>: <?= $option['value']; ?></small>
<?php endforeach; ?></td>
<td class="text-left" style="display: none"><?= $product['model']; ?></td>
<td class="text-right" style="display: table-cell"><?= $product['quantity']; ?></td>
<td class="text-right" style="display: table-cell"><?= $product['price']; ?></td>
<td class="text-right" style="display: table-cell"><?= $product['total']; ?></td>
</tr>
<?php endforeach; ?>
<?php foreach ($vouchers as $voucher): ?>
<tr>
<td class="text-left"><?= $voucher['description']; ?></td>
<td class="text-left"></td>
<td class="text-right">1</td>
<td class="text-right"><?= $voucher['amount']; ?></td>
<td class="text-right"><?= $voucher['amount']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<?php foreach ($totals as $total): ?>
<tr>
<td colspan="2"></td>
<td class="text-right"><b><?= $total['title']; ?></b></td>
<td class="text-right"><?= $total['text']; ?></td>
</tr>
<?php endforeach; ?>
</tfoot>
</table>
</div>
<?php if ($comment): ?>
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left"><?= $text_comment; ?></td>
</tr>
</thead>
<tbody>
<tr>
<td class="text-left"><?= $comment; ?></td>
</tr>
</tbody>
</table>
<?php endif; ?>
注意强>
在您的商店中输入代码之前,请先测试一下备份,以确保您的商店不会受到影响。
如果此代码有任何缺陷,请在此告诉我
谢谢!