Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1014053

    Hello there,

    I would like to know what is the best way to hide (or even beter remove) the “read more” button from the WooCommerce category page.
    Also the delimiter should be removed so only the show details link will still be there.

    I know this can be done with CSS but I prefer to remove it.

    I hope to hear from you.

    #1014194

    Hey SoWeAre,

    Thank you for using Enfold.

    You can add this code in the functions.php file to remove the default action hook and recreate it without the details button.

    #
    # add ajax cart / options buttons to the product
    #
    
    remove_action( 'woocommerce_after_shop_loop_item', 'avia_add_cart_button', 16);
    add_action( 'woocommerce_after_shop_loop_item', 'avia_add_cart_button_mod', 16);
    function avia_add_cart_button_mod()
    {
    	global $product, $avia_config;
    
    	if ($product->get_type() == 'bundle' ){
    		$product = new WC_Product_Bundle($product->get_id());
    	}
    
    	$extraClass  = "";
    
    	ob_start();
    	woocommerce_template_loop_add_to_cart();
    	$output = ob_get_clean();
    
    	if(!empty($output))
    	{
    		$pos = strpos($output, ">");
    
    		if ($pos !== false) {
    		    $output = substr_replace($output,"><span ".av_icon_string('cart')."></span> ", $pos , strlen(1));
    		}
    	}
    
    	if($product->get_type() == 'variable' && empty($output))
    	{
    		$output = '<a class="add_to_cart_button button product_type_variable" href="'.get_permalink($product->get_id()).'"><span '.av_icon_string("details").'></span> '.__("Select options","avia_framework").'</a>';
    	}
    
    	if(!in_array($product->get_type(), array('subscription', 'simple', 'bundle')))
    	{
    		$extraClass  = "single_button";
        }
    
    	if(empty($extraClass)) $output .= " <span class='button-mini-delimiter'></span>";
    
    	if($output && !post_password_required() && '' == avia_get_option('product_layout',''))
    	{
    		echo "
    <div class='avia_cart_buttons $extraClass'>$output</div>
    ";
    	}
    }

    Best regards,
    Ismael

    #1014206

    Hi there,

    First of all thanks for your reply!
    Is it also possible to do it the other way around? I would like to remove the add to cart button but I like to show the detail button there.

    #1014579

    Hi,

    Sure you can use this code instead:

    
    add_action('init', 'avia_change_add_to_cart_buttons', 10); 
    function avia_change_add_to_cart_buttons()
    {
    	remove_action( 'woocommerce_after_shop_loop_item', 'avia_add_cart_button', 16);
    	add_action( 'woocommerce_after_shop_loop_item', 'avia_add_cart_button_mod', 16);
    }
    
    function avia_add_cart_button_mod()
    {
    	global $product, $avia_config;
    
    	if ($product->get_type() == 'bundle' ){
    		$product = new WC_Product_Bundle($product->get_id());
    	}
    
    	$extraClass  = "";
    
    	ob_start();
    	woocommerce_template_loop_add_to_cart();
    	$output = ob_get_clean();
    
    	if(!empty($output))
    	{
    		$output = '<a class="button show_details_button" href="'.get_permalink($product->get_id()).'"><span '.av_icon_string("details").'></span>  '.__("Show Details","avia_framework").'</a>';
    	}
    
    	if($output && !post_password_required() && '' == avia_get_option('product_layout',''))
    	{
    		echo "
    <div class='avia_cart_buttons single_button'>$output</div>
    ";
    	}
    }
    
    

    Best regards,
    Peter

    #1014585

    Thanks! Works fine!

    #1014616

    Hi,

    Great, glad we could help. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.