Some of you may use the popular YOAST SEO plugin with WooCommerce to improve your search results in Google. And some of you also use our Google Product Feed plugin. But, the problem is that Google Product Feed doesn’t use YOAST SEO titles but WordPress products default titles. This has main issues. The first one is that your title aren’t optimized for SEO purposes, and the second one is that you can have encoding issues.
The good news is that with a simple snippet you can decide to use YOAST SEO product titles instead of default product titles. It’s pretty simple, all you have to do is to add this little snippet in the file called functions.php in your theme’s folder and BOOM!
When viewing or editing a WooCommerce order, it can be pretty handy to add custom data to the page to avoid having to switch between pages. Today, i’ll provide a quick snippet that will add to the edit/view order page the customer username and a link to its user profile.
The result in action:
Pretty handy right?
So, to add this feature to your site, simply place the following snippet in the functions.php file within your theme folder and you’re done!
Many of you asked me how to change the size of the related products displayed on the product page in WooCommerce. Most of the time, adding a little CSS snippet does the trick, but in some cases you would need to use a PHP snippet to be sure that your dimensions are taken into account. For some reason adding CSS to style.css isn’t always enough, so in that case using a few lines of PHP to add CSS code within the page source code directly is necessary. To do so, we’ll need to use the wp_footer hook.
All you have to do is to paste the following code in your functions.php file in your theme’s folder:
My friend (and awesome fellow at WooThemes) Gerhard wrote a few months ago a really nice snippet to add a new column in the WordPress administration edit order page to display the order weight. This snippet is really great but the order total weight will not be fully accurate if you change a product weight because the snippet calculates the order weight on the fly.
Let’s say a user buys product A, which weight is 10 on july 15th. User A purchases this product on the same day. But a week later you get a new version of product A that is slightly less heavy. You then edit product A weight and set it to 9. Gerhard’s snippet will display user’s A order total weight equal to 9. But if you send user A product former version of product A (the one that user A purchased) the right weight is 10, not 9. Does that makes sense?
So, in order to avoid this, i coded a quick snippet that saves the total order weight at the exact moment the order is made. The snippet then adds a new column in the orders list that displays the correct weight with the weight unit defined in WooCommerce settings. Simply place that code in functions.php in your theme folder:
Here is the result:
WooCommerce Order Total Weight
WooCommerce has a very good called “WooCommerce Brands” to help you link products to brands. This plugin provides a huge list of shortcode and builtin functions to display pretty much everything everywhere. However, I’d like to share a little very useful snippet to automatically display the brands description on the product page itself, below the product description. To do so, I simply created a little function that I hooked to the woocommerce_single_product_summary action. The code I propose is very simple and could be improved pretty easily, but I just want to provide the basics. Then it’s up to you to make something truly awesome with that snippet! And if you do, please write a comment to share your improvements!
Place the following snippet in functions.php in your theme folder (in wp-content/themes/your-theme-folder).