How to convert an Ecommerce to a catalog using WooCommerce without plugins

If you’re looking to transform your online store into a catalog using WooCommerce, you’ve come to the right place. In this article, I’ll show you how to hide product prices, remove the cart and checkout pages, and change the “Add to Cart” button to “Contact Us,” all without the need for additional plugins.

Hide Product Prices

To hide product prices and display a generic message instead, you can use the following PHP code:

// Function to hide product prices
add_filter('woocommerce_get_price_html', 'hide_product_prices');
function hide_product_prices($price) {
    return 'Price available upon request';
}

 

Hide the Cart Page

It’s important to redirect users away from the cart page if they try to access it. This can be achieved with the following code:

// Function to hide the cart page
add_action('template_redirect', 'hide_cart_page');
function hide_cart_page() {
    if (is_cart()) {
        wp_redirect(get_permalink(wc_get_page_id('shop')));
        exit;
    }
}

 

Hide the Checkout Page

Similarly, you need to hide the checkout page to prevent users from making purchases. Here’s the code needed to accomplish that:

// Function to hide the checkout page
add_action('template_redirect', 'hide_checkout_page');
function hide_checkout_page() {
    if (is_checkout()) {
        wp_redirect(get_permalink(wc_get_page_id('shop')));
        exit;
    }
}

 

Change the “Add to Cart” Button to “Contact Us”

Finally, changing the “Add to Cart” button text to “Contact Us” can help encourage direct communication with customers. This code will achieve that change:

// Function to replace "Add to Cart" button with "Contact Us"
add_filter('woocommerce_loop_add_to_cart_link', 'replace_add_to_cart_button');
function replace_add_to_cart_button($link) {
    global $product;

    $link_text = __("Contact Us", "woocommerce");
    $link = sprintf('<a href="%s" data-product_id="%s" data-product_sku="%s" class="button %s">%s</a>', esc_url($product->get_permalink()), esc_attr($product->get_id()), esc_attr($product->get_sku()), esc_attr(isset($class) ? $class : 'button'), esc_html($link_text));
    
    return $link;
}

 

Implementation

Simply place this code in the functions.php file of your active WordPress theme, and you’ll see the changes reflected on your site.

Always remember to make a backup of your site before making code changes. With these simple steps, you’ll be able to transform your online store into a catalog without the need for additional plugins.

I hope this article has been helpful to you. If you have any questions or need further assistance, feel free to leave a comment!

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to Top
0
Would love your thoughts, please comment.x
()
x