I developed a custom payment gateway plugin for a client, who wanted to add a similar method to “cod” (cash on delivery). FYI, he wanted to add a method called “card on delivery”. I simply duplicated the code, added the PHP to a file, made a plugin and gave him the plugin zip file. And everything was working great… until he did a test checkout. Continue reading WooCommerce: Fixing Fatal error Call to undefined function wc_get_order()
Search Results for: Checkout
WooCommerce: “Ship to a Different Address” Opened by Default
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
WooCommerce: Remove Shipping Labels @ Cart (e.g. “Flat Rate”)
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”)
WooCommerce: Translate “Shipping” @ Cart Totals
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
WooCommerce: Add Prefix / Suffix to Product Prices
Sometimes you may want to add a prefix or a suffix to your prices. It could be something like “From…”, “Only…”, “…tax free” and so on.
The first good news is this is very easy to do with a WooCommerce filter (remember, filters change the value of an existing variable, while actions add content). The second good news is that you don’t need to know PHP, just copy/paste my snippet!Continue reading WooCommerce: Add Prefix / Suffix to Product Prices
WooCommerce: How to Fix the “Cart is Empty” Issue
For some reason, sometimes you add products to cart but the cart page stays empty (even if you can clearly see the cart widget has products in it for example).
But don’t worry – it may just be a simple cache issue (and if you don’t know what cache is that’s no problem either) or a theme / plugin “conflict”.
The WooCommerce Cart page is extremely delicate; it displays dynamic content based on cookies and PHP sessions, is coded with PHP but also JS and Ajax, requires to be excluded from cache and is subject to problems in case of out of date software.
So, here’s your “Empty Cart” troubleshooting checklist you can follow without any technical knowledge.
I also recommend you read through the (many) comments, because many developers shared what worked for them too. Good luck!Continue reading WooCommerce: How to Fix the “Cart is Empty” Issue
WooCommerce: Fix for Wrong Order Total
On a website using USD and WooCommerce Subscriptions, a weird error showed up. After doing a bit of research, I found out that orders above $999.99 were showing as $1 on the Cart and Checkout page. Pretty weird! Here’s how I fixed it. Continue reading WooCommerce: Fix for Wrong Order Total
WooCommerce: Hide Prices on the Shop & Category Pages
Interesting WooCommerce customization here. A client of mine asked me to hide/remove prices from the shop page and category pages as she wanted to drive more customers to the single product pages (i.e. increasing the click-through rate).
As usual, a simple PHP snippet does the trick. I never recommend to use CSS to “hide” prices, as they would still be visible in the code – PHP stops the prices from loading, so they’re invisible to the user.Continue reading WooCommerce: Hide Prices on the Shop & Category Pages
WooCommerce: How to Remove the “Default Sorting” Dropdown
If the WooCommerce product sorting functionality (“Default Sorting” dropdown) is a waste of space or you don’t need that select box at all, you may want to remove it.
This PHP solution is simply cleaner than CSS – and no matter if you code or not, you just need to copy/paste my snippet in your theme’s functions.php.Continue reading WooCommerce: How to Remove the “Default Sorting” Dropdown
WooCommerce: Add Content to the Thank You Page
A client of mine wanted to add some text to the thank you page, the page that customers see after they place an order via the default WooCommerce Checkout page.
In this case scenario, they wanted to add a special coupon discount in order to entice buyers to go back to the website and buy again. Enjoy!Continue reading WooCommerce: Add Content to the Thank You Page
WooCommerce: How to Disable PayPal on Orders Above $100
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
WooCommerce: Disable Payment Gateway for Specific User Role
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.phpContinue reading WooCommerce: Disable Payment Gateway for Specific User Role
WooCommerce: Hide Shipping Rates if Free Shipping Available
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