【问题标题】:Notification for user in user account opencart用户帐户 opencart 中的用户通知
【发布时间】:2015-04-14 19:01:18
【问题描述】:

感谢任何帮助我或为我指明正确方向的人。

我想在登录后在我的帐户页面中向用户显示待处理通知。仅当他们的任何订单状态处于待处理状态时才会显示此通知。从管理员更改任何其他状态后,将删除该通知。

此通知将显示如下:

您的订单号: 订单状态: 和 [ 带有自定义 URL 的按钮]

如果有多个订单,则会显示多个订单 ID。 我的带有自定义主题的打开购物车版本 1.5.6.3。

【问题讨论】:

    标签: notifications opencart status user-accounts


    【解决方案1】:
        $this->load->model('account/order');
        $results = $this->model_account_order->getOrders();
    
        foreach ($results as $result) {
            $product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']);
            $voucher_total = $this->model_account_order->getTotalOrderVouchersByOrderId($result['order_id']);
            if( $result['status'] =! 5){ // 5 order status means its completed
                $this->data['orders'][] = array(
                'order_id'   => $result['order_id'],
                'name'       => $result['firstname'] . ' ' . $result['lastname'],
                'status'     => $result['status'],
                'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
                'products'   => ($product_total + $voucher_total),
                'total'      => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
                'href'       => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], 'SSL'),
                'reorder'    => $this->url->link('account/order', 'order_id=' . $result['order_id'], 'SSL')
                );  
            }
    
        }
    

    在 account.tpl 中添加此代码

          <div id="resent_order" class="recent_order">
                <a style="float:right; margin-bottom:15px;" href="<?php echo $manage_order; ?>" class="button">Pending orders</a>
    <h4>Recent Order</h4>
                    <ul style="clear:both;">
                    <?php if( isset($orders) && count($orders > 0 ) ){ 
    
                       foreach ($orders as $order) { ?>
                        <li>
                        <div><strong>Order:#</strong><?php echo $order['order_id']; ?></div>
                        <div><strong>Date:</strong> <?php echo $order['date_added']; ?></div>
                        <div><strong>Amount:</strong> <?php echo $order['total']; ?></div>
                        <div><strong>Status:</strong> <?php echo $order['status']; ?></div>
                        <div class="editPan"><a class="" title="Edit" href="<?php echo $order['href']; ?>">Edit</a></div>
                        </li>
    
                    <?php }   ?>
    
                    <?php }else{?> <li>You have no pending orders.</li><?php }  ?>
    
    
                    </ul>
    
                </div>
    

    【讨论】:

    • 非常感谢您的友好回答。这里有些问题。它在没有 " if( $result['status'] =! 5) " 的情况下工作。如果我把这个结果只显示“你没有最近的订单”。如果我不使用“ if( $result['status'] =! 5)” 它会显示所有订单。知道如何解决这个问题。
    • 在查询中设置限制 0,5 或 0,10
    猜你喜欢
    • 2017-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-08
    • 1970-01-01
    • 1970-01-01
    • 2017-05-12
    • 1970-01-01
    相关资源
    最近更新 更多