A client needed to add her SSL Logo Seal to the checkout page. The problem is that the code she was given had also a JS part, together with a bunch of HTML.
In this article, we will learn about wp_footer, a handy WordPress hook to print anything inside the footer, a bit of conditional logic to target the WooCommerce checkout page only (and therefore excluding the Thank You Page and Order Pay Page), and how to print HTML inside a PHP function. Enjoy!
Continue reading WooCommerce: How to Add Scripts to the Checkout Page
A simple function for a very common issue: “I can’t find where to change the PayPal icon?”. If you have the same problem, here’s a quick PHP fix.
Continue reading WooCommerce: Change the PayPal Icon @ Checkout Page
When you have special shipping requirements, maybe you want checkout users to see the shipping form section visible on load.
Here’s how you do it. You’ll also find the opposite task in case you happen to have the shipping form opened by default and you want to hide it. Enjoy!
Continue reading WooCommerce: “Ship to a Different Address” Opened by Default
How can you redirect customers to a beautifully looking, custom, product-specific thank you page?
Thankfully you can add some PHP code to your functions.php and define a redirect to a custom URL (as opposed to the default order-received endpoint). This is a great way for you to add specific up-sells, social media share and other information that could help you convert additional sales.
Continue reading WooCommerce: Redirect to Custom Thank you Page
WooCommerce functions add the shipping method label on the Cart totals, on the left hand side of the price. This ruins the price amounts alignment (subtotal, shipping, taxes, total) and many clients have asked me to remove it completely. Also, it could be that sometimes you don’t want to show the name of a shipping rate on the front-end. So, here’s how you do it!
Continue reading WooCommerce: Remove Shipping Labels @ Cart (e.g. “Flat Rate”)
The cart totals table cell title “Shipping” or “Shipping and Handling” appears also on the checkout page. So, what if you wish to “translate” this string from English to “better” English or completely customize it? Thankfully there’s a quick 4 lines snippet for you. Enjoy!
Continue reading WooCommerce: Translate “Shipping” @ Cart Totals
In some countries there is no Postcode/ZIP (such as Ireland!). How do we make the Postcode/ZIP field not required, or how do we completely remove it? The answer is very simple. Continue reading WooCommerce: Disable PostCode/Zip Field on the Checkout Page
Interesting issue. A client found out that if you push the “enter” on your keyboard while on the WooCommerce Checkout page, the form will be automatically submitted. Ouch! What if the customer wanted to use a different shipping method? What if “enter” is pushed by mistake? So, here’s how you disable it. Continue reading WooCommerce: Disable Keyboard “Enter” on Checkout Page
If you wish to print the payment gateway name on order emails (in its own paragraph below the order items table), here’s a handy snippet for you.
All you need to use is the “woocommerce_email_after_order_table” hook to pick the correct position, and then the “get_payment_method_title” WooCommerce function to return the payment gateway name. Enjoy!
Continue reading WooCommerce: Add Payment Method to Order Emails
This is a cool function you can apply to any payment gateways for any order threshold. for example, you may want to disable bank transfers if orders are below $10, or disable PayPal payments if orders are above a certain cart total. Here’s what I did. Continue reading WooCommerce: How to Disable PayPal on Orders Above $100
A WooCommerce client wanted to show some text in the checkout page, and specifically “Please allow 5-10 business days for delivery after order processing.” so that customers are aware of how shipping works. This is a vital information you should disclose on every page of your ecommerce website, and of course on the checkout page too. Continue reading WooCommerce: Add Shipping Notices on Checkout Page
WooCommerce allows you to limit shipping by countries (or “allowed” countries). However, say your business is based in Pennsylvania, USA (PA) or in one of the Australian states. You may want to limit shipping to a state only.
All you need is pasting the following code in your functions.php Continue reading WooCommerce: Limit Shipping to One State Only
You may want to disable payment gateways depending on the user role or user capability. For example, you may want to disable PayPal for “user role: shop_manager” or enable a specific gateway for “user role: customer”. All you need is pasting the following code in your functions.php
Continue reading WooCommerce: Disable Payment Gateway for Specific User Role
If Free Shipping is available, you possibly don’t want to show the other premium shipping options. WooCommerce shows by default all shipping rates that match a given shipping zone, so it’s not possible to achieve this from the settings alone.
Thankfully, the “woocommerce_package_rates” filter allows us to manipulate the shipping rates before they are returned to the frontend. In this example, we will disable all shipping methods but “Free Shipping” so that free shipping remains the only possible choice.
Here’s the code to add to your functions.php. Enjoy!
Continue reading WooCommerce: Hide Shipping Rates if Free Shipping Available
You might want to disable PayPal for non-local customers or enable a specific gateway for only one country… Either way, this is a very common requirement for all of those who trade internationally.
Here’s a simple snippet you can further customize to achieve your objective. Simply pick the payment gateway “slug” you want to disable/enable (“paypal”, “authorize”, “stripe”, etc.) and the country code (US, ES, IE, etc.) and then apply your conditional rules in the plugin below.
Continue reading WooCommerce: Disable Payment Gateway by Country