Post by WebyxStudio » Tue Aug 13, 2024 7:44 pm

Hello,

I've tried to add telephone and city into last orders but it doesn't show the details, it show the columns but not the customer city or phone
The question is Why I'm not receiving the details from customers here is screenshot ??? :
https://prnt.sc/0Hcfd6nBKuTX

I've add to file recent.php :

Code: Select all

		foreach ($results as $result) {
			$data['orders'][] = array(
				'order_id'   => $result['order_id'],
				'customer'   => $result['customer'],
				'telephone'  => $result['telephone'],
				'shipping_city'    => $result['shipping_city'],
				'status'     => $result['order_status'],
				'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
				'total'      => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
				'view'       => $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $result['order_id'], true),
			);
		}

And also add to recent to recent_info.twig :

Code: Select all

      <thead>
        <tr>
          <td class="text-right">{{ column_order_id }}</td>
          <td>{{ column_customer }}</td>
          <td>{{ column_status }}</td>
          <td>{{ column_telephone }}</td>
          <td>{{ column_city }}</td>
          <td>{{ column_date_added }}</td>
          <td class="text-right">{{ column_total }}</td>
          <td class="text-right">{{ column_action }}</td>
        </tr>
      </thead>
      <tbody>
        {% if orders %}
        {% for order in orders %}
        <tr>
          <td class="text-right">{{ order.order_id }}</td>
          <td>{{ order.customer }}</td>
          <td>{{ order.status }}</td>
          <td>{{ order.telephone }}</td>
          <td>{{ order.city }}</td>
          <td>{{ order.date_added }}</td>
          <td class="text-right">{{ order.total }}</td>
          <td class="text-right"><a href="{{ order.view }}" data-toggle="tooltip" title="{{ button_view }}" class="btn btn-info"><i class="fa fa-eye"></i></a></td>
        </tr>
Last edited by WebyxStudio on Wed Aug 14, 2024 4:39 am, edited 1 time in total.

Newbie

Posts

Joined
Tue Mar 19, 2024 3:10 pm

Post by softmonke » Wed Aug 14, 2024 4:01 am

For latest orders in "extension/dashboard/recent.php", you can see that the orders are pulled via the "getOrders" function in "model/sale/order.php". If you open up "order.php" in "admin/model/sale", you can see the following query being used to pull the orders:

Code: Select all

$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
From the SQL query, you can see that it doesn't select telephone or city. So you will have to add those columns in so that the query can return the results you want. Something like the below query, where you can see that I've added "o.telephone" and "o.shipping_city".

Code: Select all

$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.telephone, o.shipping_city, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";

Check out our ever-growing list of extensions for OpenCart here.
Some useful extensions for a better admin experience: Image File Manager ProDrag & Drop Sort Order

Reach out to us at hello@softmonke.com for your OpenCart web development needs or feedback for our extensions.


User avatar
Active Member

Posts

Joined
Tue May 23, 2023 4:42 am


Post by WebyxStudio » Wed Aug 14, 2024 4:39 am

Yeap, that work perfectly.
Thank you 8)
softmonke wrote:
Wed Aug 14, 2024 4:01 am
For latest orders in "extension/dashboard/recent.php", you can see that the orders are pulled via the "getOrders" function in "model/sale/order.php". If you open up "order.php" in "admin/model/sale", you can see the following query being used to pull the orders:

Code: Select all

$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
From the SQL query, you can see that it doesn't select telephone or city. So you will have to add those columns in so that the query can return the results you want. Something like the below query, where you can see that I've added "o.telephone" and "o.shipping_city".

Code: Select all

$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.telephone, o.shipping_city, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";

Newbie

Posts

Joined
Tue Mar 19, 2024 3:10 pm
Who is online

Users browsing this forum: No registered users and 18 guests