• Resolved David Borrink

    (@davidborrink)


    I’m developing a commerce site where my client wants a PayPal button placed in the page. When I place the PayPal button code in a page or a post it gets messed/deleted in the visual editor, and has errors when used in “code” with the visual editor turned off.

    I’m installed runPHP to allow PHP code to be executed. I place the PayPal code in a document called ‘paypalbutton.php’ and place it in my theme folder. Then on the page/post where my client wants them placed, I put the following code in:

    <?php include(‘paypalbutton.php’); ?>

    And I get error messages about line numbers and such.

    Here’s where I’m wondering if I’m a newbie-error-guy. Can I place the PayPal script inside the .php file just as I get it from PayPal, or do I need to add some php tags around it in the file?

    To explain one other bit of info: I’ve removed the post “loop” from index.php to create a static page for a front page. That’s one location they want the button. The other is on a page template. These are all static pages, but I have a post page using a modified index.php to act like a static page but without sidebars.

    Any ideas or tips about my .php file usage?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Thread Starter David Borrink

    (@davidborrink)

    Oh, and currently there are working PayPal buttons in the sidebar. No problem there, but my client wants them in the page, not in the sidebar.

    That’s why I’m trying to use runPHP. I know this plug in works. I tried a sample bit of text and it showed up fine. I just want to execute a PayPal button from a fixed file so that the post or page doesn’t mess it up.

    Thread Starter David Borrink

    (@davidborrink)

    Has anyone been able to put PayPal button in posts or pages? I’d like to know. It looks from these forums that few have had success.

    harknell

    (@harknell)

    One technique that can work is using my AWSOM News Announcement plugin. Instead of using it as a news announcement area you could instead use it’s page/post code feature using the code %%awsomnews%% to have the block only appear in a post or page where you want it–then place the paypal code in the news block manage page interface. I’ve tried it out on my dev site and it worked. You will want to disable the default location in the Manage News admin page so that only the custom locations appear.

    Jeremy Clark

    (@jeremyclark13)

    David for your original question the file should look something like this.

    <?php
    echo 'Paypal Code here';
    ?>

    Make sure to include both of the ‘ single quotes and the semicolon on the end.

    Thread Starter David Borrink

    (@davidborrink)

    Jeremy,

    I just placed that line of code in the post and when I tested it, the phrase “paypalbutton.php” showed up on the page.

    I’m wondering if you’re suggesting that I pasted the entire PayPal code in between the single quotes, right in the post instead of accessing a separate php file.

    Thread Starter David Borrink

    (@davidborrink)

    And I replaced your ‘Paypal code here’ text with ‘paypalbutton.php’.

    Thread Starter David Borrink

    (@davidborrink)

    I just tried the code in between the single quotes and got this:

    Parse error: parse error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /cashspiracy/wp-content/plugins/runPHP/runPHP.php(410) : eval()’d code on line 4

    Jeremy Clark

    (@jeremyclark13)

    I was referring to the paypalbutton.php file and how it should look. Then you can call it the way you were using <?php include..

    Thread Starter David Borrink

    (@davidborrink)

    Harknell, your plug in sounds intriguing. I’ll check your site and see what your plug in can do. Thanks!

    Thread Starter David Borrink

    (@davidborrink)

    Okay,

    Thanks, Jeremy. I’ll try that and report back.

    Thread Starter David Borrink

    (@davidborrink)

    Jeremy,

    I gave it a try and it did not work. I pasted my PayPal code inside the tags in the php file like you suggested, put the php include tag back in my page, and recieved the following error:

    Warning: Unknown(paypalbutton.php): failed to open stream: No such file or directory in /home/content/j/o/h/johnvasronllc/html/cashspiracy/wp-content/plugins/runPHP/runPHP.php(410) : eval()’d code on line 1

    Warning: Unknown(paypalbutton.php): failed to open stream: No such file or directory in /home/content/j/o/h/johnvasronllc/html/cashspiracy/wp-content/plugins/runPHP/runPHP.php(410) : eval()’d code on line 1

    Warning: (null)(): Failed opening ‘paypalbutton.php’ for inclusion (include_path=’.:/usr/local/lib/php’) in /home/content/j/o/h/johnvasronllc/html/cashspiracy/wp-content/plugins/runPHP/runPHP.php(410) : eval()’d code on line 1

    It looked to me like the error was asking for the php file inside the runPHP folder in the plugins, but that gave me a blank content area with a different message.

    Thread Starter David Borrink

    (@davidborrink)

    That is… after I placed the “paypalbutton.php” file in the runPHP folder and tried that, too.

    Thread Starter David Borrink

    (@davidborrink)

    Hacknell,

    I installed your AWSOM news plugin and entered the PayPal button code in the window. I added the %%awsomnews%% tag on the page and found a peculiar thing: the PayPal code showed up on my page as code, but when I went back to your news editor, the PayPal button appeared!

    So something is working right, but it’s not showing up on my actual page.

    You said you tried this in your dev site, did you add any tags around the PayPal code or did you just place the code as is in the window?

    harknell

    (@harknell)

    I placed the code as it was received from paypal directly into my page. I suspect that you might have a conflict going on with something– could you try the following: disable all other plugins besides AWSOM news and switch to the WordPress default theme and see if the paypal button appears.

    One side note: set the visual editor in AWSOM news to disabled, then add your paypal code. Using the visual editor will probably cause it to not appear properly. Basically never use the visual editor when entering html code, or if the code is already in the field.

    Thread Starter David Borrink

    (@davidborrink)

    SUCCESS!!! THANK YOU!!!!!!!!!!

    I turned off the visual editor option in AWSOM news, and I also deactivated the runPHP plugin.

    There was one glitch that I worked out and perhaps this will help anyone else trying this:

    When I clicked on the PayPal button, I got a PayPal error message that it couldn’t decipher the encryption. Well, at least the button got me to PayPal. Yay!

    So I viewed the source of the page and copied the form code into a TextEdit window, and also copied the form code from my original file from PayPal. Fortunately my windows were of equal width so I was able to scan down the two pages and see if the code was the same (the characters at the end of each line were identical so I knew I was seeing the same long encryption code).

    There!… Right at the end were a couple of extra <br> codes in the last section right before </form>. I took them out in the AWSOM news editor, saved it, refreshed my page and clicked the PayPal button.

    TA-DA! Right to my client’s checkout page!

    I threw my arms in the air, “YESS!!!!!”

    This has been quite a challenge, but your plugin saved my project, and this has been a critical project for the future of my web development part of my business.

    Thank you, Thank you, Thank you!

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘runPHP plugin used to add a PayPal button to a page or post’ is closed to new replies.