skip to Main Content

I want to ask everyone to know about WooCommerce WordPress. I have a page for list product WooCommerce, in there have information like title and price and button "Add to cart" when the cursor hovers to the product. I want to disable or hide the button when my point is insufficient for the product. Is it possible to do that? I am using plugin GamiPress – WooCommerce Points Gateway for payment with points

Above this example for a product (100 points)

enter image description here

Above this my current point (0 point)

enter image description here

2

Answers


  1. Use remove_action() to remove add to cart in certain conditions.

    $point = 0;
    if($point == 0){
        remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
    }
    
    Login or Signup to reply.
  2. You can add the disabled attribute on the button if points are insufficient for the product. For example, you can get the total points in the var pints and if the points are less than 100 you add disable attribute to the button.

    var point;
    if(point<100 ){
    $('.add-to-cart').attr('disabled');
    
    
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search