For a while, I have struggled with how to remove or change location of the Archive Intro Text in a Genesis-based theme. Essentially, the idea is to move the Archive Intro Text towards the bottom of the page mostly for SEO purposes.
When I asked the questions on the StudioPress forums, I did not receive a satisfactory answer. So I did what most coders do: hack it till you discover how to do this way. Worry not, because this is not a hack. It is actually the recommended way to make a change like this.
Here is the code
The first 4 lines simply unhook the actions responsible for showing the Archive Intro Text at its default position. This will make sure the Archive Intro Text does not show up in its usual location.
The rest of the code moves the Archive Intro Text down to the bottom of the page, by hooking on to the “woocommerce_after_shop_loop” action. The trick is to get the relevant parameters passed to the function that eventually displays the Archive Intro Text.
This example is limited only to moving the Archive Intro Text. You will have to extend it to display the Archive Headline to the bottom.
For a while now, I have wanted to have visibility into what really happens on the WooCommerce Checkout page. More specifically, the goal is to determine why almost 50% of those visitors leave the site from the Checkout page?
Survey pop-ups could be one way of determining why they are leaving the site. However, personally, I consider those intrusive. Why not have a behind-the-scenes way of reporting the exact error(s) the user might be encountering?
At first, I envisioned that I could insert some JS code (specifically the GA Send Event JS code) within the relevant WooCommerce filter. In this case, it was going to be the “woocommerce_add_error” filter. However, that was not going to work, as I found that out after a bit of experimentation. Somehow, the JS code was being appended to the “checkout.min.js” file instead of being added inline. Later, I discovered that you can not add JS code in Filter Hooks. See this Facebook post in the Advanced WordPress group for that discussion.
As I looked for how to solve this issue, another alternative method came to mind. What if I could trigger on the addition of the “<ul class=”woocommerce-error”>….</ul>” element to the DOM?
This way, the solution would be generic and can be extended for other notice types (warning, notice, message etc) as well. It could easily be used outside of the WooCommerce context as well. Ofcourse, you will have to change the correct class/id of the element being targeted.
The code changes are split into 2 parts:
Load the new JS file from within the functions.php of your child theme.
ga-send-error-event.jsshould be located in the “js” folder of your child theme. If the “js” folder” does not exist, you will have to create it.
Once you make these changes, you can test it yourself in Google Analytics. But first, you will have to conduct your testing in an Incognito window (Google Chrome).
Visit your Checkout page (preferably in an uncached and incognito browser session)
Open your Developer Toolbar from the Browser (Chrome Dev Tools or FireBug)
Leave all fields empty.
Select a Payment Method and click on Continue
You should see the messages printed above the Checkout Form
Log into your GA interface
Navigate to Real-Time->Events->Events (last 30 minutes)
You should see new events generated under the “WooCommerce Error” category.
See screenshots below
In my case I had left the Billing First Name and Billing Last Name empty. Additionally, I had also left the “Terms & Conditions” checkbox unchecked. The Event Label got truncated, but if you hover over it, the full label is :
“Billing First Name is a required field.,Billing Last Name is a required field.,You must accept our Terms & Conditions.”
So this is how I solved the issue of reporting error messages on WooCommerce checkout page. I am not sure how helpful this will be (I am hoping it will lead to better insight into the actions of the user on the Checkout page). Hopefully, it will reveal weaknesses in the UX.
What do you think? Is this something useful for you? Go ahead and use the code. Let me know if it works well for you. You can also easily extend this code to any part of the site (it does not have to be WooCommerce related).
As you read articles/posts on ecommerce optimization, specifically checkout optimization, a popular theme emerges: The Checkout Progress Bar. The idea is to provide your visitors some kind of visual feedback that they are making progress. It tells them how far along they are before the purchase is complete. Conversely, it tells them how much longer before they can own the product/service they are vying for.
With this in mind, I googled for a free plugin that would accomplish just that. My search ended fruitless (almost). I did hit this gem of a plugin called Progress Bar. This is a simple plugin that can be used anywhere on a WordPress site.
In this article, my aim is to create your own customized checkout progress bar without the use of any paid plugins. You will need
Make some code changes (PHP and JS included). Download from github.
The code changes are shown below. The first change is in your theme/child theme’s functions.php file. Two things are happening here:
Hooking into the “woocommerce_checkout_before_customer_details” action hook to display the Progress Bar. We use the shortcode for the Progress Bar because it allows to send in parameters for styling and appearance.
The second file is the JS script that checks in real-time which mandatory fields have been validated. Then it calculates the progress (in pixels) by simply dividing the “number of fields validated” by the “number of fields that require validation”. It also accounts for the “Shipping Address Same as Billing Address” checkbox.
The end result is you get a progress bar for your WooCommerce Checkout Page.
As of version 2.5 of WooCommerce, this functionality is now built into the WC Core. This plugin is not needed. See the WC 2.5 Changelog for more details.
Following the lead from this blog post by SkyVerge, I set upon to create email notifications when an order fails. Essentially, any time the credit card fails or the order processing is not successful, WooCommerce should notify the store owner that the order has failed.
Currently, WooCommerce is silent about Failed Orders. Note that there is a built in setting in WooCommerce for notifications about Canceled Orders, but not Failed Orders.
My first attempt at trying to modify this plugin by Justin Stern, failed. I tried to adapt the plugin for “Failed” instead of “Cancelled”. However, just replacing the instances of “Canceled” with “Failed” did not accomplish my objective.
After a lot of experimenting, I gave up and sought the help from the WooCommerce community. One of the most helpful WooNinjas, Caleb Burks, lent me a hand for this one. I take no credit for this. All I can say is that guy knows his coding very well.
In the future, I will try to explain the code. For now, here is the link to the completed plugin that sends out emails immediately after an order transitions into Failed status. To test this, simply change the status of an order to “Failed”. Emails should be fired off to the store owner.
Good luck to you. Let me know if it works or if you experience problems. This does work on my setup: WordPress 4.3.1, WooCommerce 2.4.6.