@Barry: Single Membership Subscription Buy Now Button

@Barry,

Just want to check if this is sort of the right direction for creating a buy now button? So that users can purchase single subs one at a time and thereby belong to multiple subscriptions

Basically I’m checking if using

<?php do_action('membership_purchase_button', $subscription, $pricing, $user_id); ?>

is the right direction???

I quickly created a short code to handle the buynow button here is the code and screen shots.

Read Me First:

I know shortcode buynow button isn’t ideal and the best solution would be to have a single buy now page that auto generates the subscription buy now button for specific subscription id

yourdomain.com/buy/?product=4

But I’m just testing the waters :wink:

Oh, love the private subscriptions – they work great :wink:

Here is BuyNow Shortcode:

add_shortcode('buynow', 'buynow_shortcode');
function buynow_shortcode( $atts, $content = null ) {

$defaults = array( "message" => 'you need an account',
"sub_id" => '',
);

extract(shortcode_atts($defaults, $atts));
if (function_exists(current_user_has_subscription)) {

if (!is_user_logged_in()) {
return $message;

} else {

$current_user = wp_get_current_user();
$user_id = $current_user->ID;

$subscription = new M_Subscription($sub_id);
?>
<div class='subscription'>
<div class='description'>
<h3><?php echo $subscription->sub_name(); ?></h3>
<p><?php echo $subscription->sub_description(); ?></p>
</div>

<?php
$pricing = $subscription->get_pricingarray();

if($pricing) {
?>
<div class='priceforms'>
<?php do_action('membership_purchase_button', $subscription, $pricing, $user_id); ?>
</div>
<?php
}
?>
</div>
<?php
}

}
}

Here Are Screenshots:

  • Jonathan
    • The Incredible Code Injector

    Thanks Phil, appreciate that you’ve pinged barry, and glad you had a look over and don’t see an issue :wink:

    Can’t get a free subscription to work using the above method. I see it (free sub button) is coded that it needs to run on [subscriptionform] to validate / process.

    I think a checkout page is the right way to handle this. A page that catches sub id and process that subscriptions purchase options. So on sales pages user can add buynow button with link to /checkout/?sub_id=4 or something like that?

  • poltaj
    • Site Builder, Child of Zeus

    Hi Jonathan,

    I was looking for “Multiple subscriptions” and I found this + another post with the link to staypress, which is a project I follow since first alpha was out. (used to work in the hotel business)

    I’d like to ask if you could help me mod (not for free) membership plugin, similarly to what you did for staypress.com?

    Other than that I’d like to talk to you about another opportunity… where your project’s presence could be a great asset for both you and me…

    My email paolotaiani [at] gmail.com

    Thanks in advance for anything you can do!

    Paolo

  • Barry
    • DEV MAN’s Mascot

    I’d like to ask if you could help me mod (not for free) membership plugin, similarly to what you did for staypress.com?

    I’m actually rolling that functionality into membership itself. I’ve got a membership update due out which fixes a few bugs but the next release after that will have the option of a completely new sign-up functionality, plus “Buy content” button functionality so people can purchase content directly from a post / page.

  • Jonathan
    • The Incredible Code Injector

    @paoltaia,

    Sorry for late reply – Been traveling :wink:

    I believe you were directing your response to barry. Staypress is his baby – and as he says, this functionality is being built into the membership plugin. This is great news for all of us.

    As for customization to the plugin itself. (if you were directing that to me based on my half attempt to create a buy now system) I have zero time at the moment for new projects as my wife is due in Jan. So we are both trying to ensure that we spend the first couple months with the little one, which means I have have cut back on any new projects, and have put lots of current ones on hold. You can try the developers section:

    https://premium.wpmudev.org/wpmu-jobs/developers/

    But, I reckon that the next release is going to blow us all away.

    @Barry, Woot! Sounds great :wink:

  • poltaj
    • Site Builder, Child of Zeus

    Hi Jonathan,

    thanks for your kind reply!

    I thought you were the man behind staypress, got confused!

    For the membership mod, I spent the week end and did it myself.

    Starting from your shortcode button code I managed to do everything I wanted…

    I’ll wait for the new version to see if with it I can do even better, but for now I’m more than satisfied…

    Wish you and your wife lot of joy with the little one!

    @Barry : Staypress looks awsome, wish I’d have more time to look into it! One day I will…

    Best,

    Paolo

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.