Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1484406

    I often use Paypal to generate a code and then paste it into my website on the code tab. However, recently somehting has been scrambling the code such that it no longer produces the desired result. I’ve copy and pasted the code into Word and it copies as it should. However when I paste it into my Enfold themed page it adds extra code which I then have to manually delete. What’s going on here?:
    Here’s the relevant part of the code as generated by Paypal:
    <table>
    <tr>
    <td>
    <input type=”hidden” name=”on0″ value=”Options for Brondanw & Nantclwyd only”/>
    Options for Brondanw & Nantclwyd only
    </td>
    </tr>
    <tr>
    <td>
    <select name=”os0″>
    <option value=”Member”>
    Member £17.00 GBP
    </option>
    <option value=”Guest”>
    Guest £19.00 GBP
    </option>
    <option value=”2 Members”>
    2 Members £34.00 GBP
    </option>
    <option value=”1 Member + 1 Guest”>
    1 Member + 1 Guest £36.00 GBP
    </option>
    <option value=”Child under 16″>
    Child under 16 £10.00 GBP
    </option>
    </select>
    </td>
    </tr>
    </table>

    And after pasting it into my website:
     
    <table>
    <tbody>
    <tr>
    <td><input name=”on0″ type=”hidden” value=”Options for Brondanw & Nantclwyd only” />
    Options for Brondanw & Nantclwyd only</td>
    </tr>
    <tr>
    <td>
    <select name=”os0″>
    <option value=”Member”>Member £17.00 GBP</option>
    </select>

    <select name=”os0″>
    <option value=”Guest”>Guest £19.00 GBP</option>
    </select>

    <select name=”os0″>
    <option value=”2 Members”>2 Members £34.00 GBP</option>
    </select>

    <select name=”os0″>
    <option value=”1 Member + 1 Guest”>1 Member + 1 Guest £36.00 GBP</option>
    </select>

    <select name=”os0″>
    <option value=”Child under 16″>Child under 16 £10.00 GBP</option>
    </select></td>
    </tr>
    </tbody>
    </table>

    See all those <select name = “os0”> lines before each button choice? How did they get there and how can I prevent them from being added?

    • This topic was modified 1 month ago by FFAlan.
    #1484420

    Hey FFAlan,
    Try using a plain text editor like notepad, VScode, or notepad++, not Word.

    Best regards,
    Mike

    #1484436

    Not sure what you mean there. To be clear -I’m generating the code in Paypal. I then copy the code into the code tab on the WordPress page and initially it looks Ok. Then I change to the Visual tab and the button looks wrong. When i flip back to the code tab, extra lines of codes have been added. Word is not involved anywhere.
    Here’s a test page -I’ve just pasted in the code from Paypal which should produce a single button with drop down options:
    Code as it comes from Paypal
    If I then click on the visual tab to see my button it doesn’t look right -I’ve got multiple button instead of a single one:
    Button appearance after pasting code
    So I go back to the code tab and notice the code has changed -there are new ?select name=”os0″> lines before each menu choice which I haven’t put there.
    Code as changed by Enfold

    • This reply was modified 1 month ago by FFAlan.
    #1484545

    Hi,
    Ok, you had said that you were pateing it into Word.
    If you are not then how you are copying it is adding the extra code, you will need to remove it, the theme is not adding this.

    Best regards,
    Mike

    #1484586

    For some reason you are not able to see my problem, so I will summarize it again and attach a set of screenshots so you can see exactly what is happening, and can copy the original code and paste it into your own software to see if you get the same result:

    1) I design a payment button in Paypal
    2) This generates a piece of code and shows me what the final design should look like
    3) I click on Copy in the Paypal page to copy the code into temporary memory
    4) I open my website and go to the relevant page in my case ‘Events’
    5) On that page there are two tabs labelled Visual and Code and a large space beneath.
    6) With the Code tab selected I right click and select Paste
    7) The code is pasted into the space. I look at the code and it it appears correctly
    8) I then click on the Visual tab to check the finished button
    9) It doesn’t look right. Instead of one button with a drop list of options, I’m getting a lot of separate buttons.
    10) I go back to the code tab and notice that the code has changed – I HAVEN’T DONE ANYTHING AT THIS STAGE, just switched between code and visual tabs. But there are many extra lines that have been added -each item in the drop down list now has an extra <select name=”os0″> and </select> around it . I have messaged WordPress about this, and they tell me that the code tab is part of Enfold and all inputs and outputs to the page are controlled by Enfold, which is why I’m assuming that Enfold is somehow modifying my code.
    So, here are the steps visually
    Paypal Code

    Code after pasting into code page

    Visual tab

    Code page showing modified code

    So from this I hope you can see that by simply switching between the Code tab and the Visual tab, my code is being changed.and I would like to know why and what I can do to stop this. If you want to try pasting my original code into a test page of your own, then this is the complete chunk of code:

    <form action=”https://www.paypal.com/cgi-bin/webscr&#8221; method=”post” target=”_blank”>
    <input type=”hidden” name=”cmd” value=”_s-xclick” />
    <input type=”hidden” name=”hosted_button_id” value=”H87UB2HDHP3GS” />
    <table>
    <tr>
    <td>
    <input type=”hidden” name=”on0″ value=”Options for Brondanw & Nantclwyd only”/>
    Options for Brondanw & Nantclwyd only
    </td>
    </tr>
    <tr>
    <td>
    <select name=”os0″>
    <option value=”Member”>
    Member £17.00 GBP
    </option>
    <option value=”Guest”>
    Guest £19.00 GBP
    </option>
    <option value=”2 Members”>
    2 Members £34.00 GBP
    </option>
    <option value=”1 Member + 1 Guest”>
    1 Member + 1 Guest £36.00 GBP
    </option>
    <option value=”Child under 16″>
    Child under 16 £10.00 GBP
    </option>
    </select>
    </td>
    </tr>
    </table>
    <input type=”hidden” name=”currency_code” value=”GBP” />
    <input type=”image” src=”https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif&#8221; border=”0″ name=”submit” title=”PayPal – The safer, easier way to pay online!” alt=”Add to Cart” />
    </form>

    Thankyou.

    • This reply was modified 4 weeks ago by FFAlan.
    • This reply was modified 4 weeks ago by FFAlan.
    #1484614

    Hi,
    Thank you for your patience, when I test your snippet above I find that the quotes have been converted to curly quotes which break the code.
    If I correct them first, they work correctly in the code block element:
    Screen Shot 2025 05 24 at 12.25.29 PM
    Screen Shot 2025 05 24 at 12.41.37 PM
    when using a code snippet like this the code block element is the correct element to use because the PayPal snippet is calling a function from the PayPal site which will run in the backend editor where you don’t want it to. The visual mode of the text editor will run the code, but the code block element will not.
    If you really want to use the text block element, then use the code tab and do not switch to the visual tab. Here I show that this works, in the code tab you see the code and the preview shows the button:
    Screen Shot 2025 05 24 at 12.52.08 PM
    at this point click “save” and not the visual tab and the button is shown in the editor, which means that WordPress is running the code in the text element in the backend.
    Now you can update the page and view the frontend:
    Screen Shot 2025 05 24 at 12.57.48 PM
    This is the corrected code snippet that I used:

    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
    <input type="hidden" name="cmd" value="_s-xclick" />
    <input type="hidden" name="hosted_button_id" value="H87UB2HDHP3GS" />
    <table>
    <tr>
    <td>
    <input type="hidden" name="on0" value="Options for Brondanw & Nantclwyd only"/>
    Options for Brondanw & Nantclwyd only
    </td>
    </tr>
    <tr>
    <td>
    <select name="os0">
    <option value="Member">
    Member £17.00 GBP
    </option>
    <option value="Guest">
    Guest £19.00 GBP
    </option>
    <option value="2 Members">
    2 Members £34.00 GBP
    </option>
    <option value="1 Member + 1 Guest">
    1 Member + 1 Guest £36.00 GBP
    </option>
    <option value="Child under 16">
    Child under 16 £10.00 GBP
    </option>
    </select>
    </td>
    </tr>
    </table>
    <input type="hidden" name="currency_code" value="GBP" />
    <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif" border="0" name="submit" title="PayPal – The safer, easier way to pay online!" alt="Add to Cart" />
    </form>

    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
    To prevent your code snippet from changing if you want to edit the text block element in the future, such as adding text around the button, we will create a shortcode for your button, by adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function paypal_button_shortcode() {
        ob_start(); ?>
        
        <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
            <input type="hidden" name="cmd" value="_s-xclick" />
            <input type="hidden" name="hosted_button_id" value="H87UB2HDHP3GS" />
            <table>
                <tr>
                    <td>
                        <input type="hidden" name="on0" value="Options for Brondanw & Nantclwyd only" />
                        Options for Brondanw & Nantclwyd only
                    </td>
                </tr>
                <tr>
                    <td>
                        <select name="os0">
                            <option value="Member">Member £17.00 GBP</option>
                            <option value="Guest">Guest £19.00 GBP</option>
                            <option value="2 Members">2 Members £34.00 GBP</option>
                            <option value="1 Member + 1 Guest">1 Member + 1 Guest £36.00 GBP</option>
                            <option value="Child under 16">Child under 16 £10.00 GBP</option>
                        </select>
                    </td>
                </tr>
            </table>
            <input type="hidden" name="currency_code" value="GBP" />
            <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif" border="0" name="submit" title="PayPal – The safer, easier way to pay online!" alt="Add to Cart" />
        </form>
    
        <?php
        return ob_get_clean();
    }
    add_shortcode('paypal_button', 'paypal_button_shortcode');
    

    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
    Then in your text block element use this shortcode [paypal_button]
    Screen Shot 2025 05 24 at 1.16.48 PM
    in the backend you will only see the shorcode:
    Screen Shot 2025 05 24 at 1.16.48 PM
    and on the frontend the button shows:
    Screen Shot 2025 05 24 at 1.20.15 PM

    Best regards,
    Mike

    #1484626

    Thank you for that very detailed reply -however, I’m still no nearer understanding what went wrong in the first place -you open with the statement ” when I test your snippet above I find that the quotes have been converted to curly quotes which break the code.”.. What are curly quotes? I have only a double dash quote mark on my keyboard, the symbol above the number 2 on my UK keyboard. I can’t find anything that looks like curly quotes. Neither can I see anything on the screen that looks any different to the original text I pasted from Paypal. In the line <select name=”os0″> these look like normal quotes. At what pont are they getting changed and by what?

    • This reply was modified 3 weeks, 4 days ago by FFAlan.
    #1484630

    Hi,
    The snippet that you posted above was not in a code wrap, so it is common in the forum for the quotes to be changed and also in the WordPress text field, since the forum uses WordPress. It is easy to see the diffence when a plain text editor is used such as VS code. So I’m not sure if you posted the incorrect code or if the forum text field changed it, this is why I posted the code in a code block for you above.
    But as I pointed out above, using the text block and then viewing the code in the visual tab will change the code because of the added script running in the backend of your site, there is no way to stop this, so the correct solution is to use the code block element instead. See my post above.
    The other solution would be to use the shortcode for the button above, which you could use in a text element, if you really needed to do that.
    Try following the steps in my post above and you will see that if you do not use the visual tab for your code snippet, the button will work correctly, but if you ever edit the element again in the future you will see the error again, there is no way to stop this.
    So I recommend either using the code block element, or the shortcode function above.

    Best regards,
    Mike

    #1484632

    Ok -on re-reading my last post I can see that a little bit of extra code has been tacked onto the end of the paypal addresses at the top and bottom when it appears on the forum.
    So -I did as you suggested, made a code box and pasted the code in directly from Paypal, clicked ‘update and then ‘preview changes’ and again I got the wrong button layout:
    Preview with code block
    I went back and checked the code -it had not changed. So I added a text box, pasted the code into the code tab and then saved and previewed. Again I got the odd button layout. I closed WordPress and went straight to the actual Test page at https://follies.org.uk/index.php/test/
    Now I get two buttons, both correct. So it works this way, but why does the preview show incorrectly? Also, how did you get those button views withthe Endolf logo above them as shown in your naswer? I’ve never seena preview like that.

    #1484634

    Hi,
    The “preview” of a draft page doesn’t always work correctly, you are always best to publish the page and view it to see an accurate result of your page.
    Do you mean the “element preview” shown next to the text element? This is enabled by default in the theme, go to Enfold Theme Options ▸ Layout Builder ▸ Disable Advanced Layout Builder Preview In Backend to see if it is disabled:
    Screen Shot 2025 05 24 at 6.45.23 PM

    Best regards,
    Mike

    #1484642

    I’d never seen that feature before. I checked the Disable layout Viewer setting and it wasn’t slected, but I clicked on Save all changes anyway, and now I can see the preview -a very useful feature I will now make use of. Thanks again for your help and you may now mark this as closed.

    #1484643

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Paypal Button code changes’ is closed to new replies.