Post by prosenjeet123 » Tue Feb 19, 2019 8:37 pm

I want to show product details/get all products images names inside an order in order history, to achieve the same I have inserted my code inside a result loop just like the below code but it is fetching only one product and that same product is visible to each orders.

1.catalog/controller/account/order.php

Code: Select all

public function index() {
...
foreach ($results as $result) {
...

//for product for loop

            $order_info = $this->model_account_order->getOrder($result['order_id']);

            if ($order_info) {
            $this->load->model('catalog/product');
            $this->load->model('tool/upload');



            // Products


            $data['products'] = array();

            $products = $this->model_account_order->getOrderProducts($result['order_id']);

            foreach ($products as $product) {
                $option_data = array();

                $options = $this->model_account_order->getOrderOptions($result['order_id'], $product['order_product_id']);

                foreach ($options as $option) {
                    if ($option['type'] != 'file') {
                        $value = $option['value'];
                    } else {
                        $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);

                        if ($upload_info) {
                            $value = $upload_info['name'];
                        } else {
                            $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']);

                if ($product_info) {
                    $reorder = $this->url->link('account/order/reorder', 'order_id=' . $result['order_id'] . '&order_product_id=' . $product['order_product_id'], true);
                } else {
                    $reorder = '';
                }

                $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']),
                    'reorder'  => $reorder,
                    'return'   => $this->url->link('account/return/add', 'order_id=' . $result['order_id'] . '&product_id=' . $product['product_id'], true)
                );

                // Totals
                $data['totals'] = array();

                $totals = $this->model_account_order->getOrderTotals($result['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']),
                    );
                }




            }

            //end for loop of product
            }
}

2.order-list.twig SCREENSHOT HERE :
Image
3.Front Page( Order History) SCREESHOT :
Image

Newbie

Posts

Joined
Tue Feb 19, 2019 8:02 pm

Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm

Post by prosenjeet123 » Tue Feb 19, 2019 11:53 pm

Hi,
Thanks for the quick response, well i want to show product details in order history page of user not admin.

Thanks

Newbie

Posts

Joined
Tue Feb 19, 2019 8:02 pm

Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm

Post by prosenjeet123 » Wed Feb 20, 2019 12:32 am

The link you shared is for admin/invoice/order information(not order history which is different e.g when you click on order history the first page you can see is order history after clicking on view details it will take you to order info page, i want to show product details in order history)

I really appreciate your help dear but its not related to my subject i need help for order history page not order info page which comes after order history page/Order list page. I want to show product details like images quantity and all the other info inside each orders.

Let me know if you can help me with that. I am bit close to the solution but stuck in this part only.

Newbie

Posts

Joined
Tue Feb 19, 2019 8:02 pm

Post by xxvirusxx » Wed Feb 20, 2019 1:10 am

ok, so you need in Orders history list not Order Info

Why customers need this?

My Extensions | OC 3.0.3.1, 3.0.2.0, 2.3.0.2 with bugs fixed.


Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm

Post by prosenjeet123 » Wed Feb 20, 2019 1:42 am

xxvirusxx wrote:
Wed Feb 20, 2019 1:10 am
ok, so you need in Orders history list not Order Info

Why customers need this?
Well it's not a good practice users cant just decide by the product name before they click on "View order Details" in my point of view users must see the product image and other few details like images, size what he had ordered in the past before he clicks on any details. Even many Giant Ecom companies follow the same UI practice. Why would they waste users clicks if we can show the details in Order history only.

Newbie

Posts

Joined
Tue Feb 19, 2019 8:02 pm

Post by prosenjeet123 » Fri Feb 22, 2019 3:51 pm

prosenjeet123 wrote:
Tue Feb 19, 2019 8:37 pm
I want to show product details/get all products images names inside an order in order history, to achieve the same I have inserted my code inside a result loop just like the below code but it is fetching only one product and that same product is visible to each orders.

1.catalog/controller/account/order.php

Code: Select all

public function index() {
...
foreach ($results as $result) {
...

//for product for loop

            $order_info = $this->model_account_order->getOrder($result['order_id']);

            if ($order_info) {
            $this->load->model('catalog/product');
            $this->load->model('tool/upload');



            // Products


            $data['products'] = array();

            $products = $this->model_account_order->getOrderProducts($result['order_id']);

            foreach ($products as $product) {
                $option_data = array();

                $options = $this->model_account_order->getOrderOptions($result['order_id'], $product['order_product_id']);

                foreach ($options as $option) {
                    if ($option['type'] != 'file') {
                        $value = $option['value'];
                    } else {
                        $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);

                        if ($upload_info) {
                            $value = $upload_info['name'];
                        } else {
                            $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']);

                if ($product_info) {
                    $reorder = $this->url->link('account/order/reorder', 'order_id=' . $result['order_id'] . '&order_product_id=' . $product['order_product_id'], true);
                } else {
                    $reorder = '';
                }

                $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']),
                    'reorder'  => $reorder,
                    'return'   => $this->url->link('account/return/add', 'order_id=' . $result['order_id'] . '&product_id=' . $product['product_id'], true)
                );

                // Totals
                $data['totals'] = array();

                $totals = $this->model_account_order->getOrderTotals($result['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']),
                    );
                }




            }

            //end for loop of product
            }
}

2.order-list.twig SCREENSHOT HERE :
Image
3.Front Page( Order History) SCREESHOT :
Image
UPDATE: I got answer from member of dreamvention and he helped me to fix the issue follow the answer here:
https://stackoverflow.com/questions/547 ... redirect=1

Newbie

Posts

Joined
Tue Feb 19, 2019 8:02 pm
Who is online

Users browsing this forum: No registered users and 13 guests