Here’s a simple snippet to change the display of Related Products on the single product page. Lately, I even added a fix for the Storefront theme, which already overrides the WooCommerce filter and needs a different call. Continue reading WooCommerce: Change Number of Related Products
WooCommerce: Show Product Custom Field in the Category Pages
A client asked me to show a given custom field in the loop (i.e. Shop page, Category pages, Tag pages = anywhere woocommerce products are returned). Interestingly enough, she didn’t want to show the product short description (see “show product short description on the homepage only” snippet) but a custom field, so here’s how you do it! Continue reading WooCommerce: Show Product Custom Field in the Category Pages
WooCommerce: Add Checkout Fee for a Payment Gateway (e.g. PayPal)
Here’s a simple PHP snippet to add a fee to the checkout for every payment or for a specific payment gateway.
Please do remember that for certain payment gateways such as PayPal, adding checkout fees is currently against their Terms of Service so make sure to check this first.
As usual, this needs to be copied and pasted in your child theme’s functions.php file. Enjoy!Continue reading WooCommerce: Add Checkout Fee for a Payment Gateway (e.g. PayPal)
WooCommerce: Limit State Dropdowns to One State Only
This is a workaround to Limit Shipping and Billing to One State Only. In two of my previous posts (Limit Shipping to One State Only and Limit Billing to One State Only) we’ve seen similar functionalities. In this case, let’s imagine we want to avoid that the user selects unwanted states. Continue reading WooCommerce: Limit State Dropdowns to One State Only
WooCommerce: Disable Shipping Rate if Variation ID @ Cart
A client needed to disable all shipping methods but Local Pickup for a certain variation ID. This may come useful if you’re looping through the variations on the cart/checkout page (check if variation ID is in the cart for example), so here you go! Continue reading WooCommerce: Disable Shipping Rate if Variation ID @ Cart
WooCommerce: Hide “Order Notes” @ Checkout
Here’s a simple PHP snippet to remove the annoying “Order Notes” / “Additional Information” on the checkout page. This section can usually be found below the shipping form (or the billing form if you have no shipping). Thankfully, you just need 1 line of custom PHP!Continue reading WooCommerce: Hide “Order Notes” @ Checkout
WooCommerce: Remove or Rename SALE! Badge
Here’s yet another easy WooCommerce PHP snippet if you wish to completely remove / hide or translate / rename the SALE! badge on the homepage, shop page, category pages and single product pages.
Once again, with a few lines of code (and specifically, the “woocommerce_sale_flash” filter) you can achieve anything you want. Enjoy!Continue reading WooCommerce: Remove or Rename SALE! Badge
WooCommerce: Related Products in a Custom Tab @ Single Product Page
This is a simple snippet that will allow you to move the Related Products from below the tabs to inside the single product tabs, in a brand new tab.Continue reading WooCommerce: Related Products in a Custom Tab @ Single Product Page
WooCommerce: Show “Sold Out” @ Shop Page
Here’s another simple snippet that can easily help user experience and make sure a “sold out” badge shows on each out of stock product in the category & shop pages.
Not all themes allow this so you can use the snippet below to make it happen!Continue reading WooCommerce: Show “Sold Out” @ Shop Page
WooCommerce: Sell to One State Only
Very similar to the “Limit shipping to one State only“, this time we want to limit the Billing to only one state. An Australian client asked me to limit their sales to the South Australia state, but the same can be applied to US, UK and all the other countries that have states.Continue reading WooCommerce: Sell to One State Only
WooCommerce: Sort Shipping Costs from Low to High
A client had several shipping rates on the cart page automatically generated by FedEx, USPS, UPS and similar plugins via their API. Problem was, they wanted to sort them by price as opposed to grouping them by provider.
Thankfully, with a simple “uasort” PHP function, it’s possible to take the shipping rates array and sort it by amount before returning it back to the screen. If you don’t know PHP, simply copy/paste!Continue reading WooCommerce: Sort Shipping Costs from Low to High
WooCommerce: Check if Product ID is in the Order
Once a customer places an order, you might want to know if such order contains a given product ID. you can use this for tracking purposes, redirect to a custom thank you page or run your custom functions.
Either way, checking this is quite simple thanks to the “woocommerce_thankyou” hook which runs on the order received page. Enjoy!Continue reading WooCommerce: Check if Product ID is in the Order
WooCommerce: Hide Products @ Shop Page
A client wanted to show only featured products on the shop page. While adding featured products is very easy (just use the WooCommerce shortcode in the page content), it seems very difficult to remove the “default” product loop. Here’s what I did.Continue reading WooCommerce: Hide Products @ Shop Page
WooCommerce: Remove or Move User Login / Registration at Checkout
Whether you want to disable login / registration on the WooCommerce Checkout page or move the login form from the top to the bottom of it, this is a simple thing to do. You can do it via a PHP snippet or WooCommerce settings. Continue reading WooCommerce: Remove or Move User Login / Registration at Checkout
WooCommerce: Change “Return to Shop” URL
This simple snippet will make sure you can send users back to a custom page as opposed to the shop page when the Cart is empty. In this particular project, client had no shop page so we wanted to send users back to the homepage instead.
As usual, it’s a couple of lines of PHP, without the need to override templates or even worse to edit core WooCommerce. Enjoy!Continue reading WooCommerce: Change “Return to Shop” URL
WooCommerce: Set Default Billing State / Country @ Checkout
This is a simple PGP snippet that I successfully used on a bunch of websites in order to set the default Billing country or state. This is a great way to save the user some time during checkout (and therefore increase your conversion rate) in case you almost exclusively sell to customers located in a given country or state. Nothing else to say, just… enjoy! Continue reading WooCommerce: Set Default Billing State / Country @ Checkout
WooCommerce: Translate “You may also like…” Text
Apparently, since WooCommerce 4.1, there is now an easy way to edit the “You may also like…” WooCommerce string thanks to a brand new “PHP filter”. Kudos to Damien Carbery for reporting this new method.
So, as usual, simply copy/paste the snippet below in your child theme’s functions.php and it will do what it says on the tin. Enjoy!Continue reading WooCommerce: Translate “You may also like…” Text
WooCommerce: Add to Cart URL to Open in a New Browser Tab
Mostly when working with external products in WooCommerce, you may want to not only rename “Add to Cart” into something else… but also opening the link into a new tab. Here’s how I did it!Continue reading WooCommerce: Add to Cart URL to Open in a New Browser Tab
WooCommerce & Avada: Social Sharing @ Product Category
A client wanted to add the social sharing icons provided with Avada theme on the shop loop and product shortcodes as well. The social sharing icons are visible on the single product page only, so here’s how you do it!Continue reading WooCommerce & Avada: Social Sharing @ Product Category
WooCommerce: Edit “# in stock” @ Single Product Page
I’ve seen many snippets that change the “In Stock” text on the single product page, but not the FULL string. In this particular case, not only I needed to change the text, but also edit the order of display: from “2 in stock” to “Quantity: 2“.Continue reading WooCommerce: Edit “# in stock” @ Single Product Page