Post by Majnoon » Mon Jan 17, 2022 12:05 pm

Hi guys i am having this notice in my error log

Code: Select all

PHP Notice: Undefined index: api_token in /home/gqvxzdmy/public_html/glowkl/storage/modification/catalog/controller/api/order.php on line 814
Line 814 is as :
if (!isset($this->session->data['api_token']) && $this->session->data['api_token']) {
and full code is as this

Code: Select all

public function jntHistory() {
        		$this->load->language('api/order');
        
        		$json = array();
        
        		if (!isset($this->session->data['api_token']) && $this->session->data['api_token']) {
        			$json['error'] = $this->language->get('error_permission');
        		} else {
        			// Add keys for missing post vars
        			$keys = array(
        				'order_status_id',
        				'notify',
        				'override',
        				'comment'
        			);
        
        			foreach ($keys as $key) {
        				if (!isset($this->request->post[$key])) {
        					$this->request->post[$key] = '';
        				}
        			}

Active Member

Posts

Joined
Fri Feb 05, 2021 8:29 pm

Post by by mona » Mon Jan 17, 2022 12:37 pm

It means that data[‘api_token'] has not been defined.
Since this is an extension you should contact the developer to fix.

The extension is something to do with your order history.

It is only a notice, but it should be defined.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by xxvirusxx » Mon Jan 17, 2022 3:15 pm

Majnoon wrote:
Mon Jan 17, 2022 12:05 pm

Code: Select all

storage/modification/catalog/controller/api/order.php on line 814
Majnoon wrote:
Mon Jan 17, 2022 12:05 pm

Code: Select all

public function jntHistory() {
Contact extension developer.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by Majnoon » Mon Jan 17, 2022 3:57 pm

by mona wrote:
Mon Jan 17, 2022 12:37 pm
It means that data[‘api_token'] has not been defined.
Since this is an extension you should contact the developer to fix.

The extension is something to do with your order history.

It is only a notice, but it should be defined.
Thanks its not a paid extension its a free extension and developer is not replying.
So how can i define this api_token

Active Member

Posts

Joined
Fri Feb 05, 2021 8:29 pm

Post by xxvirusxx » Mon Jan 17, 2022 4:02 pm

Majnoon wrote:
Mon Jan 17, 2022 3:57 pm
So how can i define this api_token

Code: Select all

$data['api_token'] = .........

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by Majnoon » Mon Jan 17, 2022 5:34 pm

xxvirusxx wrote:
Mon Jan 17, 2022 4:02 pm

Code: Select all

$data['api_token'] = .........
Ok in the whole place api_token been use for 10 times:

Code: Select all

<operation>
        	<search><![CDATA[<td class="text-right">{{ column_action }}</td>]]></search>
        	<add position="before"><![CDATA[
			<td>J&T Tracking Number<input type="hidden" name="api_token" value="{{ api_token }}" /></td>
			<td>Parcel Status</td>
			]]></add>
        </operation>
And this:

Code: Select all

// NEW CODE API login
            		$catalog = $this->request->server['HTTPS'] ? HTTPS_CATALOG : HTTP_CATALOG;
            
            		if ($this->request->request['api_token']) {
            			$api_token = $this->request->request['api_token'];
            		} else {
            			$api_token = '';
            		}
and here:

Code: Select all

//NEW CODE
									$url = $catalog.'index.php?route=api/order/jntHistory&api_token='.$api_token.'&store_id='.$order_info['store_id'].'&order_id='.$order_id;
									$post = array(
									    'order_status_id' => 3, //shipped order_status_id
									    'notify' => '1',
									    'override' => '0',
									    'append' => '0',
									    'comment' => 'J&T Tracking Number: '.$awb
									);
                					$ch = curl_init();
                					curl_setopt($ch, CURLOPT_URL, $url);
                					curl_setopt($ch, CURLOPT_POST, TRUE);
                					curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
                					curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
                					$res = curl_exec($ch);
                					curl_close($ch);
                					//NEW CODE END
And last this one:

Code: Select all

if (!isset($this->session->data['api_token']) && $this->session->data['api_token']) {
        			$json['error'] = $this->language->get('error_permission');
        		} else {
So where would go this

Code: Select all

$data['api_token'] = .........
???

Active Member

Posts

Joined
Fri Feb 05, 2021 8:29 pm

Post by JNeuhoff » Mon Jan 17, 2022 5:57 pm

This line doesn't make sense and is probably buggy:

Code: Select all

if (!isset($this->session->data['api_token']) && $this->session->data['api_token']) {
Perhaps it is meant to be:

Code: Select all

if (!(isset($this->session->data['api_token']) && $this->session->data['api_token'])) {
or

Code: Select all

if (isset($this->session->data['api_token']) && $this->session->data['api_token']) {
?

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Majnoon » Mon Jan 17, 2022 11:48 pm

JNeuhoff wrote:
Mon Jan 17, 2022 5:57 pm
This line doesn't make sense and is probably buggy:

Code: Select all

if (!isset($this->session->data['api_token']) && $this->session->data['api_token']) {
Perhaps it is meant to be:

Code: Select all

if (!(isset($this->session->data['api_token']) && $this->session->data['api_token'])) {
or

Code: Select all

if (isset($this->session->data['api_token']) && $this->session->data['api_token']) {
?
Thanks for reply mate:
The whole code for this line is like this:

Code: Select all

<file path="catalog/controller/api/order.php">
    	<operation>
    		<search><![CDATA[	public function history() {]]></search>
    		<add position="before"><![CDATA[
    		public function jntHistory() {
        		$this->load->language('api/order');
        
        		$json = array();
        
        		if (!isset($this->session->data['api_token']) && $this->session->data['api_token']) {
        			$json['error'] = $this->language->get('error_permission');
        		} else {
        			// Add keys for missing post vars
        			$keys = array(
        				'order_status_id',
        				'notify',
        				'override',
        				'comment'
        			);
        
        			foreach ($keys as $key) {
        				if (!isset($this->request->post[$key])) {
        					$this->request->post[$key] = '';
        				}
        			}
        
        			$this->load->model('checkout/order');
        
        			if (isset($this->request->get['order_id'])) {
        				$order_id = $this->request->get['order_id'];
        			} else {
        				$order_id = 0;
        			}
        
        			$order_info = $this->model_checkout_order->getOrder($order_id);
        
        			if ($order_info) {
        				$this->model_checkout_order->addOrderHistory($order_id, $this->request->post['order_status_id'], $this->request->post['comment'], $this->request->post['notify'], $this->request->post['override']);
        
        				$json['success'] = $this->language->get('text_success');
        			} else {
        				$json['error'] = $this->language->get('error_not_found');
        			}
        		}
        
        		$this->response->addHeader('Content-Type: application/json');
        		$this->response->setOutput(json_encode($json));
        	}
    		]]></add>
    	</operation>
    </file>
May be you can see where is from php notice coming.
Thanks

Active Member

Posts

Joined
Fri Feb 05, 2021 8:29 pm

Post by JNeuhoff » Mon Jan 17, 2022 11:53 pm

In that case it looks like it's meant to be

Code: Select all

if (!(isset($this->session->data['api_token']) && $this->session->data['api_token'])) {

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Majnoon » Tue Jan 18, 2022 10:16 am

JNeuhoff wrote:
Mon Jan 17, 2022 11:53 pm
In that case it looks like it's meant to be

Code: Select all


if (!(isset($this->session->data['api_token']) && $this->session->data['api_token'])) {
Thanks will try and let you know if still got notice coming up.

Active Member

Posts

Joined
Fri Feb 05, 2021 8:29 pm
Who is online

Users browsing this forum: No registered users and 180 guests