Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Adding a PayPal donate button


Reply

12 Posts   4910 Views

Avatar
Briohny

7 October 2008 at 3:37am (Last edited: 7 October 2008 3:37am), Community Member, 199 Posts

What about if you have different paypal buttons? i.e. buttons with different payment amounts.

I thought that perhaps the following code would work, but it didn't. :(

function Content() {
   return str_replace('$PayPal1', $this->PayPal1(), $this->Content);
   return str_replace('$PayPal2', $this->PayPal2(), $this->Content);
   }

   function PayPal1() {
   return 'replace me with paypal form html here!';
   }
   
   function PayPal2() {
   return 'replace me with paypal form html here!';
}

Any thoughts?

Avatar
Briohny

11 October 2008 at 2:57am Community Member, 199 Posts

bump bump :)

Any ideas anyone? I just want to be able to have a few different paypal buttons throughout the site.

Cheers,
Briohny

Avatar
banal

11 October 2008 at 3:26am Community Member, 901 Posts

@Briohny
A "return" statement always leaves the method. That means your custom Content() method will finish after the first return statement.

You should write something like that:

function Content() {
$tmp = str_replace('$PayPal1', $this->PayPal1(), $this->Content);
return str_replace('$PayPal2', $this->PayPal2(), $tmp);
}

Avatar
Briohny

12 October 2008 at 12:29am (Last edited: 12 October 2008 12:39am), Community Member, 199 Posts

Thanks that worked for two different buttons... what if i have more buttons though?