S2member with paypal beta checkout activated breaks shortcodes without values in hypens ""

Simple as that - the new versions with paypal checkout beta break paypal shortcode buttons when “” hyphens aren’t used for the value.

Works only in older versions:
[s2Member-PayPal-Button level=1 ccaps= desc=50 gives you 3 year VeloMap access ps=paypal lc= cc=EUR dg=0 ns=2 custom=www.velomap.org|81.217.157.16|AT|AT|+43- ta=0 tp=0 tt=Y ra=50 rp=3 rt=Y rr=BN rrt= rra=1 image=default output=button rm=2 success=/success/ notify_url=https://www.velomap.org/?s2member_paypal_notify=1 cancel_return=https://www.velomap.org return=https://www.velomap.org/?s2member_paypal_return=1 invoice=value=20 /]

Works in old and new version
[s2Member-PayPal-Button level=“1” ccaps="" desc=“50 gives you 3 year VeloMap access” ps=“paypa"l lc=”" cc=“EUR” dg=“0” ns=“2” custom=“www.velomap.org|81.217.157.16|AT|AT|+43-” ta=“0” tp=“0” tt=“Y” ra=“50” rp=“3” rt=“Y” rr=“BN” rra=“1” image=“default” output=“button” rm=“2” success="/success/" notify_url=“https://www.velomap.org/?s2member_paypal_notify=1” cancel_return=“https://www.velomap.org return=https://www.velomap.org/?s2member_paypal_return=1” invoice=“20” /]

I don’t think the PayPal Checkout implementation changed anything about shortcode parsing. The shortcode is parsed by wordpress’ do_shortcode… https://developer.wordpress.org/reference/functions/do_shortcode/

:thinking:

That one has mixed quotes, see:

[s2Member-PayPal-Button level=“1” ccaps="" desc=“50 gives you 3 year VeloMap access” ps=“paypa"l lc=”" cc=“EUR” dg=“0” ns=“2” custom=“www.velomap.org|81.217.157.16|AT|AT|+43-” ta=“0” tp=“0” tt=“Y” ra=“50” rp=“3” rt=“Y” rr=“BN” rra=“1” image=“default” output=“button” rm=“2” success="/success/" notify_url=“https://www.velomap.org/?s2member_paypal_notify=1” cancel_return=“https://www.velomap.org return=https://www.velomap.org/?s2member_paypal_return=1” invoice=“20” /]

With the quotes fixed:

[s2Member-PayPal-Button level="1" ccaps="" desc="50 gives you 3 year VeloMap access" ps="paypa"l lc="" cc="EUR" dg="0" ns="2" custom="www.velomap.org|81.217.157.16|AT|AT|+43-" ta="0" tp="0" tt="Y" ra="50" rp="3" rt="Y" rr="BN" rra="1" image="default" output="button" rm="2" success="/success/" notify_url="https://www.velomap.org/?s2member_paypal_notify=1" cancel_return="https://www.velomap.org" return="https://www.velomap.org/?s2member_paypal_return=1" invoice="20" /]

:slight_smile:

Interesting… I tested a shortcode without quotes for the values, and it works…

[s2Member-PayPal-Button custom=test.com level=1 cc=USD desc=BN Test rr=BN ra=0.01 output=button]

I had not tried it before! lol

But again, it’s not an s2 thing. If it worked before and not now, maybe there’s some of your values that if unquoted give trouble?

ChatGPT failed - but Claude Sonnet 4.6 fixed it for me - the problem was:
But actually — there’s a deeper issue here . The new PayPal Checkout in s2Member renders the button using a JavaScript SDK that must be loaded in the <head> of the parent page , not inside a div loaded via jQuery.load() . When you load the button via AJAX into a div, the PayPal JS SDK script tag that s2Member outputs gets injected into the DOM after page load , and PayPal’s SDK explicitly does not support this — it must be present at initial page load.

This is the fundamental architectural problem. The old PayPal buttons were simple form POST buttons with no JS SDK dependency. The new PayPal Checkout uses a JavaScript SDK ( paypal.Buttons().render() ) that requires:

  1. The SDK <script> tag in <head>
  2. A container div already in the DOM when the SDK initializes

Loading it via jQuery.load() into a div after page load will never work with the new PayPal Checkout buttons.

The solution requires a different approach. Instead of loading the button HTML via AJAX, you need to either:

Option A (simplest): Pre-render all possible buttons server-side and show/hide them with JavaScript based on the dropdown selection — no AJAX at all.

1 Like

Edit: deleted post as I have still optimised the plugin a little with help of Claude. Also I had not understood that the template isn’t needed anymore. No more additions to header.php

1 Like

Interesting. The have worked like this in my tests. But I’ll see how I can I improve them, and if it needs adding them to the head, that’s fine too. Thanks for that suggestion!

:slight_smile:

1 Like

you can see how the dropdown works here:
https://openmtbmap.org/support/members/

And yes of course if it’s integrated directly into s2member it can be cleaner. I’m sure. Took me 3-4 hours with free chatgpt trying to solve it which failed, and then 1.5 hours with Claude Sonnet 4.6 free version which succeeded.
I guess with Claude Opus 4.6 it would have worked even better as it can automatically check if it’s working and does buggtracking.

1 Like

And oh yeah - I really hope for a solution to s2member-pro with the dropdown that works in the same kind of fashion too - simply hiding intead of reloading the different buttons - or a complete rewrite of that pro-form - also with user being able to select which fields are mandatory, which fileds are shown but optional, and which fields are not shown at all.

I’m tempted to let Claude fix it for me but I guess Christian can do a cleaner version (maybe with AI support)

1 Like

Oh yes Christian you are right - the header.php addition is not needed anymore on the newest version of the Claude optimised plugin. It’s now a simple plugin and activated by adding the shortcode. Of course anyone wanting to use this needs to update all URLs to reflect his own website - line 723-725 and line 689 the custom value domain! Best replace any occurence of openmtbmap.org with your own domain.

Ill add the newest version here now - replace pdf with php.mc_openmtbmap.pdf (29.5 KB)

1 Like

Yeah, improving the pro-forms is something in my to-do, but it’s a major job. I’m making improvements or fixing things there, but the rewrite will probably won’t be pro-forms anymore, and will let me support many more gateways and other improvements more easily in the future, too. I haven’t gotten to that point yet, though.

1 Like