PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Button Code Generator For Level #1 Access

s2Member Plugin. A Membership plugin for WordPress®.

Button Code Generator For Level #1 Access

Postby mireille » December 27th, 2011, 8:56 am

I'm using the free version of s2Member and I was wondering if I can create an option so registered users can fill in any amount they wish to share instead of a fixed priced. I know this is possible with paypal's donate button, but I don't know how to add that to s2Member. Any help is much appreciated.
User avatar
mireille
Registered User
Registered User
 
Posts: 7
Joined: December 27, 2011

Re: Button Code Generator For Level #1 Access

Postby Raam Dev » December 27th, 2011, 4:29 pm

Hi mireille,

Let me make sure I understand what you want to do: You'd like to offer something to your customers under a pay-what-you-want pricing model, correct? Will this option be limited to logged-in (i.e. registered) users, or will anyone be able to use this?
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Button Code Generator For Level #1 Access

Postby mireille » December 27th, 2011, 4:34 pm

...under a pay-what-you-want pricing model, correct?
- Yes, that's right.

...will this option be limited to logged-in (i.e. registered) users
- That would be preferable, yes.
User avatar
mireille
Registered User
Registered User
 
Posts: 7
Joined: December 27, 2011

Re: Button Code Generator For Level #1 Access

Postby Raam Dev » December 28th, 2011, 10:23 pm

Hi mireille,

There are two possible ways to achieve this. The first way is to dynamically generate the price in the shortcode. See this thread for more information: viewtopic.php?f=36&t=1604

The other way is to use an unencrypted button and simply turn the hidden amount field into a text field that allows the user to set the price.

When you generate the PayPal button in s2Member, you'll see that you have two options: use the shortcode or use the PayPal Button Code that appears in the box at the bottom. (Keep in mind that you'll need to install and activate the PHP Execution plugin for this method to work because the PayPal Button Code contains some PHP.)

You can copy that PayPal Button Code, paste it into a WordPress page, and then modify it slightly to show a text field for the amount instead of hiding it. You'll change this line:

Code: Select all
<input type="hidden" name="a3" value="5.00" />


to this

Code: Select all
<input type="text" name="a3" value="5.00" />


(Note that if you're using a Buy Now button instead of a subscription button, you'll want to change the input field named "amount" instead of the one called "a3". Also, if you have trouble getting the text field to show up, try deleting all the lines in the generated form code that start and end with <!-- -->.)

Here's an example of what the full modified button code might look like for a Level 1 Subscription pay-what-you-want button:

Code: Select all
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
 <input type="hidden" name="business" value="raam@raamdev.com" />
 <input type="hidden" name="cmd" value="_xclick-subscriptions" />
 <!-- Instant Payment Notification & Return Page Details -->
 <input type="hidden" name="notify_url" value="http://example.com/wordpress/?s2member_paypal_notify=1" />
 <input type="hidden" name="cancel_return" value="http://example.com/wordpress/" />
 <input type="hidden" name="return" value="http://example.com/wordpress/?s2member_paypal_return=1" />
 <input type="hidden" name="rm" value="2" />
 <!-- Configures Basic Checkout Fields -->
 <input type="hidden" name="lc" value="" />
 <input type="hidden" name="no_shipping" value="1" />
 <input type="hidden" name="no_note" value="1" />
 <input type="hidden" name="custom" value="example.com" />
 <input type="hidden" name="currency_code" value="USD" />
 <input type="hidden" name="page_style" value="paypal" />
 <input type="hidden" name="charset" value="utf-8" />
 <input type="hidden" name="item_name" value="Bronze Member / description and pricing details here." />
 <input type="hidden" name="item_number" value="1" />
 <!-- Configures s2Member's Unique Invoice ID/Code  -->
 <input type="hidden" name="invoice" value="<?php echo S2MEMBER_VALUE_FOR_PP_INV(); ?>" />
 <!-- Identifies/Updates An Existing User/Member ( when/if applicable )  -->
 <input type="hidden" name="on0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; ?>" />
 <input type="hidden" name="os0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; ?>" />
 <!-- Identifies The Customer's IP Address For Tracking -->
 <input type="hidden" name="on1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; ?>" />
 <input type="hidden" name="os1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; ?>" />
 <!-- Controls Modify Behavior At PayPal® Checkout -->
 <input type="hidden" name="modify" value="0" />
 <!-- Customizes Prices, Payments & Billing Cycle -->
 <input type="hidden" name="src" value="1" />
 <input type="hidden" name="srt" value="" />
 <input type="hidden" name="sra" value="1" />
 <input type="text" name="a3" value="5.00" />
 <input type="hidden" name="p3" value="1" />
 <input type="hidden" name="t3" value="M" />
 <!-- Displays The PayPal® Image Button -->
 <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" style="width:auto; height:auto; border:0;" alt="PayPal®" />
</form>


The above code generated the following text field + PayPal button on my test site:

Screen shot 2011-12-28 at 22.14.48 .png
Screen shot 2011-12-28 at 22.14.48 .png (11.82 KiB) Viewed 2236 times
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Button Code Generator For Level #1 Access

Postby mireille » December 30th, 2011, 8:13 pm

Sorry for the late reply. I only had the time to try out your solutions just now.

The first one worked like a charm. I prefer the second one though, because it looks much more awesome on the website itself. However, there was just one problem.
When I altered the amount from 5.00 to 7.00 and then clicked on the button, Paypal still displayed $5 during checkout.
User avatar
mireille
Registered User
Registered User
 
Posts: 7
Joined: December 27, 2011

Re: Button Code Generator For Level #1 Access

Postby Raam Dev » January 1st, 2012, 5:09 pm

Did you change this line?

Code: Select all
<input type="text" name="a3" value="5.00" />


If you're still having trouble, can you paste your button code here?
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Button Code Generator For Level #1 Access

Postby mireille » January 1st, 2012, 6:21 pm

Sorry, I should've been clearer. ^^;;
I tested the code on the page and it looks wonderful, but when I alter the amount in the "preview page" just before clicking on the button and be forwarded to PayPal’s website, PayPal still thinks it $5.
See screenshot below.

Image
User avatar
mireille
Registered User
Registered User
 
Posts: 7
Joined: December 27, 2011

Re: Button Code Generator For Level #1 Access

Postby Raam Dev » January 2nd, 2012, 5:17 pm

Could you copy and paste the full code you're using to generate the text box + button?
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Button Code Generator For Level #1 Access

Postby mireille » January 2nd, 2012, 5:23 pm

Here you go:
Code: Select all
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="raam@raamdev.com" />
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<!-- Instant Payment Notification & Return Page Details -->
<input type="hidden" name="notify_url" value="http://example.com/wordpress/?s2member_paypal_notify=1" />
<input type="hidden" name="cancel_return" value="http://example.com/wordpress/" />
<input type="hidden" name="return" value="http://example.com/wordpress/?s2member_paypal_return=1" />
<input type="hidden" name="rm" value="2" />
<!-- Configures Basic Checkout Fields -->
<input type="hidden" name="lc" value="" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="custom" value="www.newjlpt.com" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="page_style" value="paypal" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="item_name" value="VIP Access" />
<input type="hidden" name="item_number" value="1" />
<!-- Configures s2Member's Unique Invoice ID/Code  -->
<input type="hidden" name="invoice" value="<?php echo S2MEMBER_VALUE_FOR_PP_INV(); ?>" />
<!-- Identifies/Updates An Existing User/Member ( when/if applicable )  -->
<input type="hidden" name="on0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; ?>" />
<input type="hidden" name="os0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; ?>" />
<!-- Identifies The Customer's IP Address For Tracking -->
<input type="hidden" name="on1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; ?>" />
<input type="hidden" name="os1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; ?>" />
<!-- Controls Modify Behavior At PayPal® Checkout -->
<input type="hidden" name="modify" value="0" />
<!-- Customizes Prices, Payments & Billing Cycle -->
<input type="hidden" name="amount" value="5" />
<input type="hidden" name="src" value="BN" />
<input type="hidden" name="srt" value="" />
<input type="hidden" name="sra" value="1" />
<input type="hidden" name="a1" value="0" />
<input type="hidden" name="p1" value="0" />
<input type="hidden" name="t1" value="D" />
<input type="text" name="a3" value="5" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="t3" value="L" />
<!-- Displays The PayPal® Image Button -->
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" style="width:auto; height:auto; border:0;" alt="PayPal®" />
</form>
Last edited by mireille on January 3rd, 2012, 7:23 am, edited 1 time in total.
User avatar
mireille
Registered User
Registered User
 
Posts: 7
Joined: December 27, 2011

Re: Button Code Generator For Level #1 Access

Postby Raam Dev » January 2nd, 2012, 5:27 pm

And which s2Member Button Generator did you use to generate this code? An Access Level Button generator, or something else? Could you tell me which settings you used as well?
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Button Code Generator For Level #1 Access

Postby mireille » January 2nd, 2012, 5:35 pm

I made a screenshot; here you go

Image
User avatar
mireille
Registered User
Registered User
 
Posts: 7
Joined: December 27, 2011

Re: Button Code Generator For Level #1 Access

Postby Raam Dev » January 2nd, 2012, 5:56 pm

OK, I generated the same button as you and here's the code that resulted:

Code: Select all
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="raam@example.com" />
<input type="hidden" name="cmd" value="_xclick" />
<!-- Instant Payment Notification & Return Page Details -->
<input type="hidden" name="notify_url" value="http://example.websharks-inc.com/wordpress/?s2member_paypal_notify=1" />
<input type="hidden" name="cancel_return" value="http://example.websharks-inc.com/wordpress/" />
<input type="hidden" name="return" value="http://example.websharks-inc.com/wordpress/?s2member_paypal_return=1" />
<input type="hidden" name="rm" value="2" />
<!-- Configures Basic Checkout Fields -->
<input type="hidden" name="lc" value="" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="custom" value="example.websharks-inc.com" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="page_style" value="paypal" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="item_name" value="VIP Access" />
<input type="hidden" name="item_number" value="1" />
<!-- Configures s2Member's Unique Invoice ID/Code  -->
<input type="hidden" name="invoice" value="<?php echo S2MEMBER_VALUE_FOR_PP_INV(); ?>" />
<!-- Identifies/Updates An Existing User/Member ( when/if applicable )  -->
<input type="hidden" name="on0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; ?>" />
<input type="hidden" name="os0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; ?>" />
<!-- Identifies The Customer's IP Address For Tracking -->
<input type="hidden" name="on1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; ?>" />
<input type="hidden" name="os1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; ?>" />
<!-- Controls Modify Behavior At PayPal® Checkout -->
<input type="hidden" name="modify" value="0" />
<!-- Customizes Prices, Payments & Billing Cycle -->
<input type="hidden" name="amount" value="5" />
<!--<input type="hidden" name="src" value="BN" />-->
<!--<input type="hidden" name="srt" value="" />-->
<!--<input type="hidden" name="sra" value="1" />-->
<!--<input type="hidden" name="a1" value="0" />-->
<!--<input type="hidden" name="p1" value="0" />-->
<!--<input type="hidden" name="t1" value="D" />-->
<!--<input type="hidden" name="a3" value="5" />-->
<!--<input type="hidden" name="p3" value="1" />-->
<!--<input type="hidden" name="t3" value="L" />-->
<!-- Displays The PayPal® Image Button -->
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" style="width:auto; height:auto; border:0;" alt="PayPal®" />
</form>


Notice all the commented out input lines that start with <!-- and end with -->? Since they're commented out, you can (and should) ignore those.

In your original code, you had an 'amount' field AND an 'a3' field active. With this button code, you should only have the 'amount' field (since the 'a3' field is commented out).

So to make things clearer, here's the same code as above, except with the commented input lines removed:

Code: Select all
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="raam@example.com" />
<input type="hidden" name="cmd" value="_xclick" />
<!-- Instant Payment Notification & Return Page Details -->
<input type="hidden" name="notify_url" value="http://example.websharks-inc.com/wordpress/?s2member_paypal_notify=1" />
<input type="hidden" name="cancel_return" value="http://example.websharks-inc.com/wordpress/" />
<input type="hidden" name="return" value="http://example.websharks-inc.com/wordpress/?s2member_paypal_return=1" />
<input type="hidden" name="rm" value="2" />
<!-- Configures Basic Checkout Fields -->
<input type="hidden" name="lc" value="" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="custom" value="example.websharks-inc.com" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="page_style" value="paypal" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="item_name" value="VIP Access" />
<input type="hidden" name="item_number" value="1" />
<!-- Configures s2Member's Unique Invoice ID/Code  -->
<input type="hidden" name="invoice" value="<?php echo S2MEMBER_VALUE_FOR_PP_INV(); ?>" />
<!-- Identifies/Updates An Existing User/Member ( when/if applicable )  -->
<input type="hidden" name="on0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; ?>" />
<input type="hidden" name="os0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; ?>" />
<!-- Identifies The Customer's IP Address For Tracking -->
<input type="hidden" name="on1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; ?>" />
<input type="hidden" name="os1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; ?>" />
<!-- Controls Modify Behavior At PayPal® Checkout -->
<input type="hidden" name="modify" value="0" />
<!-- Customizes Prices, Payments & Billing Cycle -->
<input type="hidden" name="amount" value="5" />
<!-- Displays The PayPal® Image Button -->
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" style="width:auto; height:auto; border:0;" alt="PayPal®" />
</form>


And finally, the same code with the 'amount' field made editable:

Code: Select all
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="raam@example.com" />
<input type="hidden" name="cmd" value="_xclick" />
<!-- Instant Payment Notification & Return Page Details -->
<input type="hidden" name="notify_url" value="http://example.websharks-inc.com/wordpress/?s2member_paypal_notify=1" />
<input type="hidden" name="cancel_return" value="http://example.websharks-inc.com/wordpress/" />
<input type="hidden" name="return" value="http://example.websharks-inc.com/wordpress/?s2member_paypal_return=1" />
<input type="hidden" name="rm" value="2" />
<!-- Configures Basic Checkout Fields -->
<input type="hidden" name="lc" value="" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="custom" value="example.websharks-inc.com" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="page_style" value="paypal" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="item_name" value="VIP Access" />
<input type="hidden" name="item_number" value="1" />
<!-- Configures s2Member's Unique Invoice ID/Code  -->
<input type="hidden" name="invoice" value="<?php echo S2MEMBER_VALUE_FOR_PP_INV(); ?>" />
<!-- Identifies/Updates An Existing User/Member ( when/if applicable )  -->
<input type="hidden" name="on0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; ?>" />
<input type="hidden" name="os0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; ?>" />
<!-- Identifies The Customer's IP Address For Tracking -->
<input type="hidden" name="on1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; ?>" />
<input type="hidden" name="os1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; ?>" />
<!-- Controls Modify Behavior At PayPal® Checkout -->
<input type="hidden" name="modify" value="0" />
<!-- Customizes Prices, Payments & Billing Cycle -->
<input type="text" name="amount" value="5" />
<!-- Displays The PayPal® Image Button -->
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" style="width:auto; height:auto; border:0;" alt="PayPal®" />
</form>


Try that... does that fix it for you?
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Button Code Generator For Level #1 Access

Postby mireille » January 2nd, 2012, 6:10 pm

How delightfully embarrassing I didn’t notice the double fields.
Thank you so much! It's working like a charm!
User avatar
mireille
Registered User
Registered User
 
Posts: 7
Joined: December 27, 2011

Re: Button Code Generator For Level #1 Access

Postby Raam Dev » January 2nd, 2012, 9:13 pm

No worries. It was easy to miss! :) Glad to hear it's working now. Let us know if you have any other questions.
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron