Pages

Sunday, September 29, 2019

How to add Contact Form 7 AutoResponder Functions

Contact Form 7 is the most popular and easy to use contact form WordPress plugin. Contact Form 7 Active installations: 5+ million and Version:5.1.4 available in the WordPress Plugin Directory. Contact Form 7 can manage multiple contact forms.  There may be an issue for some users that want to activate the autoreply or autoresponder e-mail that will be sent to the customer as a notification about receiving the sent query through the mail form, but the sender’s name may appear as WordPress.The settings allow to use this second e-mail, but the sender’s name has to be entered in a specific way if you’d like to have your desired name as the sender’s name in the recipient’s inbox.

You can add two-way AutoResponder:

One:

  • In settings go to Contact -> Contact Forms -> Mail tab.
  • Scroll down to the section where you can add a tick to Use Mail (2), tick it and new settings form appears.
  • See the row From and insert your senders' name and e-mail in the appropriate format.

Learn More here Contact Form 7 Docs and FAQ.
Two:
/**
 * Following code add theme functions.php file. 
 *
 */
add_action( 'wpcf7_mail_sent', 'contact_form_autoresponders' ); 
function contact_form_autoresponders( $contact_form ) {
// replace with ID 
if( $contact_form->id==1234 ){

//retrieve the details of the form/post
$submission = WPCF7_Submission::get_instance();
$posted_data = $submission->get_posted_data();

switch( $posted_data['location'] ){ 
case 'California':
$msg="California email body goes here";
break;

case 'Texas':
$msg="Texas email body goes here";
break;

}
mail( $posted_data['your-email'], 'Thanks for your enquiry', $msg );
   }

}
If you want then you can use free Contact Form 7 AutoResponder Addon plugin OR premium plugin CF7 AutoResponder Addon.But you should check carefully everything before installing the plugin. Still, form not working or if you have any questions.
Check out my Fiverr Profile and I can fix WordPress Or WooCommerce any kinds of issues: Fix WordPress WooCommerce Issues Or Errors.

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.


Add WooCommerce Custom Registration Form Fields

In this tutorial, I will share how to add extra registration form field in WooCommrce My account page. To begin, make sure that the WooCommerce registration forms are enabled on the account login page.  For checking to go WooCommerce > Settings > Accounts and check to Enable customer registration on the My Account page.


After enabling this option, you can see the user registration form at the front end. Also, If you do not enable these options than WooCommerce registration form will not show in the frontend. So this options most important for every WooCommcer website owner. WooCommerce default registration form adding some of the form fields. Like:  First Name Last Name user name etc. So, Every website owner needs to add more form fields in the website User registration page. Like: phone number, address, postal code, Country, etc.

However, I do not want to long this tutorial. So let's start, How to Add WooCommerce Custom Registration Form Fields. Include the following lines of code of your theme or child theme functions.php.  

Please Note: Blogspot do not support this PHP functions so my suggestions please check here for these functions: Add WooCommerce Custom Registration Form Fields

Monday, September 16, 2019

Adding Custom Fields WooCommerce Products With Meta Box

WooCommerce is an E-commerce plugin based on WordPress and WooCommerce powers more than 23% of the E-commerce websites across the globe. It helps you to create online stores that incorporate all the necessary tools for handling sales and shipment related tasks such as email notifications, shipping, online payment, order management, auto fees collection and tax calculations. To add extra info to a WooCommerce product (post type product), I will create a new meta box called Extra Product Info with 6 custom fields.
/**
 * Learn more about filter hook @ https://docs.metabox.io/creating-meta-boxes/
 * add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );
 *
 */
add_filter( 'rwmb_meta_boxes', 'pharmacy_meta_boxes' );
function pharmacy_meta_boxes( $meta_boxes ) {
         $meta_boxes[] = array(
         'title'  => __( 'Extra Product Info', 'pharmacy' ),
         'fields' => array(
                     array(
                      'id'       => 'unit',
                      'name'     => __( 'Unit', 'pharmacy' ),
                      'type'     => 'text',
                      'datalist' => array(
                                  'options' => array(
                                   __( 'Box', 'pharmacy' ),
                                   __( 'Blister pack', 'pharmacy' ),
                                   __( 'Packet', 'pharmacy' ),
                                   __( 'Bottle', 'pharmacy' ),
                                ),
                           ),
                        ),
                      array(
                       'id'   => 'dosage_form',
                       'name' => __( 'Dosage form', 'pharmacy' ),
                       'type' => 'text',
                       'datalist' => array(
                                 'options' => array(
                                  __( 'Capsule', 'pharmacy' ),
                                  __( 'Tablet', 'pharmacy' ),
                                  __( 'Liquid', 'pharmacy' ),
                                        __( 'Ointment', 'pharmacy' ),
                                ),
                            ),
                        ),
                      array(
                      'id'   => 'specification',
                      'name' => __( 'Specification', 'pharmacy' ),
                      'type' => 'text',
                      ),
                      array(
                       'id'   => 'manufacturer',
                       'name' => __( 'Manufacturer', 'pharmacy' ),
                       'type' => 'text',
                      ),
                      array(
                       'id'   => 'distributor',
                       'name' => __( 'Distributor', 'pharmacy' ),
                       'type' => 'text',
                      ),
                      array(
                       'id'   => 'expiry_date',
                       'name' => __( 'Expiry date', 'pharmacy' ),
                       'type' => 'date',
                      ),
                ),
            );

            return $meta_boxes;
    
}

Learn more here WooComemrce Action and Filter Hook Reference

Go to your Dashboard and edit a WooCommerce product, you will see a new meta box below the editor:

Showing Custom Field Values in the Product Page

After adding extra information to products, you need to show it on the frontend. To do that, we need to use a WooCommerce hook in a single product page and the helper function rwmb_meta to get custom field value.
add_action( 'woocommerce_product_meta_end', 'pharmacy_extra_info' );
function pharmacy_extra_info(){
            if ( $meta = rwmb_meta( 'unit' ) ){
            echo '' . __( 'Unit:', 'pharmacy' ) . " $meta";
            }
            if ( $meta = rwmb_meta( 'dosage_form' ) ){
            echo '' . __( 'Dosage form:', 'pharmacy' ) . " $meta";
            }
            if ( $meta = rwmb_meta( 'specification' ) ){
            echo '' . __( 'Specification:', 'pharmacy' ) . " $meta";
            }
            if ( $meta = rwmb_meta( 'manufacturer' ) ){
            echo '' . __( 'Manufacturer:', 'pharmacy' ) . " $meta";
            }
            if ( $meta = rwmb_meta( 'distributor' ) ){
            echo '' . __( 'Distributor:', 'pharmacy' ) . " $meta";
            }
            if ( $meta = rwmb_meta( 'expiry_date' ) ){
            echo '' . __( 'Expiry date:', 'pharmacy' ) . " $meta";
      }
}
To understand how rwmb_meta function works, please follow this documentation. When viewing the single product page, you will see:


I believe these functions will help to create a custom meta box on your WooCommerce website. If you need to be helped with the implementation of your WooCommerce store, do let me know through the services section. To Check: Create a Custome eCommerce website with WooCommerce.

I can make a dropshipping website using WooCommerce.

AliExpress dropshipping website.
SaleHoo dropshipping website.
Doba dropshipping website.
Wholesale2B dropshipping website.
Worldwide Brands dropshipping website.
Wholesale Central dropshipping website.
Dropship Direct dropshipping website.
Sunrise Wholesale dropshipping website.
MegaGoods dropshipping website.
InventorySource dropshipping website.
National Dropshippers dropshipping website.
Dropshipper.com dropshipping website.

So please check my services section. To Check: Create a Custome eCommerce dropshipping website with WooCommerce.