Home > Enterprise >  How can we install the custom TOP BAR PLUGIN FOR WORDPRESS & WOOCOMMERCE using the code method?
How can we install the custom TOP BAR PLUGIN FOR WORDPRESS & WOOCOMMERCE using the code method?

Time:06-10

I want to add the top bar plugin to my website using the code method, but I can't find a way to get this done. If anybody has some technical knowledge related to the woo-commerce plugins please provide me a simplified solution for this, I'll be very grateful to you.

CodePudding user response:

Adding top bar plugin to any website is very easy. I assume you are using TOP BAR PLUGIN FOR WORDPRESS & WOOCOMMERCE this plugin. The solution to this plugin is very easy. As we already know there are 2 methods available in this solution. 1 is manual installation, and the other is a custom installation using the code method. You need to enter the following code for initializing the setup.

add_action( 'init', array($this, '_change_loop_add_to_cart'), 10 );

function _change_loop_add_to_cart() {
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    add_action( 'woocommerce_after_shop_loop_item', '_template_loop_add_to_cart', 10 );
}

function _template_loop_add_to_cart() {

    global $product;

    if ( ! $product->is_type( 'variable' ) ) {
        woocommerce_template_loop_add_to_cart();
    }
}

This is the easiest method to install this plugin on your website. Let me know if this works for you.

  • Related