pmpro woocommerce add on

Home Forums Legacy Support Support queries Setup issues pmpro woocommerce add on

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #92896
    chinolz
    Spectator
    Hi, i have used this code to use woocommerce checkout instead of pmpro checkout. However if the cart is empty the user is unable to finish the checkout. The code is only working if there is an item in the cart already* 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 post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value = %d",'_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(); } } }
    #92897
    chinolz
    Spectator
    This reply has been marked as private.
    #93023
    Anshuman Sahu
    Keymaster
    Okay please make sure that in woocommerce settings "Redirect to cart page after successful additon" enabled from wp-admin-> woocommerce-> settings -> products -> display : http://prntscr.com/e2zuoc Second thing that you need to make sure is your membership level should be connected to only one product ,not in multiple product.This instruction is also mentioned in the tip .
    #93035
    chinolz
    Spectator
    Redirect to cart page after successful additon is enabled and it is connected to only one product still not working, it only works if there is already 1 product in the cart already
    #93036
    chinolz
    Spectator
    This reply has been marked as private.
    #93248
    Anshuman Sahu
    Keymaster
    This reply has been marked as private.
    #93278
    chinolz
    Spectator
    This reply has been marked as private.
    #93287
    chinolz
    Spectator
    solved it it was wpengine Varnish caching layer excluded cart/checkout pages on its working now
    #93379
    Anshuman Sahu
    Keymaster
    Thanks for confirming . Marking as resolved and closing the topic .
Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘pmpro woocommerce add on’ is closed to new replies.