Help with some deprecated code

This forum is for general questions about extensions for Joomla! 3.x.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
rodfarrell77
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Dec 06, 2016 1:48 am

Help with some deprecated code

Post by rodfarrell77 » Tue Dec 06, 2016 1:57 am

I'm upgrading an old unsupported extension as a self taught coder and need some help on this function. JResponse is deprecated and JApplicationWeb should be used. This is the old function below - how would this be written with JApplicationWeb?

Code: Select all

function onAfterRender()
	{
if($this->okToSend)
		{
			$body = JResponse::getBody();
			$pos = strpos($body, 'hikashop_banktransfer_end');
			$replace = $this->contents.'Your order is now complete.<br/>Thank you for your purchase.';			
			JResponse::setBody($body);

		}
		}
		

 
itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4026
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: Help with some deprecated code

Post by itoctopus » Tue Dec 06, 2016 3:34 am

All you need to do is replace JResponse with JApplicationWeb. So you will need to replace:

Code: Select all

$body = JResponse::getBody();
with:

Code: Select all

JApplicationWeb::getBody();
and

Code: Select all

JResponse::setBody($body);
with

Code: Select all

JApplicationWeb::setBody();
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter

rodfarrell77
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Dec 06, 2016 1:48 am

Re: Help with some deprecated code

Post by rodfarrell77 » Tue Dec 06, 2016 3:39 am

Thanks for the quick and very clear reply. That was my initial thought too but it looked to simplistic and I thought I must have been missing something.

 

Locked

Return to “Extensions for Joomla! 3.x”