PMPro & Woocommerce redirects
-
Hello
I have integrated PMP with Woo, followed all instructions as per PMP guides/videos, and Woo settings are spot on I believe.
However, I cannot for the life of me redirect a guest user to the checkout page after selecting a membership product. They just get redirected to the basket – which is empty.
This was a problem when I installed Subscriptions for Woo plugin. So I deactivated this, and it worked after adding some code to my functions file, but it’s stopped working and users are just being redirected to an empty basket again!
The code snippet I used in functions was;
/*** PMP redirect membership selection to Woo Checkout ***/ add_action('template_redirect','pmpro_woocommerce_redirect_checkout'); function pmpro_woocommerce_redirect_checkout(){ $id = get_option('pmpro_checkout_page_id'); global $post; if($post->ID == $id && !empty($_REQUEST['level'])){ global $wpdb; $product_id = $wpdb->get_var($wpdb->prepare("SELECT pm.post_id FROM {$wpdb->postmeta} as pm LEFT JOIN {$wpdb->posts} as p ON p.ID=pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %d AND p.post_status='publish'",'_membership_product_level',$_REQUEST['level'])); if(!empty($product_id)){ $checkout_url = WC()->cart->get_checkout_url(); if ( sizeof( WC()->cart->get_cart() ) > 0 ) { foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { $_product = $values['data']; if ( $_product->id == $product_id ) $found = true; } // if product not found, add it if ( ! $found ) WC()->cart->add_to_cart( $product_id ); wp_redirect( $checkout_url); }else{ // if no products in cart, add it WC()->cart->add_to_cart( $product_id ); wp_redirect( $checkout_url); } exit(); } } }
I also have Better Usability for Woo plugin installed which allows me to select from the backend to bypass cart/basket and redirect straight to checkout.
I simply don’t know what’s happening.
In addition to this, I have searched all of Google (for days now) to find a clear explanation how to properly setup PMP and Woo integration. The guides just say to not use PMP pages and select Woo pages instead – but what pages should be used for each? Should all be Woo MyAccount? What about Membership confirmation & cancellation page? What about login? I have a custom login page, with PMP login shortcode on it. It provides a link to login or register. When it was possible (in the short time the code/settings worked) to select a membership and proceed to the checkout page (bypassing cart/basket), I was taken to the Woo registration form with the product in the cart and could pay using Woo payments. It created a user and the user details submitted there were displayed within both PMP members details, and Woo user details – Great! But now I cannot register/go to checkout.
And, if I set the PMP login page to Woo MyAccount with the settings for users to create account on MyAccount page, the logged-out MyAccount page just issues an error for too many redirects, as if Woocommerce is redirecting back to PMP login.
Urgh!! I’m getting really fed up now with this. It seems like it should be so simple. And it also seems that many PMP users have been asking the same Qs over Google and in this forum, but without any solution, and tickets seem to be closed and marked “resolved” without any answer. If PMP is to integrate with Woo seemlessly, and a user needs to login/register through Woo rather than PMP, why isn’t there clear complete instructions of how to do so?
At this point, I’m really glad I haven’t yet purchased any additional PMP addons, but it was on my radar to do so once I’m ready to launch cuz I did really like this membership plugin. But my patience is really wearing thin now.
Please can someone just offer some clear instructions of how to setup PMP to sell memberships through Woocommerce as products, detailing which pages exactly should be selected, how users will login/register fully, whether the PMP membership details need to be shown to users frontend if it’s being purchased through Woo instead, and the rest!
Thank you, and apologies for this rant, but I’ve been going around and around in circles, and the lack of explanation anywhere is just tiring.
- The topic ‘PMPro & Woocommerce redirects’ is closed to new replies.