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.

Add multiple posts to a cart then checkout

Home Forums Community Forum Add multiple posts to a cart then checkout

This topic contains 16 replies, has 3 voices. Last updated by  Eduan 4 years, 1 month ago.

Topic Author Topic
Posted: Wednesday Nov 21st, 2012 at 10:06 am #32248
Pam
Username: pdblizzard

Is it possible to allow the customer to add multiple products (posts – we’ll use custom capabilities) to a cart and then checkout at PayPal once?

I want to avoid the purchaser having to checkout multiple times at PayPal to be able to get access to 2-12 video posts.

List Of Topic Replies

Viewing 16 replies - 1 through 16 (of 16 total)
Author Replies
Author Replies
Posted: Wednesday Nov 21st, 2012 at 8:59 pm #32299
Raam Dev
Username: Raam
Staff Member

Hi Pam,

s2Member does not currently have the shopping cart functionality that you describe. As you’re already aware, Custom Capabilities can be used to sell access to multiple things, but the functionality necessary to “collect” all the Custom Capabilities the purchaser wants and then sell them in one go would need to be created by you.

You could do something with PHP sessions where you simply record which “products” the visitors wants and then at checkout you read those session variables and then show a Pro-Form that is configured to sell access to all those Custom Capabilities.

Posted: Wednesday Nov 21st, 2012 at 9:12 pm #32300
Pam
Username: pdblizzard

Thank you so much for your thorough reply.

I know PHP enough to take some code and change it to my needs, and troubleshoot, but not to write from scratch.

Do you know of an example I could modify?

Thanks!!!!

Posted: Thursday Nov 22nd, 2012 at 4:34 pm #32374
Pam
Username: pdblizzard

Let me clarify what I’m trying to do.
I have 12 how-to videos. Ill make each video a Custom Capability on a post, and not require a subscription for purchase.

I’d like to offer 2 videos for $2.99 or all 12 for 12.99.

Customer #1 may want Video 1 and Video 6.
Customer #2 may want Video 3 and Video 7.
Customer #3 may want Videos 2, 4, 7, and 9.

I know how to collect which videos they want with PHP and retain them as variables. My question is, how would I pass the Video number(s) as Custom Capabilities for that customer and the $$ amount to Paypal for purchase.

An example is nice, but if you can tell me where the documentation for passing PHP variables to S2member is, I’d appreciate it. I’m searching but not finding quite all the pieces I’m guessing that I need. THANKS!

Posted: Friday Nov 23rd, 2012 at 12:28 pm #32425
Eduan
Username: Eduan
Moderator

Hello Pam,

So what you’re trying to achieve is modify the button according to the user’s selections right? In that case you might be interested in this article: Knowledge Base » Using variables in a shortcode

Also check out my hack which might help you, just gotta customize it to your needs: http://eduantech.com/code-snippets/donation-button-that-gives-access

Hope this helps. :)

Posted: Sunday Nov 25th, 2012 at 12:11 am #32516
Pam
Username: pdblizzard

Ok, yes, I’m starting to piece it all together, thank you.

I took your donation code, and changed it to match my own product, changing the “amount” variable to a CCAPS variable instead, and changing the button short code to my own created, [s2Member-Pro-PayPal-Form level=”*”…etc etc.

I’m unclear on what URL to send the output to, for ” Another important thing, change the output value to url,
otherwise you won’t be able to redrect the user.” When I click the button, it looks great, but it only sends me to my own site. Can you clarify what I need to do to actually get the short code to send it to PayPal and not my own site?

thanks!

Posted: Sunday Nov 25th, 2012 at 10:09 am #32532
Eduan
Username: Eduan
Moderator

Glad my button helped you. :)

Change the output value, from “button”, to “url”. In order for the hack to work. If that’s what you didn’t understand. :)

– Eduan

Posted: Sunday Nov 25th, 2012 at 10:15 am #32535
Pam
Username: pdblizzard

output=”url” in the short code is what I have, and it’s still just reloading with this as the url:

http://mysite.tv/?video1=videojan2013&x=87&y=6

Posted: Sunday Nov 25th, 2012 at 1:29 pm #32539
Eduan
Username: Eduan
Moderator

Could you please post the following here:

  • The hack that you’re using (so that I can check if it’ll work)
  • The URL to the page with the button? You can sensor out your website name if you want.
  • The location of your hack.

Thanks, these’ll help me find the reason of your problem. :)

Posted: Sunday Nov 25th, 2012 at 2:59 pm #32540
Pam
Username: pdblizzard

You are so kind to help me with this! I’m sure I will use it over and over again once I get it. I understand each peice, but just not how it all fits together.

Here’s my hack, based on your donation hack, my own comments added // after yours//.

<?php
// Define the donation_button function// I've added a drop down list to select one from a list of 12, the values being the CCAPs
function video_button() {
    echo '<!--raw-->
    <form action="/" method="get"><br />
        <p><label for="paypal-order">Select your Videos</label><br />
		<select id=video1 name="video1">
<option value="aries2013">Aries</option>
<option value="taurus2013">Taurus</option>
<option value="gemini2013">Gemini</option>
<option value="cancer2013">Cancer</option>
<option value="leo2013">Leo</option>
<option value="virgo2013">Virgo</option>
<option value="libra2013">Libra</option>
<option value="scorpio2013">Scorpio</option>
<option value="sagittarius2013">Sagittarius</option>
<option value="capricorn2013">Capricorn</option>
<option value="aquarius2013">Aquarius</option>
<option value="pisces2013">Pisces</option>
</select>:<br />
       
        <p><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" style="width:auto; height:auto; border:0;" alt="PayPal" /></p>
    </form>
    <!--/raw-->';
}
 
// Adds a shortcode for the donation button // where I have changed the name to video-button
add_shortcode('video-button', 'video_button');
 
// Check if the paypal-order variable is set
if(isset($_GET['paypal-order'])) {
    // Makes sure WordPress and all the plugins are loaded before running the forward_to_paypal function
    add_action('wp_loaded', 'forward_to_paypal', 1);
 
    // Define the forward_to_paypal function
    function forward_to_paypal() {
        // Define a variable and some arrays
        $video1 = (float) $_GET['paypal-order'];
 
        // Check if the chosen value in the $ra array exists
        if(isset($cccaps[$option])) {
            // If it does exist, then make an s2Member shortcode and make it output an URL, and then save the URL in the $url variable// this was the code created in my back end using Pro Form Generator For Independent Custom Capabilities
		  $url = do_shortcode('[s2Member-Pro-PayPal-Form level="*" ccaps="' . $option . '" desc="2013 Year Ahead Videos" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="insightfulastrology.tv/word" ra="0.01" rp="1" rt="L" rr="BN" accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" output="url" captcha="0" /]  ');
       // Redirect user to the resulting shortcode URL
            header('Location: ' . $url);
        }
 
        // Else, just redirect to the page the user was in
        header('Location: ' . $_SERVER['HTTP_REFERER']);
    }
}

Here’s the test post I made with the short code “video-button” short code: http://insightfulastrology.tv/word/button-sale/

Location of the hack is http://insightfulastrology.tv/word/wp-content/mu-plugins/video-button.php

Please note the ROOT of this WP installation is http://insightfulastrology.tv/word/ This is our test site, not her real, live site.

Posted: Sunday Nov 25th, 2012 at 3:38 pm #32543
Eduan
Username: Eduan
Moderator

Well, I inspected the code and noticed more than one thing wrong.

First, I suggest you don’t change the variable names, unless you do a search and replace on the whole file, also please tell me when you change the names, cause I was a bit confused. ;)

Also, don’t change the indenting, for some reason it’s all messed up.

OK, then, if you want your users to be able to select more than one option, then I suggest you use check boxes, not drop-downs. Here’s some reference on forms, there’s check boxes among those: http://www.w3schools.com/html/html_forms.asp

Also, last time I checked, this hack only works with PayPal buttons, not pro-forms, so that’s another thing you need to change. And… Oh yeah, the level attribute must be set to 0 or 1, depending on the level that this is gonna offer, you can’t set it to *.

– Eduan

Posted: Sunday Nov 25th, 2012 at 3:44 pm #32546
Pam
Username: pdblizzard

Ok I’m going to start over again, not changing the variables, only the “amount” and “Ccaps”.

The indenting may have happened in DreamWeaver Cs6 so I will try to keep that the same.
I’ll use a PayPal button, not the proforms and see what happens.

I SO appreciate your feedback, and assistance. I am already learning so much from your example.

Posted: Sunday Nov 25th, 2012 at 3:47 pm #32547
Eduan
Username: Eduan
Moderator

No problem, that’s how you learn. :)

Posted: Sunday Nov 25th, 2012 at 4:08 pm #32548
Pam
Username: pdblizzard

Ok, this is using your code, the only changes I made, is that I used a regular PayPal button (Button Code Generator For Independent Custom Capabilities), to change the short code, and there I changed output=”button” to output=”url”.

From this url, I input a $ amount, (32.00)
http://insightfulastrology.tv/word/button-sale/
and get this:
http://insightfulastrology.tv/?x=84&y=10

– do you think its’ because I have WP in a subdirectory and not in the root?

<?php
// Define the donation_button function
function donation_button() {
   echo '<!--raw-->
   <form action="/" method="get"><br />
       <p><label for="paypal-order">Choose the amount you want to donate</label><br />
       <input type="text" id="paypal-order" /><br />
       <span style="font-size: small;">Please make sure to define the amount of cents (e.g. 10.88, 34.00, etc.).</span>
       <p><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" style="width:auto; height:auto; border:0;" alt="PayPal" /></p>
   </form>
   <!--/raw-->';
}

// Adds a shortcode for the donation button
add_shortcode('donation-button', 'donation_button');

// Check if the paypal-order variable is set
if(isset($_GET['paypal-order'])) {
   // Makes sure WordPress and all the plugins are loaded before running the forward_to_paypal function
   add_action('wp_loaded', 'forward_to_paypal', 1);

   // Define the forward_to_paypal function
   function forward_to_paypal() {
       // Define a variable and some arrays
       $amount = (float) $_GET['paypal-order'];

       // Check if the chosen value in the $ra array exists
       if(isset($ra[$option])) {
           // If it does exist, then make an s2Member shortcode and make it output an URL, and then save the URL in the $url variable
           $url = do_shortcode('[s2Member-PayPal-Button level="1" ccaps="" desc="a sample description here" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="insightfulastrology.tv" ta="0" tp="0" tt="D" ra="' . $option . '" rp="1" rt="L" rr="BN" rrt="" rra="1" image="default" output="url" /] ');

           // Redirect user to the resulting shortcode URL
           header('Location: ' . $url);
       }

       // Else, just redirect to the page the user was in
       header('Location: ' . $_SERVER['HTTP_REFERER']);
   }
}
Posted: Sunday Nov 25th, 2012 at 5:58 pm #32551
Eduan
Username: Eduan
Moderator

Not sure if that would cause the problem. I’ve had a similar problem with a client, where it would never redirect correctly in Internet Explorer. What browser are you using?

Also, could you try these common troubleshooting tips: Knowledge Base » Common Troubleshooting Tips

– Eduan

Posted: Sunday Nov 25th, 2012 at 7:09 pm #32553
Pam
Username: pdblizzard

Does not work in IE, Firefox or Chrome. I’ll do some quick troubleshooting but it looks like I can’t use the donation code example. I’ll probably begin working right away on passing variables into a short code.

Thank you so much for your time. I know that it can be done, it’s finding the right inroads :)

Posted: Sunday Nov 25th, 2012 at 7:30 pm #32555
Eduan
Username: Eduan
Moderator

No problem. Here’s the link to variables in shortcodes: Knowledge Base » Using variables in a shortcode

Let’s hope it’s nothing too difficult. :)

Viewing 16 replies - 1 through 16 (of 16 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.