Jump to content
Sign in to follow this  
tanuj225

How to limit user to purchase once with woocommerce

Recommended Posts

Hello

i am working with woocommerce where i have products displayed on shop page 

now i want that user can purchase product only once.

 

So i am trying to get the orders of user and trying to redirect to the user to my account page 

so i am using following code in functions.php

 

 
  
 <?php
 $user_id = get_current_user_id();
        $current_user= wp_get_current_user();
        $customer_email = $current_user->email;
        $args = array(
            'post_type' => 'product',
            'posts_per_page' => 12
            );
        $loop = new WP_Query( $args );
        if ( $loop->have_posts() and is_page( 1036 )) {
            
echo "has post";
}
 
          else
    {
     echo do_shortcode('[
recent_products per_page=20" columns="4" orderby="rand" order="rand]');
     
    }
 
 
 ?>
 
but its not working anyone can help.

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.