Post by nightwing » Sun Aug 09, 2020 3:36 am

Hello Team,
I would like to display the percentage of sales from each location in the tooltip on the map when you hover. I am using 3.0.3.2.
This should be

Code: Select all

current number of orders for the location / total number of completed orders across the store * 100
ocmod could be used:

Code: Select all

	
<file path="admin/view/template/extension/dashboard/map_info.twig">
<operation error="log">
<search><![CDATA[	label.html('<strong>' + label.text() + '</strong><br />' + '{{ text_order }} ' + json[code]['total'] + '<br />' + '{{ text_sale }} ' + json[code]['amount']);]]></search>
<add position="replace"><![CDATA[label.html('<strong>' + label.text() + '</strong><br />' + '{{ text_order }} ' + json[code]['total'] + '<br />' + '{{ text_sale }} ' + json[code]['amount']  <br> CALCULATION HERE );]]></add>
</operation>
</file>
In

Code: Select all

admin/view/template/extension/dashboard/map_info.twig

We could add the calculation at the end, I just cant figure out how to gather the data on the total orders, I already have the orders for the current location here

Code: Select all

+ json[code]['total']
Thanks

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 » Wed Aug 12, 2020 9:35 pm

Anyone able to shed some light on this one? I am still stuck.

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 » Wed Aug 12, 2020 10:17 pm

you have to get the total orders in the controller admin/controller/extension/dashboard/map.php function map and add that to the returned json record.
currently that function returns an array with the total and amount per iso code.

Code: Select all

			$json[strtolower($result['iso_code_2'])] = array(
				'total'  => $result['total'],
				'amount' => $this->currency->format($result['amount'], $this->config->get('config_currency'))
			);

just invoke the function to get the total orders, I believe there is such a function somewhere.
then add

Code: Select all

$json['total'] = that total;
after the code above then you can access that value json['total'] in your twig file.

or you can change this in the twig file:

Code: Select all

		success: function(json) {
			data = [];
			
			for (i in json) {
				data[i] = json[i]['total'];
			}

to

Code: Select all

		success: function(json) {
			data = [];
			total = 0;
			
			for (i in json) {
				data[i] = json[i]['total'];
				total = total + parseInt(data[i]);
			}

and which sums up the individual totals and use that total.

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 » Wed Aug 12, 2020 11:23 pm

letxobnav, thank you, I will test and get back to you!
letxobnav wrote:
Wed Aug 12, 2020 10:17 pm
you have to get the total orders in the controller admin/controller/extension/dashboard/map.php function map and add that to the returned json record.
currently that function returns an array with the total and amount per iso code.

Code: Select all

			$json[strtolower($result['iso_code_2'])] = array(
				'total'  => $result['total'],
				'amount' => $this->currency->format($result['amount'], $this->config->get('config_currency'))
			);

just invoke the function to get the total orders, I believe there is such a function somewhere.
then add

Code: Select all

$json['total'] = that total;
after the code above then you can access that value json['total'] in your twig file.

or you can change this in the twig file:

Code: Select all

		success: function(json) {
			data = [];
			
			for (i in json) {
				data[i] = json[i]['total'];
			}

to

Code: Select all

		success: function(json) {
			data = [];
			total = 0;
			
			for (i in json) {
				data[i] = json[i]['total'];
				total = total + parseInt(data[i]);
			}

and which sums up the individual totals and use that 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

Who is online

Users browsing this forum: No registered users and 27 guests