I am a big fan of Elegant Themes, but a lot of CSS styles (mainly in Divi) contain “!important” in order to override WooCommerce styles when using the two in a combo. Now, the big problem is that we can’t override !important with another !important. Divi will win. But no matter whether Divi has been developed in a good or not so good way, there is something we can do. (NOTE: using !important is a horrible thing in CSS. Use at your own risk) Continue reading WooCommerce and Divi: how to override !important CSS
WooCommerce: Change Input Field to Textarea @ Checkout
Let’s say you require to make the “address” field at checkout bigger. Instead of an “input type = text”, we’d require an “input type = textarea” in HTML. This was my WooCommerce client’s challenge: how can I edit a checkout field input type programmatically? Here’s the snippet! Continue reading WooCommerce: Change Input Field to Textarea @ Checkout
WooCommerce: Only Allow 1 Product in the Cart
Here’s how to limit your WooCommerce Cart to just one product at a time.
This simple PHP snippet can be used for many applications. For example, your store may only allow to buy one subscription at a time. On this same website, on the other hand, customers can only purchase one product at a time so it’s easier for me to manage invoicing and payments, given that I switch PayPal and Stripe accounts based on what’s inside the cart.
Here’s the quick fix – enjoy!Continue reading WooCommerce: Only Allow 1 Product in the Cart
WooCommerce: is_single() Doesn’t Work [Solved]
When building custom functions and using hooks and filters, you may want to apply those changes to a unique product id: “If product id = xxx, then execute this function”.
Honestly, I tried to do that with the simplest of all solutions (is_single WordPress conditional tag) but it didn’t work for me. Hopefully, I can help you solve this in 2 seconds!Continue reading WooCommerce: is_single() Doesn’t Work [Solved]
WooCommerce: Get/Edit Logged in Username @ Checkout
On a recent job, a client asked me to get the logged in username in WooCommerce. Interesting task! He needed to show that on the checkout form page and also on the order email. Actually, this is quite simple to do and can be used for several applications. Continue reading WooCommerce: Get/Edit Logged in Username @ Checkout
WooCommerce: Do Something When Product is Published
A client needed to add “something” upon product publishing. For example, product meta key “total_sales” with value = 0 gets added automatically once a WooCommerce product is created.
So, how do we run (“hook”) our function when a new product is published?Continue reading WooCommerce: Do Something When Product is Published
WooCommerce: Hide Coupon Code @ Cart & Checkout Page
When you apply a coupon code programmatically, for example, you may want to hide the coupon code on the cart and checkout page so that the code stays private and cannot be shared with others.
This solution will basically remove the coupon code (e.g. “VWXYZ”) from the “Coupon: VWXYZ” string that appears in the Cart and Checkout totals. Enjoy!Continue reading WooCommerce: Hide Coupon Code @ Cart & Checkout Page
WooCommerce: How to Add Scripts to the Checkout Page
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
WooCommerce: How to change Shop Page SEO Meta Title (“Products Archive”)
Just say thanks to YOAST SEO plugin, that’s all you need to know. No PHP, no editing template files… just a simple setting in YOAST SEO for WordPress. That’s it 🙂Continue reading WooCommerce: How to change Shop Page SEO Meta Title (“Products Archive”)
WooCommerce: JetPack Sharing Not Showing? [resolved]
Yes, Jetpack Sharing has an option to show the Sharing buttons on the WooCommerce Single Product page. But this does not mean your template is compatible with that! If you have ticked “products” and JetPack Sharing buttons are not showing, you can use this simple snippet. Continue reading WooCommerce: JetPack Sharing Not Showing? [resolved]
WooCommerce: Change the PayPal Icon @ 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
WooCommerce: Apply Coupon Programmatically if Product @ Cart
Users can manually enter a coupon code, refresh the Cart and see their discount apply… or you can do that automatically (or “programmatically” as we say in the dark web) when a user adds a product to the WooCommerce Cart 🙂
All you’ve got to do is creating a coupon, and then a PHP function will do the whole work. Automation is the best thing in the world!Continue reading WooCommerce: Apply Coupon Programmatically if Product @ Cart
WooCommerce: Fixing Fatal error Call to undefined function wc_get_order()
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()
WooCommerce: Exclude Category from [product_categories] Shortcode
Sometimes solutions are very simple, and you don’t need rocket science to fix your issue!
A client of mine needed to hide a category from the Product Categories Shortcode (“product_categories”); in fact, there is no parameter that allows you to “exclude” a given product category such as “uncategorized” or whatever category you wish.
A rare issue, but once again a quick fix! Here’s how you do it.Continue reading WooCommerce: Exclude Category from
WordPress: How to Add CSS to a Specific Page URL
This is an interesting topic. A WordPress/WooCommerce client could not add CSS via the usual way. In fact, Gravity Forms plugin (and in particular the “directory” extension), stores entries in the database BUT the directory page and the entries filtered list have the same classes, ids, and cannot be “targeted” with CSS.
Long story short, and Gravity Form or not Gravity Form, here’s the snippet you can use to add CSS to any WordPress page as long as you know its URL.Continue reading WordPress: How to Add CSS to a Specific Page URL
WooCommerce: Hide Categories From Product Cat Widget
A client asked me to customize the Product Categories Widget that comes included with WooCommerce. In this case, they wanted to show ALL categories but the current one (when looking at a category page of course).
You can also use this tutorial to hide certain category IDs from the widget, or maybe “all product category names that start with a given string of text”. Case studies are millions, but the code base is always the same – we’ll make use of the “woocommerce_product_categories_widget_args” filter and provide a list of product categories to exclude. Enjoy!Continue reading WooCommerce: Hide Categories From Product Cat Widget
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 / Edit “Added to Your Cart” Message
A client asked me to completely remove the message that appears after you add a product to the cart from the product page. This is simply done by using a PHP snippet, so here’s the quick fix for you!Continue reading WooCommerce: Remove / Edit “Added to Your Cart” Message
WooCommerce: Shipstation plugin is broken [solved]
I worked with a client who uses the Shipstation plugin. After updating to the latest version of WooCommerce (2.2), the plugin stopped working and its tab under “settings” could not be clicked. On top, some of the dropdowns got broken. Here’s the fix, hoping that Shipstation updates the plugin asap. Continue reading WooCommerce: Shipstation plugin is broken [solved]
WooCommerce: Redirect to Custom Thank you Page
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