
WooCommerce provides a simple way to log your custom events and debug your custom code and plugins. By using this built-in tool, you can easily track errors, troubleshoot issues, and log important actions, making debugging more efficient in WooCommerce development.
Hosted by Rodolfo Melogli
Session overview
In this webinar, we’ll dive into the WooCommerce Logger class (WC_Logger) and explore how it can be a game-changer for debugging and tracking custom events within your WooCommerce store. Whether you’re a developer building custom plugins, adding bespoke features, or troubleshooting code, WC_Logger provides a powerful yet easy-to-use tool to log everything you need.
When working with WooCommerce, debugging is a crucial part of the development process. Errors, unexpected behaviors, and performance issues are common, and without a robust logging mechanism, it can be difficult to pinpoint the cause of problems. The WC_Logger class allows developers to log detailed information about events and errors, making it easier to diagnose issues and improve the reliability of your store.
When you build custom functionality in WooCommerce—whether it’s a new payment gateway, shipping method, or custom admin tools—you often need to monitor the behavior of that code. WC_Logger allows you to log events that are important to your development process. You’ll learn how to write these custom log entries, store them, and retrieve them for analysis.
Throughout the session, we’ll demonstrate live examples of how to log events in WooCommerce. You’ll see how easy it is to implement logging within your custom code and how the logs appear in the WooCommerce admin interface, giving you direct access to important debugging data. Whether you’re working on a small custom feature or a large-scale project, you’ll walk away from this webinar with a deeper understanding of how to leverage the WooCommerce Logger class to improve your workflow and troubleshooting process.
So, join me for this hands-on, live session where we’ll unlock the full potential of custom logs. Don’t miss the opportunity to learn from my real-world examples – as well as the chance to learn and connect with the Business Bloomer Club WooCommerce community in real time!
Video Recording
If you are a member, please log in.
Otherwise, here is why you should join the Club.
Useful Links
- Logging in WooCommerce: https://developer.woocommerce.com/docs/logging-in-woocommerce/
- WooCommerce: How to Create Custom Logs: https://www.businessbloomer.com/woocommerce-create-custom-logs/
- WooCommerce Function of the Week: wc_get_logger: https://poststatus.com/woocommerce-function-of-the-week-wc_get_logger/
Useful Snippets
/**
* @snippet Log Product Title Changes
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 9
* @community https://businessbloomer.com/club/
*/
add_action( 'post_updated', function( $post_ID, $post_after, $post_before ) {
// BAIL IF NOT A PRODUCT
if ( 'product' !== $post_before->post_type ) return;
// BAIL IF TITLE DIDNT CHANGE
if ( $post_after->post_title == $post_before->post_title ) return;
// LOAD THE WC LOGGER
$logger = wc_get_logger();
// LOG SLUGS TO CUSTOM LOG
$logger->info( 'Product ID ' . $post_ID . ' title changed from "' . $post_before->post_title . '" to "' . $post_after->post_title . '"', array( 'source' => 'product-changes' ) );
}, 10, 3 );
/**
* @snippet Log Product Stock Changes
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 9
* @community https://businessbloomer.com/club/
*/
add_action( 'woocommerce_update_product', function( $product_id, $product ) {
// GET PRODUCT STOCK
$qty = $product->get_stock_quantity();
// LOAD THE WC LOGGER
$logger = wc_get_logger();
// WRITE TO CUSTOM LOG
$logger->info( 'Product ID ' . $product_id . ' stock changed to: ' . $qty, array( 'source' => 'product-changes' ) );
}, 10, 2 );
/**
* @snippet Send Email Upon New Log Entry
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 9
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_register_log_handlers', function my_wc_log_handlers( $handlers ) {
$recipients = array( 'info@example.com' );
$threshold = 'critical'; // Only send emails for this level and higher.
$handlers[] = new WC_Log_Handler_Email( $recipients, $threshold );
return $handlers;
});
Upcoming masterclasses
As a Business Bloomer / WooWeekly subscriber you can attend as many live classes you wish – for free. Here’s a list of upcoming events (we usually take a break for June-August, otherwise you should expect about 2 classes per month). Make sure to attend live so you can interact with the teacher and the other attendees!
Supercharge WooCommerce With Custom Product Options
Custom product options (“add-ons”) in WooCommerce can do much more than just…
Classic vs Block: Add, Remove & Edit WooCommerce Checkout Fields
Let’s dive into the ins and outs of customizing WooCommerce checkout fields,…
Available webinar recordings
As a Business Bloomer Club member you have full lifetime access to previous class recordings (as well as online courses, private community and more). Here’s the list of all past classes:
Send These 7 WooCommerce Emails & Watch Sales Grow
Think email marketing is too complicated? Think again… If you’re only sending WooCommerce order emails, you’re leaving money on the…
Spotting WooCommerce Conversion Rate Killers: A Live Audit
In this class, I’ll be auditing several live WooCommerce stores to identify and analyze conversion rate optimization (CRO) issues. Whether…
How to Sync WooCommerce & Google Sheets Without Plugins!
Want to connect WooCommerce with Google Sheets without relying on plugins, Zapier, Make, or third-party connectors? In this class, you’ll…
Preventing WooCommerce Checkout Carding Attacks
Carding attacks can wreak havoc on your WooCommerce store, leading to fraudulent transactions, chargebacks, spam orders, and financial loss. In…
Generate WooCommerce Test Data: Products, Orders, Users
To properly test or develop a WooCommerce site, you need a large dataset of fake products, orders, customers, and taxonomies….
Live Migrating a WooCommerce Site to HPOS
Migrating a WooCommerce site to HPOS can be complex, especially with 30,000+ orders. In this case, we’ll use the terminal…
How to Spin Up WooCommerce Test Websites For Free
Testing WooCommerce snippets, plugins, themes shouldn’t be a hassle. Let’s discover free tools to spin up test websites in minutes—no…
Log Events & Debug Custom Code with WooCommerce Logger
WooCommerce provides a simple way to log your custom events and debug your custom code and plugins. By using this…
Optimize WooCommerce Performance with WordPress Transients
Discover how WordPress transients can boost WooCommerce speed! We’ll explain what transients are, their pros and cons, and when and…
Unlocking the Power of WooCommerce Featured Products
Many developers and store owners find themselves unsure about how to effectively use featured products. Let’s change that – and…
Buying a WooCommerce Store: All You Need to Know
A guide to valuation, negotiation, and acquisition strategies – along with post-acquisition tips for optimizing and growing an existing WooCommerce…
1-Hour WooCommerce Challenge: Let’s Recreate the Nike Product Page
Join me for a live coding challenge, where I’ll customize the WooCommerce Single Product page to resemble the Nike website…
Live Coding a WooCommerce Mini-Plugin
Join me for a live coding session, while I try to develop a custom, commercial WooCommerce plugin in less than…
WooCommerce AMA with Rodolfo Melogli
Join me for an ‘Ask Me Anything About WooCommerce’ session – covering customization, development, plugins, analytics, marketing, forking, and more!…
Maximize Your WooCommerce Potential: Understanding User Behavior with Clarity
Learn how to use the free Microsoft Clarity plugin to record and analyze user behavior on your WooCommerce site, so…
Mastering WooCommerce Thank You Page Customization: A Plugin-Free Approach
Let’s learn how to personalize the WooCommerce Thank You page with simple code, so that you can enhance the customer…
Conversion-Focused Redesign Of The WooCommerce Single Product Page
Let’s improve the boring WooCommerce Single Product page and encourage MORE users to convert. Hosted by Rodolfo Melogli Masterclass overview…
Allow Multiple Payments In The Same WooCommerce Order
All deposit / split / partial payment plugins generate an additional order for paying the balance. Today, we change that….
Live Coding a Simple WooCommerce Checkout Currency Switcher
I definitely need a EUR/USD switcher in my Woo shop, and I’d love to try implementing it without a plugin….
How to Find and Fix Slow Database Queries in WooCommerce
Learn how to resolve slow database queries in WordPress / WooCommerce websites. Use the right tools to boost performance and…
Live Coding a “Deal of the Week” Functionality For WooCommerce
I’ve always wanted to set up an automatic promotion on a different Woo product each week. Let’s code it together?…
Web Accessibility Basics for WooCommerce
Accessibility in ecommerce is increasingly a legal requirement, but it also helps you expand your audience. Hosted by Bet Hannon…
How to Avoid Timeouts When Running Millions of WooCommerce Tasks
Meet Action Scheduler – a scalable processor of large queues of PHP jobs. Learn how to run bulk actions without…
WooCommerce Reimagined: Powering Up with the AI Advantage
Say goodbye to the same old, boring WooCommerce experience. Let’s dive in and see what AI can do for your…
Live Coding a WooCommerce LMS Plugin
Watch me code a simple WooCommerce plugin for selling and managing online courses. Masterclass overview My business relies on creating…
WooCommerce No-Code Automations Make* Simple
* Not a spelling mistake. Here’s how you can build entire workflows and connect WooCommerce to other apps via Make,…
Better Than Subscriptions: Building a Re-order Page in WooCommerce
Transform WooCommerce re-ordering into a seamless, customer-centric experience that goes beyond the ordinary. Hosted by Patrick Rauland Masterclass overview Join…
How to Contribute to WooCommerce Core
Learn how to contribute to the WooCommerce plugin code by submitting your first pull request (PR). Hosted by Rodolfo Melogli…
Behind the Woo Scenes: How I Run Business Bloomer
Find out how I sell, support and manage the whole business via WooCommerce, some custom code, and a handful of…
– BACKED BY –
Is your WooCommerce store prepared for traffic spikes? Improve speeds up to 200% with our
managed WooCommerce hosting. Enjoy scalable server resources, rock-solid security, and 24/7 support.