Post by nightwing » Sat Aug 08, 2020 1:58 am

Hello,

I am creating a custom map for my country using opencart 3.0.3.2, inspired by an extension built by Opencart Brazil. So far I am able to see the map and all the regions, however, when I hover over the regions I see their names, but no sale information comes up in the tooltip. I tested by creating a few orders, doesn't work. Please see the model file as I believe this issue lies here:

Code: Select all

<?php
class ModelExtensionDashboardCustomMap extends Model {
	public function getTotalOrdersByZone() {
		$implode = array();

		if (is_array($this->config->get('config_complete_status'))) {
			foreach ($this->config->get('config_complete_status') as $order_status_id) {
				$implode[] = (int)$order_status_id;
			}
		}

		if ($implode) {
			$query = $this->db->query("SELECT COUNT(*) AS total, SUM(o.total) AS amount, z.code  FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "zone` z ON (o.payment_zone_id = z.zone_id) WHERE o.order_status_id IN('" . (int)implode(',', $implode) . "') AND o.payment_country_id = '106' GROUP BY o.payment_zone_id");

			return $query->rows;
		} else {
			return array();
		}
	}
}
Could someone kindly point out where I may have went wrong? Thanks
Last edited by nightwing on Tue Aug 18, 2020 1:39 am, edited 1 time in total.

Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing


Active Member

Posts

Joined
Tue Nov 05, 2019 11:08 pm


Post by nightwing » Sat Aug 08, 2020 3:02 am

I would also like to add all previous orders to the map when I reinstall, I believe it will add only orders after the extension is installed by default.

Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing


Active Member

Posts

Joined
Tue Nov 05, 2019 11:08 pm


Post by letxobnav » Sat Aug 08, 2020 3:49 pm

Could someone kindly point out where I may have went wrong? Thanks
All this function does is get some information from the order database for orders having status in the "complete set".

Why would you think that is where the issue is?
Does it not return anything or not what you expected?

if I put a query somewhere and it does not do what I think it should, I just print the generated sql to the error log, copy it and run it in my sql manager.
that is why I always create the sql separate first:

Code: Select all

$sql = "SELECT COUNT(*) AS total, SUM(o.total) AS amount, z.code  FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "zone` z ON (o.payment_zone_id = z.zone_id) WHERE o.order_status_id IN('" . (int)implode(',', $implode) . "') AND o.payment_country_id = '106' GROUP BY o.payment_zone_id";
then use it in the function:

Code: Select all

$query = $this->db->query($sql);
so I can add a troubleshooting command in there:

Code: Select all

$this->log-write($sql);
to see what sql is actually executed.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by nightwing » Sun Aug 09, 2020 2:50 am

Hey letxobnav, I ended up finding another extension that replaced world map using ocmod, so I modified that, added my map.js file and got that working with the help of straightlight.
Thanks for the help though!
letxobnav wrote:
Sat Aug 08, 2020 3:49 pm
Could someone kindly point out where I may have went wrong? Thanks
All this function does is get some information from the order database for orders having status in the "complete set".

Why would you think that is where the issue is?
Does it not return anything or not what you expected?

if I put a query somewhere and it does not do what I think it should, I just print the generated sql to the error log, copy it and run it in my sql manager.
that is why I always create the sql separate first:

Code: Select all

$sql = "SELECT COUNT(*) AS total, SUM(o.total) AS amount, z.code  FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "zone` z ON (o.payment_zone_id = z.zone_id) WHERE o.order_status_id IN('" . (int)implode(',', $implode) . "') AND o.payment_country_id = '106' GROUP BY o.payment_zone_id";
then use it in the function:

Code: Select all

$query = $this->db->query($sql);
so I can add a troubleshooting command in there:

Code: Select all

$this->log-write($sql);
to see what sql is actually executed.

Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing


Active Member

Posts

Joined
Tue Nov 05, 2019 11:08 pm

Who is online

Users browsing this forum: No registered users and 20 guests