• Resolved Magnuspil

    (@magnuspil)


    Hi,

    Would it be possible to force a membership onto the cart, if a user is trying to buy a product, but isn’t a member? So if i’m not a member, it will add a membership to cart/checkout alongside the product i’m buying. I have made the function like this:

    function force_membership_on_cart() {
        if(pmpro_hasMembershipLevel('1')) {
            // go to checkout
            
        } else {
    //force to cart here
        }
    }

    I have searched as much as i have possibly could in the source files, but i can’t seem to find any add to cart/checkout/gateway code. The membership should be non removal.

    Any suggestions here?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Andrew Lima

    (@andrewza)

    Hi @magnuspil,

    Thank you for getting in touch and choosing Paid Memberships Pro.

    I did a quick search and found this on the WooCommerce docs – https://docs.woocommerce.com/document/automatically-add-product-to-cart-on-visit/

    You will be able to add !pmpro_hasMembershipLevel('1'); to line 7 of the first gist file when checking if the user is an admin. If the user doesn’t have a membership level it will then add the product to the cart.

    I hope this helps ??

    • This reply was modified 7 years, 9 months ago by Andrew Lima.
    Thread Starter Magnuspil

    (@magnuspil)

    Hi Andrew, wasnt what i meant.

    It has to be the Membership it should add to the cart, not the product. All products require a membership to be bought, but is still visible on site. We want to have the following: If i’m a guest, and i click add to cart on the checkout page, then it should add the membership to the cart, and start the membership as soon as the order is finished. If i was a member though, it wouldn’t add a membership, since i’m already a member.

    I do NOT use WooCommerce Subscriptions.
    Thanks so far!

    • This reply was modified 7 years, 9 months ago by Magnuspil.
    Plugin Author Andrew Lima

    (@andrewza)

    Thank you for the feedback, for some clarification, how are you selling your Paid Memberships Pro memberships?

    Are you using the Paid Memberships Pro WooCommerce integration add-on: https://www.paidmembershipspro.com/add-ons/free-add-ons/pmpro-woocommerce/?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Forcing membership on woocommerce cart’ is closed to new replies.