Skip to content
OK Plugin
  • Trang chủ
  • Blog
  • Plugin Woocommerce
  • Plugin Hỗ trợ SEO
  • Plugin Khác
  • Plugin Miễn phí
OK Plugin

Ẩn nút thêm vào giỏ hàng hoặc giá trong WooCommerce

By Siêu Nhím 20/01/2024 0
an nut them vao gio hang hoac gia trong woocommerce 600x333 1

Bạn muốn ẩn nút thêm vào giỏ hàng (add to cart) hoặc ẩn cả giá trong trong WooCommerce ra khỏi trang thông tin sản phẩm thì sau đây muaplugin.com chia sẻ với bạn 1 số đoạn code giúp bạn điều đó. Bạn chỉ việc thêm đoạn code vào trong file functions.php trong child theme là xong.

Ẩn nút thêm vào giỏ hàng hoặc giá trong WooCommerce

Ẩn nút thêm vào giỏ hàng trong WooCommerce

Để ẩn nút thêm vào giỏ hàng bạn sử dụng đoạn code dưới đây

add_action( 'init', 'paulc_hide_add_to_cart_button', 1000 );
function paulc_hide_add_to_cart_button() {
    add_filter( 'woocommerce_loop_add_to_cart_link', '__return_null' );
    add_filter( 'wc_get_template', 'paulc_wc_get_template', 90, 2 );
}

function paulc_wc_get_template( $located, $template_name ) {
$new_path = get_stylesheet_directory_uri() . '/woocommerce/no-add-to-cart-button.php';
    $templates = array(
     'single-product/add-to-cart/simple.php',
        'single-product/add-to-cart/grouped.php',
        'single-product/add-to-cart/variable.php',
        'single-product/add-to-cart/external.php'
    );
    if( in_array( $template_name, $templates ) ) {
     return $new_path;
    }
    return $located;
}

 

Code Ẩn Giá và Nút thêm vào giỏ hàng với tất cả Khách hàng

add_action( 'init', 'paulc_hide_price_add_to_cart_button', 1000 );
function paulc_hide_price_add_to_cart_button() {
add_filter( 'woocommerce_get_price_html', '__return_false' );
    add_filter( 'woocommerce_loop_add_to_cart_link', '__return_null' );
    add_filter( 'wc_get_template', 'paulc_wc_get_template', 90, 2 );
}

function paulc_wc_get_template( $located, $template_name ) {
$new_path = get_stylesheet_directory_uri() . '/woocommerce/no-add-to-cart-button.php';
    $templates = array(
     'single-product/add-to-cart/simple.php',
        'single-product/add-to-cart/grouped.php',
        'single-product/add-to-cart/variable.php',
        'single-product/add-to-cart/external.php'
    );
    if( in_array( $template_name, $templates ) ) {
     return $new_path;
    }
    return $located;
}

Ẩn Giá và Nút nút thêm vào giỏ hàng khi khách hàng chưa đăng nhập

add_action( 'init', 'paulc_hide_price_add_to_cart_button', 1000 );
function paulc_hide_price_add_to_cart_button() {
if( is_user_logged_in() )
     return;  
add_filter( 'woocommerce_get_price_html', '__return_false' );
    add_filter( 'woocommerce_loop_add_to_cart_link', '__return_null' );
    add_filter( 'wc_get_template', 'paulc_wc_get_template', 90, 2 );
}

function paulc_wc_get_template( $located, $template_name ) {
$new_path = get_stylesheet_directory_uri() . '/woocommerce/no-add-to-cart-button.php';
    $templates = array(
     'single-product/add-to-cart/simple.php',
        'single-product/add-to-cart/grouped.php',
        'single-product/add-to-cart/variable.php',
        'single-product/add-to-cart/external.php'
    );
    if( in_array( $template_name, $templates ) ) {
     return $new_path;
    }
    return $located;
}

 

4.6/5 - (7 bình chọn)
Share
facebookShare on FacebooktwitterShare on TwitterpinterestShare on Pinterest
linkedinShare on LinkedinvkShare on VkredditShare on ReddittumblrShare on TumblrviadeoShare on ViadeobufferShare on BufferpocketShare on PocketwhatsappShare on WhatsappviberShare on ViberemailShare on EmailskypeShare on SkypediggShare on DiggmyspaceShare on MyspacebloggerShare on Blogger YahooMailShare on Yahoo mailtelegramShare on TelegramMessengerShare on Facebook Messenger gmailShare on GmailamazonShare on AmazonSMSShare on SMS
Post navigation
Previous post

Hướng dẫn Update theme Flatsome theo cách thủ công

Next post

24 plugin WordPress WooCommerce tốt nhất cho website bán hàng

Siêu Nhím

Tổng hợp và chia sẻ plugin tốt, xài được cho wordpress

Nội dung liên quan

Ẩn nút thêm vào giỏ hàng hoặc giá trong WooCommerce

Chia sẻ theme wordpress bán hàng miễn phí, chuyên nghiệp

Ẩn nút thêm vào giỏ hàng hoặc giá trong WooCommerce

Chia sẻ theme wordpress giới thiệu công ty – doanh nghiệp miễn phí, đẹp mắt

Ẩn nút thêm vào giỏ hàng hoặc giá trong WooCommerce

Hướng dẫn cài đặt và sử dụng plugin WooCommerce Product Filter – WOOF

Leave a Comment Hủy

Blog

tai theme maia 1

Chia sẻ theme wordpress bán hàng miễn phí, chuyên nghiệp

theme payton 2

Chia sẻ theme wordpress giới thiệu công ty – doanh nghiệp miễn phí, đẹp mắt

huong dan cai dat va su dung plugin woocommerce product filter woof 400x400 1

Hướng dẫn cài đặt và sử dụng plugin WooCommerce Product Filter – WOOF

10 theme wordpress chuan seo tot nhat 2022 7 600x400 1

10 theme WordPress chuẩn SEO tốt nhất 2022

huong dan bao mat website wordpress hieu qua 600x338 1

Hướng dẫn bảo mật website WordPress hiệu quả

Plugins

isures product variations table for woocommerce 3

iSures Product Variations Table for WooCommerce

isures suggest discount code coupon plugin for woocommerce 2

iSures Suggest Discount Code (Coupon) plugin for WooCommerce

isures variation prices for woocommerce 4

iSures Variation Prices for WooCommerce

isures menu order for woocommerce 9 3

iSures Menu Order For Woocommerce

isures improve customer experience 6

iSures Improve Customer Experience

Copyright © 2025 OK Plugin - Powered by BNIX.
  • DoMinhHai
  • Envato
  • Plugin68
  • Webmau68
  • Wordpres Org
  • Yith
Offcanvas
  • Trang chủ
  • Blog
  • Plugin Woocommerce
  • Plugin Hỗ trợ SEO
  • Plugin Khác
  • Plugin Miễn phí