Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $products = get_field('product');
  2.  
  3. if (get_field('product')) {
  4.     foreach ($products as $product) {
  5.         $current_user = wp_get_current_user();
  6.    
  7.         if ( is_user_logged_in() && (wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product->ID ))) {        
  8.             return true;
  9.         } else {               
  10.             echo '<div>' . do_shortcode('[add_to_cart id="' . $product->ID . '" style=""]') . '</div>';
  11.         }
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement