latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Variables in shortcode

Home Forums Community Forum Variables in shortcode

This topic contains 4 replies, has 2 voices. Last updated by  Raam Dev 4 years, 5 months ago.

Topic Author Topic
Posted: Thursday Aug 2nd, 2012 at 10:08 pm #21065

I have created a two step checkout process where a user selects custom capabilities using check boxes. The action for the selection form is the checkout page where the custom capabilities are dynamically added the shortcode. The price (ra attribute) and description (desc attribute) are also generated dynamically.

When I test the checkout process I get errors because the checkout form action is the checkout page itself and my php variables don’t have POST attributes to set themselves again. I can overcome the php errors from my POST variables are no longer set, but how do I maintain my dynamic fields once the Pro form is submitted? Obviously when the form checkout form is submitted the original POST variables don’t exist from the first time the page was loaded.

Can I grab my custom values from the “s2member_pro_paypal_checkout” array to re-populate my variables or is there a minimum required shortcode I could execute leaving off my dynamic attributes when the page is reloaded after the checkout form submission?

Let me know if I need to clarify anything.

Thanks,

David

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Friday Aug 3rd, 2012 at 12:35 am #21067

I bypassed the POST variables for the checkout form precessing, which allowed me to overcome the errors I was experiencing.

Now there is a secondary problem, if there is an error while processing the form the variables for the shortcode are not set. Can I re-set the variables on the page load when the checkout for is processing. Like pulling them from the “s2member_pro_paypal_checkout” array somehow? When looking at that array the “attr” is encrypted.

Posted: Friday Aug 3rd, 2012 at 9:46 am #21106
Raam Dev
Username: Raam
Staff Member

Hi Andrew,

I’m really not sure what the problem is. Could you please share the code you’re using so I can understand better?

Posted: Friday Aug 3rd, 2012 at 8:41 pm #21146

The code is fairly extensive, but hopefully I can clarify.

I am building my shortcode dynamically, in php it looks like this:

<?php
$shortcode = '[s2Member-Pro-PayPal-Form level="1" ccaps="'.$ccaps.'" desc="'.$descPretty.'" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="localhost" ta="0" tp="0" tt="D" ra="'.$totalPrice.'" rp="1" rt="L" rr="BN" rrt="" rra="2" accept="paypal,visa,mastercard,amex,discover" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" captcha="0" template="checkout.php" /]';
?>

As you can see I have some variables in my shortcode: $ccaps, $descPretty and $totalPrice . These variables are set the first time the checkout page is loaded based on a from on a previous page. If there are any errors in the s2member pro form processing the page is reloaded and the form is re-displayed but my variables are not set because the $_POST data from the previous page is no longer set. This causes errors, for example the desc=”” attr is empty because my variables are empty.

So to try and clarify, if there are errors when the pro form is processed and the checkout page is re-loaded, my variables are left empty.

How can I re-set my variables? Can I do it from the “s2member_pro_paypal_checkout” array somehow when the form is processed?

Does that help clarify?

Thanks,

David

Posted: Monday Aug 6th, 2012 at 10:58 pm #21303
Raam Dev
Username: Raam
Staff Member

It sounds like you just need to pass that $_POST data along when you reload the page. There are various ways to do that, but it all depends on how you’re reloading the page and how you’re checking if there are errors.

(FYI, these types of issues are usually resolved by doing client-side error checking and not even POSTing the data until the form has been completed properly.)

It’s hard to offer more advice here without seeing how the whole thing works.

Viewing 4 replies - 1 through 4 (of 4 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.