Hello WP community, I am trying to build a WP e-commerce site
and I have run into an issue. I'll give some background first.
s2member is a free plug-in to handle memberships/subscriptions
and woo-commerce is a free plug-in to handle e-commerce for a website. I am trying to create a Level 0 membership with s2member where non-registered users cannot purchase(but can see catalog) unless signed-in. I am trying to achieve this by making the "add the cart" button(s) in website, powered by woo-commerce, redirect to the account
login/sign-on page. After logging in/signing up,can a visitor attempt
to buy products via "add to cart".
I put my "integration code" for the 2 plug-ins inside my functions.php file of my wootique theme.
My current code is something like this:
<?php
add_filter('add_to_cart_redirect','redirect_to_login');
function redirect_to_login() {
global $woocommerce;
if(is_user_not_logged_in()){
$login_page = get_permalink(get_option('10'));
// above line goes to accounts page
return $login_page;
}
} ?>
The above code doesn't work. However, if I try something like this
(not what I need), it works:
<?php
if(is_user_not_logged_in()){
echo "<p>Function reaches this point</p>";
} ?>
Narrowing down the problem, its mainly the woo-commerce
part(s) of the code that doesn't seem to work here.
I would like to know from the more experienced WP users here
if the problem is the syntax and coding and/or do I have
to put the coding at another place. I will appreciate
any thoughtful help.
Last note: I am aware of a membership ship plug-in made
by Woo called groups. I haven't tried it and I am guessing
its compatible with with woocommerce; however, I want
to solve my issue with s2member because I believe s2member
is more feature-rich and has a larger use in client projects.