Post by Cue4cheap » Sun Jan 07, 2024 12:11 am

OC 2.3.0.2.
Sorry not feeling well and I had a quick change that I thought was simple but it isn't working (brain fog?).
I would like to make a change to the checkout.tpl file.
I was trying to add a small amount of code only if the square payment extension was enabled. So I put this code in the checkout.tpl file.

<?php if ($this->config->get('squareup_status')) {
Echo 'Square is in testing mode only - please don't use.';
} ?>

It gives me "Call to a member function get() on null"

What am I missing?
Mike
Last edited by Cue4cheap on Mon Jan 08, 2024 10:24 pm, edited 2 times in total.

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by straightlight » Sun Jan 07, 2024 1:13 am

Cue4cheap wrote:
Sun Jan 07, 2024 12:11 am
OC 2.3.0.2.
Sorry not feeling well and I had a quick change that I thought was simple but it isn't working (brain fog?).
I would like to make a change to the checkout.tpl file.
I was trying to add a small amount of code only if the square payment extension was enabled. So I put this code in the checkout.tpl file.

<?php if ($this->config->get('squareup_status')) {
Echo 'Square is in testing mode only - please don't use.';
} ?>

It gives me "Call to a member function get() on null"

What am I missing?
Mike
You could change the extension title directly from the language file instead of adding a code to display a text in the checkout.tpl file.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by Cue4cheap » Sun Jan 07, 2024 1:21 am

straightlight wrote:
Sun Jan 07, 2024 1:13 am
Cue4cheap wrote:
Sun Jan 07, 2024 12:11 am
OC 2.3.0.2.
Sorry not feeling well and I had a quick change that I thought was simple but it isn't working (brain fog?).
I would like to make a change to the checkout.tpl file.
I was trying to add a small amount of code only if the square payment extension was enabled. So I put this code in the checkout.tpl file.

<?php if ($this->config->get('squareup_status')) {
Echo 'Square is in testing mode only - please don't use.';
} ?>

It gives me "Call to a member function get() on null"

What am I missing?
Mike
You could change the extension title directly from the language file instead of adding a code to display a text in the checkout.tpl file.
Understood but wish to use that example for other things later so would like a working example.
Thank you,
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by straightlight » Sun Jan 07, 2024 1:27 am

Cue4cheap wrote:
Sun Jan 07, 2024 1:21 am
straightlight wrote:
Sun Jan 07, 2024 1:13 am
Cue4cheap wrote:
Sun Jan 07, 2024 12:11 am
OC 2.3.0.2.
Sorry not feeling well and I had a quick change that I thought was simple but it isn't working (brain fog?).
I would like to make a change to the checkout.tpl file.
I was trying to add a small amount of code only if the square payment extension was enabled. So I put this code in the checkout.tpl file.

<?php if ($this->config->get('squareup_status')) {
Echo 'Square is in testing mode only - please don't use.';
} ?>

It gives me "Call to a member function get() on null"

What am I missing?
Mike
You could change the extension title directly from the language file instead of adding a code to display a text in the checkout.tpl file.
Understood but wish to use that example for other things later so would like a working example.
Thank you,
Mike
By creating an event from the checkout page, that can also be accomplished by validating the shipping_address of the session_data or by editing the extension model title with IF conditions as per the above and one you can add. This can be achieved in multiple ways.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by Cue4cheap » Sun Jan 07, 2024 2:31 am

Shouldn't what I have work though on the template file?

I'll check back later days when I'm feeling better.
Thanks,
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by straightlight » Sun Jan 07, 2024 3:36 am

Cue4cheap wrote:
Sun Jan 07, 2024 2:31 am
Shouldn't what I have work though on the template file?

I'll check back later days when I'm feeling better.
Thanks,
Mike

Code: Select all

<?php if ($this->config->get('payment_squareup_status')) {
echo '...';
?>

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by Cue4cheap » Mon Jan 08, 2024 2:57 am

straightlight wrote:
Sun Jan 07, 2024 3:36 am

Code: Select all

<?php if ($this->config->get('payment_squareup_status')) {
echo '...';
?>
I'm a bit better but that code didn't work for me in the .tpl file so I did it the more proper way, in the controller file.
Thank you for your input.
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by paulfeakins » Mon Jan 08, 2024 6:29 pm

Cue4cheap wrote:
Mon Jan 08, 2024 2:57 am
I'm a bit better but that code didn't work for me in the .tpl file so I did it the more proper way, in the controller file.
So you knew the proper way to do it but decided to try and hack it? Tut tut.

TPL files don't have access to anything other than the data passed to them from the controller, that's why it didn't work.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Cue4cheap » Mon Jan 08, 2024 10:12 pm

paulfeakins wrote:
Mon Jan 08, 2024 6:29 pm
Cue4cheap wrote:
Mon Jan 08, 2024 2:57 am
I'm a bit better but that code didn't work for me in the .tpl file so I did it the more proper way, in the controller file.
So you knew the proper way to do it but decided to try and hack it? Tut tut.

TPL files don't have access to anything other than the data passed to them from the controller, that's why it didn't work.
Yeah.... sometimes you do something that should be the fast way and when it doesn't work it, drives you crazy no matter if you know the other way to do it.
Plus it was supposed to just be for one store, that has low traffic, and since that store is the only one using that template I figured 'easy way to isolate'.
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am
Who is online

Users browsing this forum: No registered users and 59 guests