Posted on 11 Comments

List of shortcodes In BC Woo Thank You Page Builder

You can find below the list of the shortcode that supported by my plugin BC Woo Thank You Page Builder:

Most common pieces of data

  • [bctk_formatted_billing_full_name] : Full customer billing name
  • [bctk_formatted_shipping_full_name] : Full customer shipping name
  • [bctk_formatted_billing_address]: Full billing address
  • [bctk_formatted_shipping_address]: Full shipping addres
  • [bctk_formatted_order_total]: Order total, currency formatted
  • [bctk_customer_note]: Customer note
  • [bctk_order_number]: Order number
  • [bctk_order_id]: Order ID
  • [bctk_view_order_url]: URL to view the order details
  • [bctk_order_details]: Table that list the order details
  • [bctk_billing_first_name]: Billing first name
  • [bctk_billing_last_name]: Billing last name
  • [bctk_billing_company]: Billing company
  • [bctk_billing_address_1]: Billing address 1
  • [bctk_billing_address_2]:
  • [bctk_billing_city]
  • [bctk_billing_state]
  • [bctk_billing_postcode]
  • [bctk_billing_country]
  • [bctk_billing_email]
  • [bctk_billing_phone]
  • [bctk_shipping_first_name]
  • [bctk_shipping_last_name]
  • [bctk_shipping_company]
  • [bctk_shipping_address_1]
  • [bctk_shipping_address_2]
  • [bctk_shipping_city]
  • [bctk_shipping_state]
  • [bctk_shipping_postcode]
  • [bctk_shipping_country]
  • [bctk_order_item_totals]

Bank transfer shortcode

  • [bctk_payment_bacs_account_name]
  • [bctk_payment_bacs_account_number]
  • [bctk_payment_bacs_bank_name]
  • [bctk_payment_bacs_routing_number]
  • [bctk_payment_bacs_iban]
  • [bctk_payment_bacs_swift]

Less common order data

  • [bctk_order_key]
  • [bctk_customer_id]
  • [bctk_user_id]
  • [bctk_user]
  • [bctk_address_prop]
  • [bctk_payment_method]
  • [bctk_payment_method_title]
  • [bctk_transaction_id]
  • [bctk_customer_ip_address]
  • [bctk_customer_user_agent]
  • [bctk_created_via]
  • [bctk_date_completed] (probably empty if payment is COD/bank transfer…)
  • [bctk_date_paid] (probably empty if payment is COD/bank transfer…)
  • [bctk_date_created]
  • [bctk_address]
  • [bctk_shipping_address_map_url]
  • [bctk_downloadable_items]
  • [bctk_checkout_payment_url]
  • [bctk_checkout_order_received_url]
  • [bctk_cancel_order_url]
  • [bctk_cancel_order_url_raw]
  • [bctk_cancel_endpoint]
  • [bctk_edit_order_url]
  • [bctk_customer_order_notes]
  • [bctk_refunds]
  • [bctk_total_refunded]
  • [bctk_total_tax_refunded]
  • [bctk_total_shipping_refunded]
  • [bctk_item_count_refunded]
  • [bctk_total_qty_refunded]
  • [bctk_qty_refunded_for_item]
  • [bctk_total_refunded_for_item]
  • [bctk_tax_refunded_for_item]
  • [bctk_total_tax_refunded_by_rate_id]
  • [bctk_remaining_refund_amount]
  • [bctk_remaining_refund_items]
Posted on 10 Comments

How To Customize WooCommerce Shop Page In 5 Minutes Without A Plugin

How To Customize WooCommerce Shop Page In 5 Minutes Without A Plugin 1

Want to customize the shop page using page builders such as Elementor, Beaver? Check this guide out.

WooCommerce shop page is like a category page in WordPress, there is no built in tool (like the editor) to customize its look. If you have been trying to customize WooCommerce shop page without any success, you are at the right place.  At the end of this post, you will know everything you need to customize your shop page to your liking. Let’s get started.

Here are the steps we are going to do to customize the shop page:

  1. Create a child theme of your current theme (if you haven’t)
  2. Create the folder structure for the WooCommerce shop page template in your child theme
  3. Creating content for your WooCommerce shop page

Create a child theme of your current theme (if you haven’t)

Creating a child theme is necessary to customize woocommerce shop page. Actually, if you want to do any customization to your theme or other plugins (such as WooCommerce), create a child theme. It is the safest way to add functions or change styles in WordPress. Creating a child theme isn’t hard. I’ve made a tutorial here so you can follow easily. It will not take you more than a few minutes to read:

Step by step guide to create child theme in WordPress

Create the folder structure for the WooCommerce shop page template in your child theme

IMPORTANT! Your editing interface might be different to what I’m showing here. However, the files are under yoursite/wp-content/themes/your-theme

So I assume that you have created the child theme. In this example, I’ll use a child theme that I’ve created for storefront. The theme folder is storefront-child-theme:

create child theme folder

Let’s navigate to the theme folder and create a folder named woocommerce:

create woocommerce folder inside child theme

Inside that folder, we are going to create a file called archive-product.php

create shop page templete in woocommerce folder

This archive-product.php is the WooCommerce shop page template file.

Now, if you have followed and done all the steps mentioned above (with the child theme activated), when you visit your shop page, you should see a blank page.

Congratulations, you have successfully customized your WooCommerce shop page.

Creating content for your WooCommerce shop page

Now, it is totally up to you to customize the design of the shop page. If I open the file archive-product.php in a text editor and put the following content:

<h1>Hello this is the shop page</h1>

Then, if I go back to the shop page, sure enough, I’ll see this:

example text on the shop page

It doesn’t look really attractive though. If you are confident in your design and HTML skills, you can stop reading here and start working on your shop page. However, if you just need something that has similar layout to your post’s and allows you to control the products that display on it, read on.

Create shop page template from post’s template

Now, let’s see how quickly you can customize your store shop page using your post’s template. Let’s go to the parent theme of the child theme you’ve created and copy a file named single.php. If that isn’t available, you can copy index.php instead. In my case, I have both single.php and index.php available so I’ll choose single.php.

List of templates file in wordpress theme

Let’s go to our child theme folder, paste the file into woocommerce folder:

paste the single file in woocommerce folder

Now, let’s delete the archive-product.php file and rename the single.php file to archive-product.php. Basically, we’ve replaced the archive-product.php file with the post’s template file.

If I go to the shop page now, I’ll see something like this:

new shop page design from post template

The products are listed basically displayed as posts are.

We are going to use the power of WooCommerce shortcodes to make it looks like a real shop page. You can grab woocommerce shortcodes here to match your need.

So, for example, I want to display products from all categories in 3 columns, 12 products max. The shortcode will be:

woocommerce product shortcode

But where do you put the shortcode? In the archive-product.php file of course.

Let’s open archive-product.php file (inside your child theme folder/woocommerce). Different theme has different structure. This is mine:

content of archive product

You should delete the part between <main and </main. Then, put the following code right at the position of the code you deleted:

How To Customize WooCommerce Shop Page In 5 Minutes Without A Plugin 2

The content of archive-product.php looks like this:

display the woocommerce shortcode in the shop page

Save the file and go to the shop page, here is what I got:

customize woocommerce shop page

You can see, it looks a lot like a shop page now. If you know HTML, you can add additional code in to make the page more lively. In my experience, I just need to play with shortcodes to accomplish my desired design.

Conclusion

That’s it! That’s how you customize WooCommerce shop page. As always, I hope you find the tutorial helpful. Don’t hesitate to ask if you have questions.

Posted on 2 Comments

The Ultimate Nginx Configuration For WordPress Website

The Ultimate Nginx Configuration For WordPress Website 3

So recently I decided to move my server from HostGator to DigitalOcean droplets. In comparison, DigitalOcean has so many benefits over HostGator, especially for developer. The most notable are:

  1. Full root access
  2. You can install anything you want on DigitalOcean
  3. Free SSL (Let’s encrypt)
  4. Cheaper
  5. More powerful server (2GB of RAM, 50GB SSD, 2TB transfer for just $10/month)

My website was running on Apache server at HostGator. As I’ve heard so many good things about Nginx, I decided to make the change. Installing Nginx was easy. However, as I’m not familiar with Nginx, I spent more than a day to solve these two issues:

  1. Website is not accessible. I got 502 Bad Gateway error every time I try to access my site.
  2. When I was able to access my site. All pages/posts are 404 except the home page.

So, to save you time, I’m going to share my configurations so you can follow and get your site up and running fast on Nginx.

Configure PHP FPM

First, let’s edit you php-fpm www.conf file. I’m running php7.2 so the file is located here:

/etc/php/7.2/fpm/pool.d/www.conf

However, if you are running a different php version, you may have different path. The trick is to cd from /etc the ls to see the list of folders. For example, if you have php 7.3, the path would be:

/etc/php/7.3/fpm/pool.d/www.conf

Edit the file using your favorite editor. I’m using vim so I type:

vim /etc/php/7.2/fpm/pool.d/www.conf

Let’s navigate to the line says:

listen = /run/php/php7.2-fpm.sock

Comment that line by placing a ; at line start and type the following line below:

listen = 127.0.0.1:9000

Now it will look like this:

 

configure php-fpm www.conf

Save your file and restart php fpm. I’m on ubuntu 18.04 so my command to restart php fpm is this:

systemctl restart php7.2-fpm

However, if you are on a different server, the command could be different. You can google for the exact command for your system.

Configure your site’s server block

Let’s go to:

/etc/nginx/sites-available/

And create a file match your domain name. For example, my site is excelautocomplete.com, I’ll create file called excelautocomplete.com

vim excelautocomplete.com

then enter the following content to the file:

# WordPress single site rules.
# Designed to be included in any server {} block.
# Upstream to abstract backend connection(s) for php
upstream php {
        server unix:/tmp/php-cgi.socket;
        server 127.0.0.1:9000;
}

server {
        ## Your website name goes here.
        server_name domain.tld;
        ## Your only path reference.
        root /var/www/wordpress;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
                expires max;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                # This is cool because no php is touched for static content.
                # include the "$is_args$args" so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
                fastcgi_buffers 16 16k;
                fastcgi_buffer_size 32k;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                access_log off;
                log_not_found off;
        }
}

You need to pay close attention to two fields:

  • server_name
  • root

in server_name, type in your website address (without http or https). In the root field, enter the location of your site’s file (the folder that contains wp-content, wp-admin…)

Save the file and reload nginx.

systemctl reload nginx

Now, your site should be up and running without an error.

Conclusion

Moving my website from Apache to Nginx was a challenging but exciting experience for me. I lost a sales due to my customer cannot get to the download page of the product. However, I’ve learned a lot from this experience and next time when I need to move other sites, the whole process would be much faster and easier.

Hopefully, the post has been helpful to you. If you have questions, don’t hesitate to ask.

Posted on Leave a comment

Picture Guide To Create Child Themes In WordPress Step By Step

Picture Guide To Create Child Themes In WordPress Step By Step 4

If you are reading this post, you may have heard of the good things that a child theme bring. Most of the time, you like the look and feel of the parent theme, however, you still need to modify a bit to your liking. This is the perfect case to create child themes in WordPress. Another example is when you want to alter some functionalities of the parent theme such as change the WooCommerce shop page design. Once you know how to create a child theme, there are many great things you can do. Without further ado, let’s learn how to create child themes in WordPress.

There are two ways you can create a child theme in WordPress. If you are comfortable with creating folders and files, then take a look at the second method below. However, if you want an easy way, maybe using a plugin to create your child theme is the right way.

Create child themes in  WordPress using plugin

We are going to use a plugin called Child theme wizard. Let’s go to Plugins->Add new and type Child theme wizard in the search box:

plugin to create child theme

Let’s click on Install now and wait until the text on the button change to Activate. Click on Activate.

Now, go to Tools->Child theme wizard:

creating child theme with child them wizard

If you are creating a child theme, chances are you want to add styles or function to the current active theme. Thus, you should leave the parent theme as the currently active one (however, you can create a child theme for any theme available in your themes folder).

Next, let’s enter some details. You can enter anything you like in these boxes. When you are done, click on Create Child Theme.

After a few seconds, you should see this notice:

wordpress child theme created sucessfully

The child theme was created successfully.

Now, let’s go to Appearance, you should see the child theme listed there:

child theme created

Now you can activate the child theme and write additional styles and functions to your site.

 

Create WordPress child theme by manually creating the theme files

If you want to create the folder structure for the child theme yourself, let’s follow the instructions below:

Here are the steps we are going to do to create a child theme

  1. Locate the parent theme that you want to create a child theme for
  2. Create a folder to host the child theme’s content
  3. Create the style.css file inside child theme folder to declare its information
  4. Activate the child theme in WordPress dashboard

Let’s go through the steps above. In this post, I’m going to use my local development server (which runs Windows). However, you can apply the same concept to create child themes on cPanel or even through linux command line. If you need help, please let me know.

Locate the parent theme that you want to create a child theme for

The first thing you need to do is to find out which theme you want to create a child theme for. Let’s go to your wp-content/themes folder. Here I have some themes available:

list of themes in wordpress themes folder

I’m going to create a child theme for the theme storefront, which is the default theme of WooCommerce. It’s totally depend on you to pick the parent theme.

Create a folder to host the child theme’s content

Our next step is to create a folder to host the child theme’s files. I’m going to create a folder called storefront-child-theme. You can give the folder any name you want. However, the name should (not must) make it obvious to see the parent-child relationship. Some other good examples for child theme’ names are:

  • storefront-child
  • storefront-extend-theme

Now, in our wp-content/themes folder, we have these folders:

create child theme folder

Create the style.css file inside child theme folder to declare its information

Our next step is to go to the child theme’s folder and create a file named style.css. This is the must-have file of any WordPress theme. Let’s enter the following details in style.css:

/*!
Theme Name:   Storefront Child Theme
Theme URI:    https://binarycarpenter.com/?p=1158&preview=true
Author:       Dat
Author URI:   https://binarycarpenter.com/
Template: storefront
Description:  This is the storefront child theme
Version:      1.0.0
License:      GNU General Public License v2 or later
License URI:  https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:  storefront-child-theme
Tags:         e-commerce, two-columns, left-sidebar, right-sidebar, custom-background, custom-colors, custom-header, custom-menu, featured-images, full-width-template, threaded-comments, accessibility-ready, rtl-language-support, footer-widgets, sticky-post, theme-options, editor-style
*/

There are quite some fields here (each field stays on one line). However, there are two fields you need to pay attention to. Those are Theme Name and Template.

These two fields are required and they have some strict rules you must follow:

  1. For the “Theme Name” field, you can put anything you like in here but it must be unique across all your themes (on your site).
  2. For the Template field, the value of this field must match the FOLDER NAME of this theme’s parent theme. In this example, the parent theme’s folder is storefront so I put storefront in the Template field. You should put this value according to your parent theme.

Let’s save the file and go to the next step.

Activate the child theme in WordPress dashboard

Now we have successfully created the child theme for storefront. Let’s go to Appearance->Themes inside WordPress dashboard to activate it:

child theme in wordpress dashboard

As you can see, we now have a new theme called Storefront Child theme. Let’s hover on it and click on activate. The site is now running our new child theme. Now you can start working on writing custom CSS styles, additional functions in the functions.php files…

Conclusion

Child themes bring a lot of flexibility to your WordPress site. Knowing how to create and work with child theme is important, even when you are not a developer. Child themes let you customize the styles and also add new functions to the parent theme. Hopefully the post has been helpful to you. If you have any questions, please let me know in the comment below.

Posted on Leave a comment

5 Steps I Made To Get 99% On GTMetrix And How You Can Do It Too

binary-carpenter site speed optimization

It’s 2019 and nobody likes a slow website. With Google launching the AMP project, websites now can load in less than 1 second and that number has become the expectation of web users. Website with load time more than 3 seconds are considered slow. If you are like me, you’ve been trying a lot of methods to make your website load faster. However, with many factors contribute to the total picture, it is so difficult to do it manually, even though you are a developer.

Before we begin, let me share with you the screenshot of this website (https://binarycarpenter.com/) on GTMetrix.com after being optimized:

 

binary-carpenter site speed optimization

You can view the link of the report here.

I also tested the site on pingdom tools:

5 Steps I Made To Get 99% On GTMetrix And How You Can Do It Too 5

This is the result I achieved without using a CDN. If I used one, the YSlow score should be higher.

Now, let’s walk through steps that I did to achieve this.

Optimize all images with Smush Pro

Nearly 68% content of the web are images. This fact sound crazy but if you think about it a bit, you will see it’s quite reasonable. On blogs like this one, the content are text and images. Text doesn’t contribute much in term of size. Images are more prevalent in e-commerce sites where sites’ owners need to show many products’ images. If you don’t optimize your images well, your web page can be pretty big, up to several MB or even more.

Heavy websites load slower, no matter how fast the connection and powerful your server is. Slow websites drive visitors away, no matter how good your content or product are.

As you can see from my blog, I write a lot of tutorials. Many of them use screenshots to demonstrate the steps. That’s why I need to optimize my images badly. Downloading the images and optimize them then upload back to the server is not an option. Thus, I use Smush pro from WPMU dev. The plugin goes through all my images and optimize them to make their size small while preserve their quality:

5 Steps I Made To Get 99% On GTMetrix And How You Can Do It Too 6

All images are optimize with just a simple click.

Minify CSS, JS, HTML, enable caching with Hummingbird Pro

Honestly, there are many plugins can minify CSS, JS, HTML and combine them. One good example is W3 Total Cache. However, no other tools come close to Hummingbird Pro in terms on user interface. I love the design and the simplicity it brings to the users. I just need a few clicks to make the assets (CSS, JS, HTML) on my site minified. The plugin also support caching (again, you can achieve this with other plugins too but probably takes you more time).

5 Steps I Made To Get 99% On GTMetrix And How You Can Do It Too 7

5 Steps I Made To Get 99% On GTMetrix And How You Can Do It Too 8

Avoid unnecessary image, iframe loads with a3 Lazy Load

If your site has many images, enable lazy loading for your images is super important. Lazy loading is a technique that prevent images from loading if they are not needed. Sounds complicated? Actually, it is very simple. For example, you have 10 images on your blog post. One visitor comes to your post and read a few seconds then quit. He sees only two images before quitting. If you don’t have lazy loading enabled, all 10 images on that blog posts are loaded.

However, if you enable lazy loading, only the visible images are loaded. As a result, you save the bandwidth for that 8 images that the visitor never sees.

Enabling lazy loading also reduce page’s size, which makes your site load faster.

Here is my a3 lazy load settings:

5 Steps I Made To Get 99% On GTMetrix And How You Can Do It Too 9

Make less requests with Fast Velocity Minify

Hummingbird pro does a good job minifying css and js and even combine some of them together. However, Fast velocity minify goes a step further. You can see from the screenshot below:

Number of requests when Fast velocity minify is NOT enabled:

5 Steps I Made To Get 99% On GTMetrix And How You Can Do It Too 10

There are 41 requests total.

Let’s see the number of requests when I have this plugin enabled:

5 Steps I Made To Get 99% On GTMetrix And How You Can Do It Too 11

The number of requests dropped to just 15. That’s awesome!

Deactivate plugins that you don’t really need to save requests

One of the most effective way to improve your site’s speed is to get rid of plugins you don’t need. Plugins can add some cool features to your site. However, you should go through your plugin list and find out the one that isn’t vital to your site to get rid of them. One good example is the Add this plugin (that displays a floating social bar on your website). While it makes your site look nice and help your visitors share your content on social network easily, it contains heavy javascript and css resources that make your site load slowly. In addition, you should consider using a SEO optimized theme. Not all WordPress themes are created equal. From my experience, there are themes that have an amazing look but under the hood, they use so many external libraries that make the site super heavy, even without images. You definitely want to avoid those themes.

Conclusion

This is my personal experience with my site. The concept works in general. However, you may not achieve the exact result. I hope you can apply the tips in this post and make your site load much faster.

All plugins in this post are free except Hummingbird pro and Smush pro. The membership from WPMU Dev cost $49/month. However, if you are interested, I can set you up a super sweet deal that cost only $49/year with 2 months free test. Let me know if you are interested in the comment below.