Pages

Tuesday, September 17, 2019

How to remove Description Text in the product description in WooCommerce

Today, I will share you most important and very useful some of the WooCommerce functions. This code should be added in your active theme or child theme functions.php.

Learn more WooCommerce Action and Filter Hook Reference

1. Remove the product description Title
add_filter( 'woocommerce_product_description_heading', 'remove_product_description_heading' );
function remove_product_description_heading() {
   return '';
}
2. Change the product description title
add_filter('woocommerce_product_description_heading', 'change_product_description_heading');
function change_product_description_heading() {
  return __('NEW TITLE HERE', 'woocommerce');
}

3. Remove the additional information title
function remove_additional_information_heading() {
  return '';
}
add_filter( 'woocommerce_product_additional_information_heading', 'remove_additional_information_heading' );

4. Change the additional information title
function change_additional_information_heading() {
    return __('NEW TITLE HERE', 'woocommerce');
 } 
add_filter( 'woocommerce_product_additional_information_heading', 'change_additional_information_heading' );


How to change In Stock or Out of Stock text in WooCommerce

WooCommerce is the most popular eCommerce plugin in WordPress. WooCommerce is easy to use and an open-source eCommerce solution for the WordPress user. More than 5+ million active installations. However, I do not want to long this tutorial. So let's start, How to change In Stock or Out of Stock message in using functions in your website WooCommerce website. If you want then you can use any plugins for this problem.
Here two plugin so you can try but my suggestion check plugin update date and user feedback. Because I do not recommend any plugin for this problem.

1. Woo Custom Stock Status
2. WooCommerce Custom Stock Status
/**
 * 
 * Open active theme functions.php file and add following code
 *
 */
add_filter( 'woocommerce_get_availability', 'custom_get_availability', 1, 2);
  
function custom_get_availability( $availability, $_product ) {
    //change text "In Stock' to 'SPECIAL ORDER'
    if ( $_product->is_in_stock() ) $availability['availability'] = __('AVAILABLE', 'woocommerce');
  
    //change text "Out of Stock' to 'SOLD OUT'
    if ( !$_product->is_in_stock() ) $availability['availability'] = __('SOLD OUT', 'woocommerce');
        return $availability;
    }


How do you set stock quantity by default in WooCommerce?

I am very sorry because any PHP code does not allow here. so if your need How do you set stock quantity by default in WooCommerce functions then please check here: How do you set stock quantity by default in WooCommerce

Add Custom Taxonomy Filter WooCommerce Products Admin Dashboard

How to add Add Custom Taxonomy Filter WooCommerce Products Admin Dashboard. Add the following PHP code in your active theme fucntions.php file.
 
add_filter( 'woocommerce_product_filters', 'wcf_filter_by_custom_taxonomy_dashboard_products' );
 
function wcf_filter_by_custom_taxonomy_dashboard_products( $output ) {
   
  global $wp_query;
  $output .= wc_product_dropdown_categories( array(
   'show_option_none' => 'Filter by product tag',
   'taxonomy' => 'product_tag',
   'name' => 'product_tag',
   'selected' => isset( $wp_query->query_vars['product_tag'] ) ? $wp_query->query_vars['product_tag'] : '',
  ) );
   
  return $output;
}

After Save, these functions go to the admin panel and WooCommerce products sections should look like following attached images. So now you able to Filter by Taxonomy.


No comments:

Post a Comment