logo
down
shadow

I want to hide woocommerce products from the shop loop which the user already puchased


I want to hide woocommerce products from the shop loop which the user already puchased

Content Index :

I want to hide woocommerce products from the shop loop which the user already puchased
Tag : wordpress , By : Thomas Gueze
Date : November 24 2020, 05:44 AM

To fix the issue you can do hey you can use this to hide or remove the product from the shop that is already purchased
   add_action( 'woocommerce_after_shop_loop_item', 'user_logged_in_product_already_bought', 30 );

function user_logged_in_product_already_bought() {
    if ( is_user_logged_in() ) {
        global $product;
        $current_user = wp_get_current_user();
        if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product->get_id() ) ) 

        ?>
            <script>
                var productId = '<?= $product->get_id();  ?>';
                jQuery(document).ready(function(){
                   jQuery(".products li .post-"+productId).remove(); 
                });
            </script>
        <?php


    }
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Woocommerce - Hide shop for unregistered user


Tag : php , By : Franky
Date : March 29 2020, 07:55 AM
Does that help You don't need to modify Woocommerce template file for what you are trying to achieve. Just add the following code to functions.php
function custom_redirect() {        
    if( is_shop() && ! is_user_logged_in() ) {
        wp_redirect( home_url() ); 
        exit();
    }   
}

add_action("template_redirect","custom_redirect");

hide some category names from products in woocommerce shop


Tag : php , By : Simone
Date : March 29 2020, 07:55 AM
it helps some times WooCommerce provides some coarse control over displaying sub categories in your shop/category pages with the “Show subcategories on category pages” and “Show subcategories on the shop page” options on the WooCommerce > Settings > Catalog > Catalog Options section.
These controls are all-or-nothing though: show all subcategories on the category pages, or show all subcategories on the shop page. If you want finer-grained control, for instance displaying only certain subcategories on the shop or particular subcategories on a given category catalog page, you’ll need to write a little custom code, and there are a couple of approaches you can take.

Hide out of stock products only on shop archive pages in Woocommerce


Tag : php , By : Bimal Poudel
Date : March 29 2020, 07:55 AM
this one helps. Updated: Using a custom function hooked in woocommerce_product_query_meta_query filter hook, targeting non "out of stock" products on shop archive pages only:
add_filter( 'woocommerce_product_query_meta_query', 'shop_only_instock_products', 10, 2 );
function shop_only_instock_products( $meta_query, $query ) {
    // Only on shop archive pages
    if( is_admin() || is_search() || ! is_shop() ) return $meta_query;

    $meta_query[] = array(
        'key'     => '_stock_status',
        'value'   => 'outofstock',
        'compare' => '!='
    );
    return $meta_query;
}

WooCommerce: Hide Product Loop on Shop Page


Tag : php , By : cthulhup
Date : March 29 2020, 07:55 AM
it helps some times I am using the following code to hide the product loop on the Woo shop page: , Change your wc_no_products_found function with this one
add_action( 'woocommerce_no_products_found', function(){

 if(is_shop()) {
    remove_action( 'woocommerce_no_products_found', 'wc_no_products_found', 10 );
}
}, 9 );

hide category name under products on woocommerce shop page


Tag : wordpress , By : user187301
Date : March 29 2020, 07:55 AM
To fix the issue you can do I checked your website. Add this to Custom CSS to hide the categories of products on shop page:
a.cmsmasters_cat_color {
     display: none;
}
Related Posts Related QUESTIONS :
  • how to add more text below blog title in WordPress
  • Wordpress - Theme stuck at loading after migration
  • Is it possible in WordPress to add editable sections in the dashboard?
  • How to test custom classes of my Wordpress theme using phpunit?
  • how to set up 2 virtualhosts with the same root adress?
  • How Can I remove a particular product from an completed order in woocommerce?
  • How to regenerate WordPress thumbnails via Bash?
  • Gravity Form Plugin not Working on Microsoft Edge
  • How to deploy react images inside a wordpress plugin?
  • Cannot get error count in CodeMirror editor
  • Show product thumbnail on woocommerce New Order email
  • how to redirect everysubdomain to main domain? like anysubdomain.domain to domain in wordpress
  • Googled, and failed: Looking for a really good video on WordPress
  • get latest activity from linkedin into website
  • File path without domain name from wp_get_attachment_url()
  • Post repeating in Infinite Scroll in Wordpress
  • wordpress: body_class producing "home" class on custom url
  • Mod Rewrite Rule to take article ID from URL and place a Slash before it
  • How to disable submit button and change text on form submit at Wordpress "contact form 7"
  • .htaccess 301 redirect not working on WordPress site
  • How can i override function wp_insert_user() on Wordpress
  • Does WordPress have the functionality to create a new subdomain?
  • Send thank you email in wordpress after user is redirected from other website
  • WordPress page: Why is <main> tag wrapped by <p> while <div> is not?
  • LESS Compiler PHP with Wordpress 4.0.1 and Bootstrap 3
  • Wordpress tinymce dialog box Body Element & Attribute Formal Documentation
  • How to fetch WP_User_Query with multiple role arguments
  • .htaccess authentication with wordpress
  • Wordpress html5 input date time
  • Woocommerece. Single product page
  • Wordpress Site Broken after Changing URL
  • Adsense Ads not working in Google AMP cache
  • FTP permissions on Wordpress Bitnami AWS install?
  • Advanced Wordpress categories listing
  • wordpress nginx ssl redirect loop
  • How to download wordpress source code?
  • Wordpress images not displaying in pages
  • Create oembed previews for my selfhosted WP?
  • Pagination for Custom Post Types using Shortcode not showing
  • WordPress array in query meta_value
  • How to style custom shortcode in WordPress editor
  • How to Redirect URL using .access from domain.org/xxx/archive/ to domain.org/archive /wordpress
  • Change stylesheet depend on time in Wordpress
  • Installing Wordpress on IIS 7 - invalid root password or failed to connect
  • Where I set the resolution to enter on tablet with mobile theme?
  • How to add custom html in a genesis theme between entry-meta and entry-content
  • WordPress: how to display only certain post types on page?
  • How to mark custom pages to be removed in a Wordpress plugin?
  • Wordpress Permalinks in Nginx 404 error
  • I need to get all tags from woo commerce products in a page
  • wc-api-node woocommerce api missing data
  • ReCAPTCHA v3 Google Badge is drawn underneath page content
  • Is WP-CLI incompatible with Bitnami's Wordpress install on AWS Lightsail?
  • Change role after purchasing a specific product on WooCommerce
  • Docker containers starts at different subtnets
  • Mailchimp embed code not working in wordpress
  • Woo Commerce Add to cart replace with a message when it hidden on Variable Product
  • Woocommerce won't add my custom fee to the cart total
  • Woocommerce not sending Emails on cancelled order
  • Wordpress - different post title on frontend than in url
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com