:::: MENU ::::
Browsing posts in: WooCommerce

WooCommerce get current user information

Today we talk WooCommerce get current user information. In this tutorial, we will get the following information of the current user, user name, user email, user id, and user group. So let’s start with our example.

 $user = wp_get_current_user(); // get current user
 $id = $user->ID; // get user id
 $name = $user->user_name; // get user name
 $email = $user->email; //get user email
 $role = $user->roles[0]; // get user role
Author: Qaisar Satti
Category: WooCommerce
Last Modified: September 30, 2020


WooCommerce remove tax for user

Today we talk about how in WooCommerce remove tax for user. We will remove the tax on basis of the user id or user groups. Now, let’s start with our example.

add_filter( 'wc_tax_enabled',  'custom_enable_tax' , 1, 2 );
function custom_enable_tax(){
   $user = wp_get_current_user(); //get current user
   if( '20' == $user->ID ){
      return false;//remove tax for current user on basis of id
   }
   if( 'customer' == $user->roles[0] ){
     return false; //remove tax for current user on basis of user group
   }
  return true,
}
Author: Qaisar Satti
Category: WooCommerce
Last Modified: September 30, 2020


WooCommere remove tax for product

Today we talk about WooCommerce remove tax for product. Sometime in the scenario, you have to remove the tax bases on some condition. In the below example, I will explain how can you achieve this functionality.

add_filter( 'woocommerce_product_is_taxable' , 'product_product_custom_tax_status' , 10 , 2);
function product_product_custom_tax_status( $product_status , $product ){
    //return true to enable Tax and false to disable tax
    if( '20' == $product->get_id() ){
        return false;
    }else {
       return true;
    }
}
Author: Qaisar Satti
Category: WooCommerce
Last Modified: September 30, 2020


WooCommerce apply discount programmatically

Today we talk about how WooCommerce apply discount programmatically. Sometimes you need to add the discount bases on some condition. Follow is the snippets how can you achieve the functionality.

Simple Product

To apply the discount on simple products use the following code.

add_filter( 'woocommerce_product_get_price' , 'products_custom_price' , 5, 2 );
function products_custom_price( $price, $product ){
      $discount = 10;
      $product_id = $product->get_id();
      if( $product_id == '20' ){
          return $price - $discount;
      }
}

Variable Product

To apply the discount on variable products use the following code.

add_filter( 'woocommerce_product_variation_get_price' , 'variation_custom_price' , 99, 2 );
function variation_custom_price( $price, $variation ){
        //Apply Discount by matching the parent Product
       $product = wc_get_product($variation->get_parent_id());
       if( '20' == $product->get_id() ){
             return $price - $discount;
       }
       //Apply Discount by matching the Product Variation
       if( '20' == $variation->get_id() ){
             return $price - $discount;
       }
}
Author: Qaisar Satti
Category: WooCommerce
Last Modified: September 29, 2020


WooCommerce remove price html

Today we talk about how WooCommerce remove product price HTML.It will remove the price from all the listing pages, product pages, and all other pages too. So let’s start with our example.

add_filter( 'woocommerce_get_price_html' ,  'remove_woocommerce_price_html' , 10, 2 );
function remove_woocommerce_price_html( $price_html ){
          $price_html = "";
          return $price_html;
}
Author: Qaisar Satti
Category: WooCommerce
Last Modified: September 29, 2020


WooCommerce remove add to cart

Today we talk about WooCommerce remove to add to cart to different places. Like listing page, product page. So let’s start with an example.

Lisitng Page

You have to remove the following action to do the trick.

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');

Product Page

You have to remove the following action to do the trick.

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');

For the simple product use the following code.

remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );

Remove add to cart for variable products without removing the variation selectors
Note: It will remove only the add to cart button and the Quantity box.

remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
Author: Qaisar Satti
Category: WooCommerce
Last Modified: September 29, 2020


Top 10 woocommerce plugins

In this article, I will share Top 10 woocommerce plugins you must have. I have already written an article about woocommerce and also about plugins.You can read that here Must have woocommerce plugins.Also, there are a number of plugins available to enhance your store’s functionalities and performance. We will discuss few hands picked plugins here too.

Having that said, let’s take a look at the best free WooCommerce plugins for WordPress.

1. OptinMonster
OptinMonster is the most powerful conversion optimization software in the market. It helps you convert abandoning website visitors into subscribers and customers.
You can use it on your eCommerce website to reduce cart abandonment, increase sales conversion, grow your email list, show targeted website messages, onsite retargeting, and more.
If you’re serious about growing your email list and boosting sales, then you need this conversion optimization toolkit.

2. YITH WooCommerce Wishlist

YITH WooCommerce Wishlist plugin allows your customers to save products to their wishlist. They can use the wishlist to make the purchase later or share their wishlist with friends and family.

This is a perfect addon for your online store during busy holiday seasons when people are making their shopping lists and purchasing gifts.

3. WooCommerce Multilingual
Non-English WordPress websites surpassed the English WordPress websites in 2014. Since then more WooCommerce stores are created in languages other than English. WooCommerce Multilingual adds compatibility layer with the popular WPML WordPress multilingual plugin.

This allows you to translate your product and other WooCommerce pages in multiple languages. Your customers can choose to browse your website in their preferred language.

4. WooCommerce Products Slider
WooCommerce Products Slider allows you to easily create beautiful product sliders and carousels and add them anywhere on your WooCommerce store.

5. WooCommerce Customizer

WooCommerce Customizer provides an easy user-interface to use built-in WooCommerce filters. These filters allow you to customize things like button text, labels, fields, and much more.

Normally, you would have to write PHP code to use these filters. With WooCommerce customizer, you can easily use those filters from a simple settings page (no coding necessary).

6. WooCommerce EU VAT Compliance

As the name suggests, this simple plugin makes your WooCommerce shop compliant with the new EU VAT. It will automatically detect your customer’s location and will display prices with correct VAT from the first page.

7. Order Delivery Date for WooCommerce

This plugin allows users to choose a delivery date for products during the checkout. WooCommerce store owners can see the desired delivery date on their orders page in the admin area.

8. YITH WooCommerce Quick View

WooCommerce Quick View allows your customers to peek into product details by simply taking their mouse over a button. This enables customers to quickly get the product information without leaving the product listings or shop page.
Users will be able to see a larger product image, product description, and an add to cart button in a lightbox popup.

9. WooCommerce PDF Invoices & Packing Slips
This nifty plugin allows you to send PDF invoices and packing slips to customers via email. Users can also download their invoices and slips from their account area. As a site admin, you can also bulk generate invoices, download them, and email them to users from an admin area.

10. YITH WooCommerce Compare
As the name suggests, this plugin allows your customers to compare two or more WooCommerce products side by side. You can choose which fields users will see in the comparison table and reorder them as needed.

Similarly, there are many other extensions available. I tried to list a few. I hope this tutorial helps you in any way.
Please feel free to drop any suggestions or queries in the comments section. It will be highly appreciated.

Author: Qaisar Satti
Category: WooCommerce
Last Modified: August 1, 2019


Pages:123