P
P
Pan Propan2019-01-28 18:06:24
WordPress
Pan Propan, 2019-01-28 18:06:24

How to remove add to cart button in Woocommerce custom theme?

Hello, friends.
With php Pts bad sign, tell me please in solving a simple problem.
I'm using a custom theme. There is a /wp-content/themes/hestia-mebel/inc/compatibility/woocommerce/functions.php
file in the theme directory with the following content

spoiler

/**
* Change the main content for single product listing
*/
function hestia_woocommerce_template_loop_product_title() {
global $post;
$current_product = wc_get_product( get_the_ID() );
?>
<?php
$product_categories = get_the_terms( $post->ID, 'product_cat' );
$i = false;
if ( ! empty( $product_categories ) && apply_filters( 'hestia_show_category_on_product_card', true ) ) {
/**
* Show only the first $nb_of_cat words. If the value is modified in hestia_shop_category_words filter with
* something lower than 0 then it will display all categories.
*/
$nb_of_cat = apply_filters( 'hestia_shop_category_words', 2 );
$nb_of_cat = intval( $nb_of_cat );
$index = 0;
if ( $nb_of_cat !== 0 ) {
echo '';
foreach ( $product_categories as $product_category ) {
if ( $index < $nb_of_cat || $nb_of_cat < 0 ) {
$product_cat_id = $product_category->term_id;
$product_cat_name = $product_category->name;
if ( ! empty( $product_cat_id ) && ! empty( $product_cat_name ) ) {
if ( $i ) {
echo ' , ';
}
echo '' . esc_html( $product_cat_name ) . '';
$i = true;
}
$index ++;
}
}
echo '';
}
}
?>
<?php
/**
* Explode title in words by ' ' separator and show only the first 6 words. If the value is modified to -1 or lower in
* a function hooked at hestia_shop_title_words, then show the full title
*/
$title = the_title( '', '', false );
$title_in_words = explode( ' ', $title );
$title_limit = apply_filters( 'hestia_shop_title_words', - 1 );
$title_limit = intval( $title_limit );
$limited_title = $title_limit > - 1 ? hestia_limit_content( $title_in_words, $title_limit, ' ' ) : $title;
?>
<?php echo esc_html( $limited_title ); ?>
<?php
if ( $post->post_excerpt ) :
/**
* Explode the excerpt in words by ' ' separator and show only the first 60 words. If the value is modified to -1 or lower in
* a function hooked at hestia_shop_excerpt_words, then use the normal behavior from woocommece ( show post excerpt )
*/
$excerpt_in_words = explode( ' ', $post->post_excerpt );
$excerpt_limit = apply_filters( 'hestia_shop_excerpt_words', 60 );
$excerpt_limit = intval( $excerpt_limit );
$limited_excerpt = $excerpt_limit > - 1 ? hestia_limit_content( $excerpt_in_words, $excerpt_limit, ' ' ) : $post->post_excerpt;
?>
<?php echo wp_kses_post( apply_filters( 'woocommerce_short_description', $limited_excerpt ) ); ?>
<?php endif; ?>
<?php
$product_price = $current_product->get_price_html();
if ( ! empty( $product_price ) ) {
echo '';
echo wp_kses(
$product_price,
array(
'span' => array(
'class' => array(),
),
'del' => array(),
)
);
echo '';
}
?>
<?php hestia_add_to_cart(); ?>
<?php
}

I actually need to remove the output of the button, that is, the following lines.
<div class="stats">
   <?php hestia_add_to_cart(); ?>
</div>

How to do it right so that the changes are not overwritten in the update?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2019-01-28
@azerphoenix

Hello!
https://www.cloudways.com/blog/how-to-remove-hide-...

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');

Add to functions.php
Another option is Yith Woocommerce Catalog mode (plugin turns on catalog mode and removes buttons, cart, etc.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question