The “Ship to a Different Address?” checkbox displays on the WooCommerce Checkout page and toggles the shipping form. That’s useful when Billing and Shipping addresses are different, so let’s say every B2C requires the double form.
However, the “Ship to a Different Address?” string may be confusing or may need further clarification, as not all customers are created equal. What about “I’d like to define a different shipping address” or “Ship to a different address than the Billing one“?
Either way, editing the string is super easy, so you can change it to whatever you like. Enjoy!
Continue reading WooCommerce: Edit “Ship to a Different Address?” @ Checkout
The frontend WooCommerce product search, for some reason, doesn’t work for SKU numbers. If it does, then your theme developers were smart enough to include this in their code, because this is a big problem especially for B2B stores.
Today, we’ll study how to alter the product search query, as well as the wc_get_product_id_by_sku() function, which is super helpful to determine the product ID for a given SKU. Enjoy!
Continue reading WooCommerce: Search Products By SKU
In April 2015, Google released an algorithm update that favored mobile-friendly pages in Google’s mobile oriented search results. This algorithm was named “Mobilegeddon”, and it gave leverage to those sites that display perfectly on smartphones and other mobile devices.
Clearly, having a mobile-friendly website not only makes it easier to engage and convert mobile using customers, but also paves the way for better ranking and visibility on search engines.
While it is good practice to get a WooCommerce mobile app for your store, it is also important to optimize your website and make it more mobile-friendly.
We will first discover the benefits of making your website more mobile-friendly, and then learn the tips and tricks to optimize it for small devices.
Continue reading WooCommerce: How to Make Your Store More Mobile-Friendly
We’ve already seen how to hide products based on IP addresses, hide products belonging to a specific category and even hide all products from the Shop page.
Today I want to publish another version of those, but this time we’ll use a custom field / ACF in our conditional logic, so that we can toggle the product visibility based on its value. Enjoy!
Continue reading WooCommerce: Hide Products Based On Custom Field / ACF Value
By default, the WooCommerce Shop page displays simple, variable, grouped, bundle and other product types. As you know, each variable product is made of one or more “single variations”, and these are only visible in the single product page.
Now, what if you want to display a grid of all “single variations” in a custom page / post? Well, a shortcode can be coded so that you can achieve just that. Enjoy!
Continue reading WooCommerce: Display All Single Variations (Shortcode)
This is a great customization for those WooCommerce store owners who are willing to accept donations, custom amounts, or need anyway that the customer enters a custom price on the product page for paying an invoice or a bill.
This is as simple as creating a simple product with $0 price, and after that using the snippet below to display an input field on the single product page, where customers can enter their custom amount. Enjoy!
Continue reading WooCommerce: Allow Customers To Define the Product Price
It’s official – there is no way to get the fees total from an order with a simple PHP getter (not sure why – you can get lots of values such as totals, addresses, dates, URLs with one line of code except for this basic thing!).
So, we’ve got to fix this. Let’s say you have access to the $order object (on the thank you page, in the WordPress dashboard, inside an order email, etc.); here’s a few lines of PHP you can use to calculate the total amount of order fees. Enjoy!
Well, there is actually one line of PHP you can use to calculate the order total fees (despite I didn’t think so while I was writing this post) – I’ve now added it to the list of order “getters” here (where you can get lots of order values such as totals, addresses, dates, URLs with one liners).
So, in order not to waste this post, you still find below the original way to calculate order total fees (by looping through all order fees and adding up totals), as well as the one liner that can help you save time. Enjoy!
Continue reading WooCommerce: Get Order Fees Total
By default, WooCommerce does not display the product thumbnail inside the order emails.
With this little trick, however, you can revert this default behavior and indeed show images beside their product name inside the email order item table. Enjoy!
Continue reading WooCommerce: Show Product Image @ Emails
Alright, this title may not really help you understand what I mean, so let’s put it in another way. When, as an administrator, you edit an order and are in the Order Items table, you have the chance to edit the item quantity, subtotal and discounted price (see screenshot below).
Now, what if you also want to have the freedom to display and edit another custom field, so that it is saved inside the order once you hit the “Save” button?
This could be useful for custom setups – for example let’s imagine the admin has the necessity to also define the “shipped quantity”, so that they know exactly if a specific order has been entirely fulfilled or requires a second shipment to get completed.
Either way, see the screenshot below, play with the snippet, and see how it goes. Enjoy!
Continue reading WooCommerce: Item Custom Field @ Edit Order Page
Ok, this is an unusual snippet today, but it may happen that for performance / security / conflict / conditional / privacy reasons you may need a certain WooCommerce user role to not see / load / use a given plugin.
Let’s think of an example: as an administrator, you wish to use a CRM plugin to sync your order data to an external software. This plugin, however, does not have the ability to exclude Shop Managers from accessing it, and you don’t want to install yet another plugin to define who can access and who can not.
Another case scenario: Shop Managers and Administrators wish to use a live chat plugin, but they want to restrict the live chat visibility to logged in customers only, while logged out customers should not see anything, hidden code included.
There are a million reasons why this could be helpful. So, let’s see how to actually deactivate a plugin (not disable its scripts – but actually deactivate it) with a handy piece of code. Test it and only then – enjoy!
Continue reading WooCommerce: Disable A Plugin For Customers / Shop Managers
Whenever we need to do custom WooCommerce work, remembering how to get “things” is the most time-consuming task. So, a Google search often helps us find the right and quickest solution.
For example, it’s easy to “get the current product’s categories“, but how can we get the “parent product categories” only? In today’s snippet we will see how this can be achieved in 7 lines of PHP. Enjoy!
Continue reading WooCommerce: Get Product Parent Categories
Manual operations are always a nightmare for WooCommerce store owners. Thankfully, a bit of code can help and actions that would normally take hours can be executed in a few seconds via PHP.
Today, we’ll take a look at a very edge case, but this can still be helpful to understand the code and re-adapt it to other scenarios. If as a store owner you tend to replace products or product lines, it’s possible that you may need to replace the old products with the new ones inside existing orders, retroactively.
It’s a one-off operation that could take hours if it had to be done manually, based on the number of existing orders. With this simple snippet, however, you can edit an unlimited number of orders, and let the code replace ordered items. So, let’s see how this is done. Enjoy!
Continue reading WooCommerce: Bulk Replace Product Inside Existing Orders
When you edit an order as an admin, you’re presented with the usual WooCommerce layout: order details on the left, order action on the right, the list of order items on the bottom left, and – possibly – additional meta boxes added by third party plugins (e.g. the PDF Invoice and Packing List plugin order meta box where you can define the invoice date and number).
On top of that, it’s also possible, of course, to define our own custom meta boxes, so that the administrator and/or shop managers can view (or even enter) additional information.
I’ve used it on a client website to show a custom field, but you can print anything you wish – even documentation for shop managers (how to complete the order for example).
So, here’s how we add a new “section” (meta box) to the single order edit page in the WordPress dashboard, and how we display some content in it. Enjoy!
Continue reading WooCommerce: Add Custom Meta Box @ Order Admin
The goal of marketing automation is to help you save on effort. However, sometimes it comes at the price of poorly targeted campaigns and half-baked marketing content, which can be outright damaging to your business.
The other problem with most of WooCommerce marketing automation tools is that they have a one-off approach to marketing that aims to get as much as possible from one user interaction – during checkout, for example – without providing for loyalty or retention. This goes against the golden rule of marketing, where your biggest asset is your leads and customers and your biggest mission is to retain them.
The solution is to use a omni-channel marketing approach, where a central tool collects and enriches user behavior and history in a unified profile and then uses that profile to deliver relevant campaigns across all user touchpoints.
This ensures more harmonized marketing, a seamless experience for your users and eventually more trust and engagement with your brand. These are all the ingredients you need to increase the loyalty lifetime value of your users and customers.
Continue reading WooCommerce: 4 Ways to Grow Your Sales With Omni-Channel Marketing
The WooCommerce plugin allows you to manage stock for each product, but you only have a single stock quantity field!
What if you have two warehouses and, as a store admin, need to manage the inventory for each location? Besides, what if an item is out of stock at location 1, but it’s in stock at location 2, and therefore the customer needs to be able to purchase it?
This amazing workaround will add a second input number in the product settings, redefine stock quantity and status on the frontend by summing up stock 1 + stock 2, and finally decrease stock 1 until it goes to 0, after which it will decrease stock 2.
This default behavior can be changed of course e.g. it’s possible to define from where the stock is reduced (by distance?) via additional code. Also, additional code can be written to make it compatible with variable products or custom product types, as well as make it work with refunds. Either way, enjoy!
Continue reading WooCommerce: Additional Stock Inventory Location
So, we all know that the “Store Address” fields under WooCommerce > Settings > General are used by other WooCommerce functions such as the initial setup wizard, currency switchers, language plugins as well as taxes and shipping calculations. Also, it may display on PDF invoices, WooCommerce emails and static pages.
This is all good and easy, but as usual businesses are not made equal. It could be that you need to show an additional address; for example, the “Warehouse Address”.
In this tutorial, we will add a new “Warehouse Address” section and address fields under the “Store Address” settings, and also see how we can easily retrieve this custom address so that you can display it anywhere. Enjoy!
Continue reading WooCommerce: Additional “Store Address” @ General Settings
It’s great that WooCommerce products clearly display their stock status and quantity on the single product page (and on the shop page, with this simple customization).
However, WooCommerce store owners often need to display the stock quantity in other sections of the website, such as the homepage, a blog post, a custom pricing table, and keep the quantity dynamic so that the text changes when there is a stock change.
We can therefore build a simple shortcode, that can automatically update the output, so that you never need to worry about changing that piece of content ever again. Enjoy!
Continue reading WooCommerce: Stock Quantity in a Shortcode
When an order that has previously reduced stock is “cancelled” or goes to “pending payment” because the payment failed or the store admin decided to change the order status, the wc_maybe_increase_stock_levels() function triggers and restores the order items’ stock quantity.
As usual, some WooCommerce entrepreneurs asked for a way to disable this automatic restocking given their custom setup. It often goes like that – you can’t really please everyone.
This is unless you’re a smart developer and can account for both options, thanks to a WordPress “filter“. Here’s a PHP one-liner that can immediately disable this default behavior, so that you can avoid the automatic restocking (and maybe doing it manually based on your business rules). Enjoy!
Continue reading WooCommerce: Disable Restocking @ Order Cancelled
There are certainly ways and plugins to turn WooCommerce into a quote engine, but today I want to share a super simple workaround that could be helpful to many.
In a nutshell, we’ll use the same WooCommerce cart/checkout flow, rename a few strings and buttons, enable an offline payment gateway (so there is no actual payment), let the admin revise the order and send back the final invoice, and finally get the customer to pay for their order.
Continue reading WooCommerce: Turn Checkout Into a Quote System
Especially when you do a lot of custom shipping, showing the shipping method title may not be a good idea. Honestly, the default “via ___” suffix beside the shipping cost doesn’t make much sense anyway.
So, let’s get rid of it. With a 1 liner. Enjoy!
Continue reading WooCommerce: Hide “Shipping Via ___” @ Thank You Page, View Order Page