Tagged: woocommere
-
AuthorPosts
-
September 25, 2018 at 9:06 am #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.
September 25, 2018 at 2:32 pm #1014194Hey 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,
IsmaelSeptember 25, 2018 at 2:56 pm #1014206Hi 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.September 26, 2018 at 8:45 am #1014579Hi,
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,
PeterSeptember 26, 2018 at 8:56 am #1014585Thanks! Works fine!
September 26, 2018 at 9:46 am #1014616 -
AuthorPosts
- You must be logged in to reply to this topic.