Post by OCdevWizard » Tue Oct 17, 2017 4:51 pm

Hi
I`m extension developer for opencart.
The right side menu ( https://www.uploady.com/download/iS9_uS ... xTZkNkhdYq ) on the account page is not good for me, cuz I need to check Order ID.
To resolve this issue I made JS code, this code add Transaction and Sale link to right side menu:

Code: Select all

var token = get_url_value($('.visible-xs:eq(0) > a').attr('href'), 'member_token');

if ($('#opencart-transaction-link').length == 0) {
	$('#account-menu .panel-default:eq(1)').append('<a id="opencart-transaction-link" href="https://www.opencart.com/index.php?route=account/transaction&member_token='+token+'" class="list-group-item">Transactions</a>');
}

if ($('#opencart-sale-link').length == 0) {
	$('#account-menu .panel-default:eq(1)').append('<a id="opencart-sale-link" href="https://www.opencart.com/index.php?route=account/sale&member_token='+token+'" class="list-group-item">Sales</a>');
}
$('#opencart-sale-link').remove();

function get_url_value(url, type) {
  var value = 0;
  var arr = url.split("&");

  for(var i = 0; i < arr.length; i++){
    var value = arr[i].split("=");

    if (value[0] === type) {
      return value[1];
    }
  }
}
You can copy and execute this JS code with the help of browser extension.
At result you get this: https://www.uploady.com/download/fL~f~5 ... fZCXzJRkY6

OCdevWizard - OpenCart extensions and modules.


User avatar
Active Member

Posts

Joined
Fri Jan 16, 2015 5:37 pm
Location - Eastern Europe

Post by straightlight » Wed Oct 18, 2017 8:07 am

A similarity of the provided code can already be found in catalog/view/javascript/common.js file:

Code: Select all

function getURLVar(key) {
	var value = [];

	var query = String(document.location).split('?');

	if (query[1]) {
		var part = query[1].split('&');

		for (i = 0; i < part.length; i++) {
			var data = part[i].split('=');

			if (data[0] && data[1]) {
				value[data[0]] = data[1];
			}
		}

		if (value[key]) {
			return value[key];
		} else {
			return '';
		}
	}
}

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 10 guests