Page 1 of 1
List of shortcodes in the Pro html templates?
Posted:
July 19th, 2011, 4:56 pm
by blewis
I am trying to tweak my PayPal Pro template (paypal-checkout-form.html), which uses double-percent shortcodes. I wish to show the price of the level at the top of the page, but NOT include the price in the description.
Currently toward the top of the page there is "%%description%%", which shows the value of the "desc" variable passed into it. I want to change this to something like "%%description%% - %%price%%" but I don't know what code to use or if there is even one available. It should be the contents of the "ra" field passed in, but "%%ra%%" is not a valid variable.
Is this possible?
Thanks,
Bryan
Re: List of shortcodes in the Pro html templates?
Posted:
July 20th, 2011, 10:57 am
by Cristián Lávaque
Hi Bryan.
Well, you could try replacing that string with JavaScript. Or find where s2Member replaces that code with the string and then you edit it there using a hook.
But you can edit the description in the shortcode, have you tried that?
Re: List of shortcodes in the Pro html templates?
Posted:
July 20th, 2011, 11:22 am
by blewis
I have tried searching through the code to locate where those %% strings are replaced with real values and have been unable to find it. Do you know where that happens?
I don't want the price in the description, mostly because we will be having a lot of various discount options. Because the description is used in things like the welcome email to tell them what level they have, I don't want the price in there because they may have used a discount code to reduce the base price. It would be confusing to have the description be "My Plan - $29.95 / Month" when there is a good chance they will not actually be paying that amount.
thanks,
Bryan
Re: List of shortcodes in the Pro html templates?
Posted:
July 20th, 2011, 10:03 pm
by Cristián Lávaque
I understand why you wouldn't want it in the description. No, I don't know where in the code the replacement codes are parsed, I emailed Jason but he hasn't gotten to it yet.
I was suggesting above that you edit the description attribute in the shortcode, just remove the price there: description="My Plan".
Re: List of shortcodes in the Pro html templates?
Posted:
July 20th, 2011, 10:54 pm
by blewis
Yes, I have edited the description on the shortcode for the paypal checkout page to remove the price, but I still want to show the price somewhere on the page -- so being able to display the "ra" variable would be great. I tried doing some searches through the code (both regular and pro code) and could not find where the replacements occur.
Re: List of shortcodes in the Pro html templates?
Posted:
July 21st, 2011, 12:43 am
by Cristián Lávaque
Ah, I see. I'll ask Jason about that.
Re: List of shortcodes in the Pro html templates?
Posted:
July 22nd, 2011, 6:44 pm
by Jason Caldwell
I'm investigating this now.
Just a quick FYI though. s2Member will notate discounts in the %%description%% value when/if discounts are applied through Coupon Codes. In other words, if your discounts are applied with Coupon Codes configured with s2Member, the %%description%% value would always indicate that a discount was applied, along with other notes about the Coupon used and the original price before the discount. Your original description is followed by this information, which is added dynamically by s2Member whenever a Coupon is used.
Re: List of shortcodes in the Pro html templates?
Posted:
July 22nd, 2011, 7:02 pm
by Jason Caldwell
The Replacement Code
%%description%% is handled inside:
- Code: Select all
/s2member-pro/includes/classes/gateways/authnet/authnet-form-in.inc.php
( search for instances of %%description%% )OR --- if you want access to Shortcode Attributes inside your custom template file,
please create this directory and file first please:
/wp-content/mu-plugins/s2-hacks.php- Code: Select all
<?php
add_action ("ws_plugin__s2member_pro_before_sc_authnet_form_after_shortcode_atts", "my_action");
function my_action ($vars = array ())
{
$GLOBALS["authnet_attr"] = $vars["attr"];
}
?>
* Now you can have access to all Shortcode Attributes inside your custom PHP template file. For instance, you could now use: $GLOBALS["authnet_attr"]["ra"]
Re: List of shortcodes in the Pro html templates?
Posted:
July 22nd, 2011, 7:07 pm
by blewis
Thanks (and thanks for the reminder about the dynamic desc).
But just to clarify, I am using PayPal Pro (with ARB). The code for this would still be in the Authnet gateway directory?
Bryan
Re: List of shortcodes in the Pro html templates?
Posted:
July 22nd, 2011, 7:14 pm
by Jason Caldwell
Oh, sorry. I guess I just had Authorize.Net on my mind when I wrote that.
The process is essentially the same for PayPal, but the locations are different. Here you go.
The Replacement Code
%%description%% is handled inside:
- Code: Select all
/s2member-pro/includes/classes/gateways/paypal/paypal-form-in.inc.php
( search for instances of %%description%% )OR --- if you want access to Shortcode Attributes inside your custom template file,
please create this directory and file first please:
/wp-content/mu-plugins/s2-hacks.php- Code: Select all
<?php
add_action ("ws_plugin__s2member_pro_before_sc_paypal_form_after_shortcode_atts", "my_action");
function my_action ($vars = array ())
{
$GLOBALS["paypal_attr"] = $vars["attr"];
}
?>
* Now you can have access to all Shortcode Attributes inside your custom PHP template file. For instance, you could now use: $GLOBALS["paypal_attr"]["ra"]
Re: List of shortcodes in the Pro html templates?
Posted:
July 22nd, 2011, 7:57 pm
by blewis
Thanks. I will give it a try.
Bryan
Re: List of shortcodes in the Pro html templates?
Posted:
July 23rd, 2011, 5:44 pm
by blewis
Not sure why, but the s2-hacks file in the mu-plugins directory did not work for me. The %%ra%% variable did not change to the price (it just stayed the literal string "%%ra%%" in the final output).
However, hacking the paypal-form-in.inc.php file directly did work. It's not the prettiest thing, since I not really like changing core files in plugins (due to updates). But at least it's working.
Thanks,
Bryan
Re: List of shortcodes in the Pro html templates?
Posted:
July 24th, 2011, 12:06 pm
by Jason Caldwell
Thanks for reporting back.blewis wrote:Not sure why, but the s2-hacks file in the mu-plugins directory did not work for me. The %%ra%% variable did not change to the price (it just stayed the literal string "%%ra%%" in the final output).
However, hacking the paypal-form-in.inc.php file directly did work. It's not the prettiest thing, since I not really like changing core files in plugins (due to updates). But at least it's working.
Thanks,
Bryan
Sorry for any confusion. You'll need to use
<?php echo $GLOBALS["paypal_attr"]["ra"]; ?>. The %%ra%% Replacement Code is invalid inside a Pro Form template. The hack I supplied makes it possible to access Shortcode Attributes through PHP tags though.
- Code: Select all
<?php echo $GLOBALS["paypal_attr"]["attribute_name_goes_here"]; ?>
Re: List of shortcodes in the Pro html templates?
Posted:
July 24th, 2011, 1:21 pm
by blewis
Oops. I guess you did state that in your original code posting. I just failed to read the part below the code box. Sorry for not following directions!
Re: List of shortcodes in the Pro html templates?
Posted:
July 24th, 2011, 10:33 pm
by Jason Caldwell
No problem at all. Thanks for the follow-up!