Tagged: require log in to purchase
December 15, 2009 at 12:55 am #560zzman44Member
Is it possible for when someone clicks “Add to Cart” to be redirected to the login page if theyre not logged in? And once they log in it brings them to the Shopping Cart? Basically to require users to be logged in in order to Add to Cart and then checkout, while still displaying the Add to Cart button to users who aren’t logged in. (I’m kind’ve new to coding, so not sure if this is easy or not possible)
Thanks though, really love this plugin and I hope this can be done.December 15, 2009 at 7:31 am #16741amin007Participant
Yeah this should be easy to implement. All you gotta do is check if the visitor is logged in when they hit the “Add to Cart” button. If they are logged in then let them process as usual or else redirect them to the Login page.
Search for the following piece of line in the code (this is what gets executed when the button is clicked:
You will need to add the check for
is_user_logged_in()inside this if statement block and redirect to the login page if the user is not logged in.December 15, 2009 at 9:13 pm #16742zzman44Member
I’m sorry, I really have almost no idea how to do this. Everywhere I try and add code it is telling me I’ve made a fatal error and it deactivates the plugin on me. Would it be too much trouble if you could add it to my code? I’m fairly certain this is the if block, correct? It’s not that big of a deal, it’s just a personal pet peeve I would have with orders from unregistered users. Thank you very much so if you can!
$count = 1;
$products = $_SESSION;
foreach ($products as $key => $item)
if ($item == $_POST)
$count += $item;
$products = array();
if ($count == 1)
$price = $_POST[$_POST];
$price = $_POST;
$product = array(‘name’ => stripslashes($_POST), ‘price’ => $price, ‘quantity’ => $count, ‘shipping’ => $_POST, ‘cartLink’ => $_POST, ‘item_number’ => $_POST);
$_SESSION = $products;
$checkout_url = “http://www.mydomain.com/checkout”;
$redirection_parameter = ‘Location: ‘.$checkout_url;
}January 26, 2010 at 3:00 am #16743joanMember
As always you are doing a fantastic job with Simple Paypal. I was wondering if the above ‘require login’ could be built on so that the users name is passed to Paypal’s form ?
Regards, JoanJanuary 26, 2010 at 6:00 am #16744amin007Participant
I can give you some guidance on how to include the username but I don’t plan to add this to the shopping car cause it falls under the responsibility of a membership plugin.
- You must be logged in to reply to this topic.