Neil Matthews

Author: Neil Matthews

  • How to Delete WooCommerce Customers Who Have Never Made a Purchase

    How to Delete WooCommerce Customers Who Have Never Made a Purchase

    As your WooCommerce store grows, you may accumulate a significant number of registered users who have never made a purchase. These inactive accounts can clutter your customer database, making it harder to manage and potentially slowing down your site. In this blog post, we’ll explore why you might want to delete these inactive accounts and provide a simple PHP code snippet to help you do so safely.


    Why Delete Inactive WooCommerce Customers?

    1. Database Performance: A large number of inactive users can bloat your database, leading to slower query performance and longer backup times. Deleting these accounts can help optimize your database and improve overall site performance.
    2. Data Accuracy: Keeping your customer data clean and relevant is essential for effective marketing and customer relationship management. Removing inactive users helps you focus on customers who are actively engaged with your store.
    3. Security Concerns: Every user account represents a potential security risk. By minimizing the number of accounts in your database, you reduce the attack surface available to hackers.
    4. Cost Management: If you’re using CRM or email marketing tools that charge based on the number of contacts, deleting inactive users can help reduce unnecessary costs.

    How to Identify and Delete Inactive WooCommerce Customers

    Before proceeding with deletion, it’s important to back up your database. Once you have a backup, you can safely use the following code snippet to identify and delete users who have registered but never made a purchase.

    Step 1: Add the PHP Code Snippet

    Here’s a PHP code snippet that you can use to delete WooCommerce customers who have never made a purchase:

    function delete_customers_without_purchases() {
        global $wpdb;
    
        // Get all users with the customer role who have never made a purchase
        $customers = $wpdb->get_results("
            SELECT u.ID, u.user_login, u.user_email
            FROM {$wpdb->prefix}users u
            LEFT JOIN {$wpdb->prefix}usermeta um ON u.ID = um.user_id
            LEFT JOIN {$wpdb->prefix}wc_order_stats os ON u.ID = os.customer_id
            WHERE um.meta_key = '{$wpdb->prefix}capabilities'
            AND um.meta_value LIKE '%customer%'
            AND os.customer_id IS NULL
        ");
    
        if (!empty($customers)) {
            echo '<h2>Deleting Customers Who Have Never Made a Purchase</h2>';
            echo '<ul>';
    
            // Loop through each customer and delete their account
            foreach ($customers as $customer) {
                wp_delete_user($customer->ID);
                echo '<li>Deleted user: ' . esc_html($customer->user_login) . ' (' . esc_html($customer->user_email) . ')</li>';
            }
    
            echo '</ul>';
        } else {
            echo '<p>No customers found who have never made a purchase.</p>';
        }
    }
    
    // Usage example: Call this function to delete customers
    add_action('admin_init', 'delete_customers_without_purchases');

    Step 2: Implement the Code

    1. Using a Custom Plugin: You can create a small custom plugin to hold this code. To do this, create a folder named delete-inactive-customers in the wp-content/plugins/ directory. Inside that folder, create a file named delete-inactive-customers.php and paste the code snippet above into it. Then, activate the plugin from your WordPress dashboard.
    2. Adding to Theme’s functions.php: Alternatively, you can paste the code into your theme’s functions.php file. However, using a custom plugin is preferable as it won’t be affected when you update your theme.

    Step 3: Execute the Code

    The code is designed to run automatically when you access the WordPress admin area. It will scan for WooCommerce customers who have never made a purchase and delete their accounts.

    You can also remove the add_action('admin_init', 'delete_customers_without_purchases'); line and call the function manually if you prefer to run it only on demand.

    Step 4: Verify Deletion

    After running the code, you should verify that the inactive users have been deleted. You can check your user list in WooCommerce or by reviewing your database directly.

    Step 5: Disable the Code

    Once the code has executed and the inactive users have been deleted, it’s important to disable or remove the code to prevent accidental deletion in the future. If you added the code to a custom plugin, simply deactivate the plugin. If you placed it in your theme’s functions.php, you can comment it out or delete it.


    Conclusion

    Cleaning up your WooCommerce customer database by removing users who have never made a purchase is a practical step towards optimizing your store’s performance, enhancing security, and maintaining accurate data. The code snippet provided in this post offers a straightforward way to identify and delete these inactive accounts.

    Before implementing any deletion process, always ensure you have a recent backup of your database. This allows you to restore any data if needed. Once the inactive users are removed, you’ll have a more streamlined and manageable WooCommerce store.

    Feel free to share this post with other WooCommerce store owners, and if you have any questions or need further customization, leave a comment below!

    Photo by Markus Spiske on Unsplash

  • How to Extract Your Top Customers by Sales from Your WooCommerce Store

    How to Extract Your Top Customers by Sales from Your WooCommerce Store

    As a WooCommerce store owner, understanding who your top customers are can be crucial for driving business growth. These customers are not only valuable for repeat business, but they can also be excellent advocates for your brand. In this blog post, we’ll guide you through how to extract your top customers by sales from your WooCommerce store using a simple code snippet.


    Why Identifying Top Customers is Important

    1. Targeted Marketing: Knowing your top customers allows you to tailor your marketing efforts towards them, increasing the likelihood of repeat purchases.
    2. Customer Loyalty Programs: You can offer exclusive rewards or discounts to your top customers, strengthening their loyalty.
    3. Personalized Experience: Understanding your top customers’ preferences helps you offer a more personalized shopping experience.
    4. Customer Insights: Analyzing the purchasing habits of your top customers can provide valuable insights for product development and inventory management.

    How to Extract Top Customers by Sales: A Step-by-Step Guide

    To identify your top customers by sales in WooCommerce, you can use a custom SQL query or a PHP code snippet. For this guide, we’ll focus on a PHP solution that you can easily implement.

    Step 1: Prepare Your Environment

    Before proceeding, make sure you have access to your WooCommerce store’s backend, and you’re comfortable editing theme files or using a custom plugin.

    Step 2: Add the PHP Code Snippet

    Here’s a PHP code snippet that you can use to retrieve a list of your top customers based on their total spending:

    function get_top_customers_by_sales($limit = 10) {
        global $wpdb;
    
        // Query to get the top customers by total sales
        $query = "
            SELECT p.ID AS customer_id, 
                   SUM(pm2.meta_value) AS total_spent,
                   CONCAT_WS(' ', um1.meta_value, um2.meta_value) AS customer_name,
                   u.user_email
            FROM {$wpdb->prefix}posts AS p
            JOIN {$wpdb->prefix}postmeta AS pm1 ON p.ID = pm1.post_id
            JOIN {$wpdb->prefix}postmeta AS pm2 ON p.ID = pm2.post_id
            JOIN {$wpdb->prefix}users AS u ON u.ID = p.post_author
            LEFT JOIN {$wpdb->prefix}usermeta AS um1 ON um1.user_id = u.ID AND um1.meta_key = 'first_name'
            LEFT JOIN {$wpdb->prefix}usermeta AS um2 ON um2.user_id = u.ID AND um2.meta_key = 'last_name'
            WHERE p.post_type = 'shop_order'
            AND p.post_status IN ('wc-completed')
            AND pm1.meta_key = '_customer_user'
            AND pm2.meta_key = '_order_total'
            GROUP BY p.post_author
            ORDER BY total_spent DESC
            LIMIT %d
        ";
    
        // Prepare and execute the query
        $results = $wpdb->get_results($wpdb->prepare($query, $limit));
    
        // Output the results
        if (!empty($results)) {
            echo '<h2>Top ' . $limit . ' Customers by Sales</h2>';
            echo '<table>';
            echo '<tr><th>Customer ID</th><th>Customer Name</th><th>Email</th><th>Total Spent</th></tr>';
            foreach ($results as $result) {
                echo '<tr>';
                echo '<td>' . esc_html($result->customer_id) . '</td>';
                echo '<td>' . esc_html($result->customer_name) . '</td>';
                echo '<td>' . esc_html($result->user_email) . '</td>';
                echo '<td>' . wc_price($result->total_spent) . '</td>';
                echo '</tr>';
            }
            echo '</table>';
        } else {
            echo '<p>No customers found.</p>';
        }
    }
    
    // Usage example
    add_shortcode('top_customers_by_sales', 'get_top_customers_by_sales');

    Step 3: Implement the Code

    1. Using a Custom Plugin: You can create a small custom plugin to hold this code. To do this, create a folder named top-customers-by-sales in the wp-content/plugins/ directory. Inside that folder, create a file named top-customers-by-sales.php and paste the code snippet above into it. Then, activate the plugin from your WordPress dashboard.
    2. Adding to Theme’s functions.php: Alternatively, you can paste the code into your theme’s functions.php file. However, using a custom plugin is preferable as it won’t be affected when you update your theme.

    Step 4: Display the Top Customers

    You can display the top customers on any page or post using the shortcode [top_customers_by_sales]. This shortcode will render a table listing your top customers by total sales.

    Step 5: Customize the Output

    You can customize the $limit parameter in the function to control how many top customers you want to display. For example, to show the top 20 customers, change the function call to:

    get_top_customers_by_sales(20);

    Conclusion

    Identifying your top customers by sales is a powerful way to leverage your WooCommerce store’s data for better marketing and customer retention strategies. With the simple code snippet provided, you can quickly extract this valuable information and start building stronger relationships with your best customers.

    By displaying this data, either on the backend or directly on a webpage, you can keep track of your most valuable customers and ensure they receive the attention they deserve.

    Feel free to share this post with other WooCommerce store owners and leave a comment below if you have any questions or need further customization!


    By implementing this solution, you’ll have a clear view of who your top spenders are, allowing you to focus on what matters most—keeping your best customers happy and engaged.

    Photo by Blake Wisz on Unsplash

  • How to Integrate WooCommerce Sales with Amazon Fulfillment: A Complete Guide

    How to Integrate WooCommerce Sales with Amazon Fulfillment: A Complete Guide

    Running an eCommerce store can be challenging, especially when it comes to managing inventory and fulfilling orders. For many store owners using WooCommerce, Amazon Fulfillment (FBA – Fulfillment by Amazon) offers a robust solution. By integrating your WooCommerce store with Amazon Fulfillment, you can automate the process of order management, inventory tracking, and shipping, allowing you to focus on scaling your business.

    In this blog post, we’ll walk you through the steps of integrating WooCommerce with Amazon Fulfillment, discuss the benefits, and recommend some of the best plugins available to make the integration seamless.


    Why Integrate WooCommerce with Amazon Fulfillment?

    Integrating WooCommerce with Amazon Fulfillment provides several key benefits:

    1. Efficient Order Management: Orders placed on your WooCommerce store are automatically sent to Amazon for fulfillment, saving you time and reducing manual errors.
    2. Faster Shipping: Amazon’s vast network ensures quick delivery, often within 1-2 days, improving customer satisfaction.
    3. Inventory Management: Syncing your inventory between WooCommerce and Amazon helps prevent overselling and stockouts.
    4. Global Reach: Amazon’s international fulfillment centers can help you expand your business to new markets with minimal effort.
    5. Cost-Effective: Leveraging Amazon’s fulfillment services can be more cost-effective than managing your own warehousing and shipping operations.

    Steps to Integrate WooCommerce with Amazon Fulfillment

    Here’s a step-by-step guide to integrate your WooCommerce store with Amazon Fulfillment:

    Step 1: Choose the Right Plugin

    To connect WooCommerce with Amazon FBA, you’ll need a reliable plugin. Here are some of the best options available:

    1. WooCommerce Amazon Fulfillment by WP Lab:
      This plugin is one of the most popular options, offering seamless integration between WooCommerce and Amazon FBA. It allows you to send orders to FBA automatically and sync your inventory in real-time.
    2. Amazon Integration for WooCommerce by Codisto:
      Codisto offers a comprehensive solution for integrating WooCommerce with Amazon, enabling product listings, inventory sync, and order management all from within your WooCommerce dashboard.
    3. WP-Lister for Amazon:
      WP-Lister allows you to list your WooCommerce products on Amazon and sync orders and inventory between the two platforms. It’s a great option if you also want to sell directly on Amazon.
    4. M2E Pro:
      M2E Pro provides advanced integration features, including multi-channel fulfillment, making it ideal for larger stores with complex needs.

    Step 2: Install and Configure the Plugin

    Once you’ve chosen a plugin, the next step is to install it on your WooCommerce store:

    1. Install the Plugin: Download the plugin from the WordPress repository or the developer’s website. Then, navigate to your WordPress dashboard, go to “Plugins” > “Add New,” upload the plugin file, and activate it.
    2. Configure Amazon FBA Settings: After installation, go to the plugin settings. You’ll need to connect your Amazon Seller Central account by entering your API credentials. The plugin’s documentation will guide you through this process.
    3. Set Up Fulfillment Rules: Configure how orders are sent to Amazon for fulfillment. For example, you can choose to fulfill all orders automatically or only those that meet specific criteria.
    4. Sync Your Inventory: Ensure your WooCommerce inventory is synced with Amazon FBA to prevent overselling. The plugin will typically handle this automatically, but it’s good to verify the settings.

    Step 3: Test the Integration

    Before going live, it’s essential to test the integration:

    1. Place a Test Order: Place an order through your WooCommerce store to ensure it’s correctly sent to Amazon for fulfillment.
    2. Check Inventory Sync: Make sure that any changes in your WooCommerce inventory reflect accurately in Amazon FBA and vice versa.
    3. Monitor Order Fulfillment: Verify that Amazon is fulfilling orders as expected, including shipping and tracking.

    Step 4: Monitor and Optimize

    After the integration is live, regularly monitor its performance:

    1. Track Order Fulfillment: Ensure orders are processed and shipped promptly. Address any issues immediately.
    2. Optimize Inventory Levels: Keep an eye on inventory to avoid stockouts or overstock situations.
    3. Review Costs: Periodically review the costs associated with Amazon FBA to ensure it remains cost-effective for your business.

    Conclusion

    Integrating WooCommerce with Amazon Fulfillment is a powerful way to streamline your eCommerce operations, ensuring fast and reliable order delivery while freeing you up to focus on growth. With the right plugin, you can automate much of the process, reduce errors, and improve customer satisfaction.

    By following the steps outlined in this guide and choosing the right plugin for your needs, you’ll be well on your way to a more efficient and scalable WooCommerce store.

    For more detailed instructions on the plugins mentioned, be sure to check out their official documentation linked above.


    If you found this guide helpful, feel free to share it with other WooCommerce store owners looking to optimize their fulfillment process. And if you have any questions or need further assistance, leave a comment below!

    If you need help setting up Amazon fulfilment, get in touch.

    Photo by Sam Balye on Unsplash

  • Don’t Add Discomfort Hurdles

    Don’t Add Discomfort Hurdles

    As I’ve worked with my client’s sites over the years I’ve noticed other developers and agencies add discomfort hurdles into the way way they work with site owners.

    When I inherit these new clients, I have to stumble over these hurdles before I can start working with them

    This blog post is a plea to these people to NOT add discomfort hurdles when working with site owners.

    What Is A Discomfort Hurdle

    A discomfort hurdle is a technique used by some agencies and developer to lock in a client and make it difficult for them to move away and work with another developer.

    You create a level of discomfort a client has to jump over to move to a new service provider, for some it’s such a pain in the back side they will stay with their current developer even if issues have arisen.

    I’m going to get some push back on this post saying, it’s how you build the best site, but is it really? What you are doing is creating a few quid of recurring income in hosting and locking your client into your services making it painful to move away from you.

    I understand why the hurdles are there I get it, you want the best hosting, you want to build the best site you can but NO! Let the client buy their own hosting and licenses so they are not locked in.

    Example Hurdles

    Here are some example of the hurdles I have seen:

    • Developer or agencies owning domain names and holding them to ransom (don’t ever let someone control your domain!).
    • Being forced to use an agencies hosting when they build a site.
    • Owning software licenses and revoking them when they move away
    • Locking down admin user names and password.

    Why I Don’t Add These Hurdles

    I don’t add these types of hurdles into my service offering because of the following:

    • I don’t want the obligations, if the hosting goes down it’s me that gets the call in the middle of the night not GoDaddy.
    • I don’t want to lock in every client I work with, there are some weird people out there 🙂
    • I want my clients to move providers easily and quickly if they want
    • I lock in clients with the quality of my work not via discomfort.

    Wrap Up

    Your work should speak for itself, your clients should stay with you based upon the quality of the work done not some stupid discomfort hurdle.

    Talking about work, if you need help with your WordPress site or WooCommerce Store, get in touch.

    Photo by Quino Al on Unsplash

  • How to Troubleshoot a Crashed WordPress Site: A Step-by-Step Guide

    How to Troubleshoot a Crashed WordPress Site: A Step-by-Step Guide

    A crashed WordPress site can be a nightmare, especially if it’s your business or portfolio on the line. But don’t panic—most issues can be resolved if you follow a systematic approach. This guide will walk you through the steps to troubleshoot a crashed WordPress site, with screen grabs to help illustrate the process.


    1. Identify the Symptoms

    Before diving into troubleshooting, it’s essential to identify what “crashed” means in your case. Common symptoms of a crashed WordPress site include:

    • White Screen of Death (WSOD): The site displays a completely white screen with no error messages.
    • 500 Internal Server Error: A generic server error that doesn’t give much information.
    • Database Connection Error: The site cannot connect to the database.
    • Critical Error Message: WordPress displays a message indicating a critical error.

    Example Screenshot:

    500 Internal Server Error (Replace with an actual screenshot of a 500 Internal Server Error on a WordPress site.)


    2. Check for a Backup

    Before making any changes, check if you have a recent backup of your site. If something goes wrong during troubleshooting, a backup will allow you to restore your site to a working state.

    Step-by-Step Instructions:

    1. Log in to your hosting control panel (e.g., cPanel).
    2. Navigate to the backup section and check for the most recent backup.
    3. If you have a backup plugin installed (like UpdraftPlus), you can also check there for available backups.

    3. Enable Debugging in WordPress

    Enabling debugging can provide more detailed error messages, making it easier to identify the issue.

    Step-by-Step Instructions:

    1. Access your site’s files via FTP or your hosting file manager.
    2. Open the wp-config.php file located in the root directory of your WordPress installation.
    3. Add the following lines of code (or change false to true if already present):
       define( 'WP_DEBUG', true );
       define( 'WP_DEBUG_LOG', true );
       define( 'WP_DEBUG_DISPLAY', false );
    1. Save and close the file.

    4. Deactivate All Plugins

    A common cause of a crashed site is a conflict between plugins. The quickest way to test this is to deactivate all plugins and see if the site comes back online.

    Step-by-Step Instructions:

    1. Access your site’s files via FTP or the file manager.
    2. Navigate to the wp-content directory.
    3. Rename the plugins folder to plugins_old to deactivate all plugins at once.
    4. If the site comes back online, rename the folder back to plugins and then reactivate plugins one by one to identify the culprit.

    5. Switch to a Default Theme

    Sometimes, issues arise from a problem with your active theme. Switching to a default WordPress theme can help determine if the theme is the source of the crash.

    Step-by-Step Instructions:

    1. Access your site’s files via FTP or the file manager.
    2. Navigate to the wp-content/themes directory.
    3. Rename the folder of your active theme to something else, forcing WordPress to fall back to a default theme like Twenty Twenty-One.

    6. Check File Permissions

    Incorrect file permissions can also cause a WordPress site to crash. The correct permissions are generally:

    • Folders: 755
    • Files: 644

    Step-by-Step Instructions:

    1. Log in to your hosting control panel and open the file manager, or use an FTP client.
    2. Navigate to your WordPress root directory.
    3. Right-click on the folders and files to check their permissions.
    4. Adjust permissions if they are not set to 755 for folders and 644 for files.

    7. Increase PHP Memory Limit

    A common issue that can cause a WordPress site to crash is running out of memory. Increasing the PHP memory limit can often resolve this.

    Step-by-Step Instructions:

    1. Access your site’s files via FTP or your hosting file manager.
    2. Open the wp-config.php file.
    3. Add the following line of code just above the /* That's all, stop editing! Happy blogging. */ line:
       define( 'WP_MEMORY_LIMIT', '256M' );
    1. Save and close the file.

    8. Review Server Error Logs

    If none of the above steps resolve the issue, the problem might be server-related. Reviewing the server error logs can provide more information.

    Step-by-Step Instructions:

    1. Access your hosting control panel and navigate to the logs section.
    2. Open the error logs and look for any recent errors that might indicate the cause of the crash.

    Conclusion

    A crashed WordPress site can be daunting, but with a systematic approach, you can often identify and resolve the issue quickly. Start by identifying the symptoms, then proceed with debugging steps such as deactivating plugins, switching themes, checking file permissions, and reviewing error logs.

    Remember, always back up your site before making any significant changes. With these steps, you’ll be well-equipped to get your WordPress site back up and running.

    Photo by Bermix Studio on Unsplash

  • How I Debug WordPress Code: A Step-by-Step Guide

    How I Debug WordPress Code: A Step-by-Step Guide

    Debugging WordPress code is an essential skill for developers and site administrators. Whether you’re trying to fix a bug, improve performance, or develop new features, knowing how to identify and solve issues in your WordPress code can save you a lot of time and frustration.

    In this blog post, we’ll explore several methods and tools that you can use to debug WordPress code. We’ll also provide screenshots to guide you through the process.


    1. Enable WordPress Debugging

    The first step in debugging WordPress is to enable the built-in debugging mode. WordPress comes with a set of constants that you can define in the wp-config.php file to control how errors and warnings are displayed.

    Step-by-Step Instructions:

    1. Locate the wp-config.php file in the root directory of your WordPress installation.
    2. Open the file in a text editor.
    3. Add the following lines of code:
       define( 'WP_DEBUG', true );
       define( 'WP_DEBUG_LOG', true );
       define( 'WP_DEBUG_DISPLAY', false );
    • WP_DEBUG: Enables debugging mode.
    • WP_DEBUG_LOG: Saves errors to a debug.log file located in the wp-content directory.
    • WP_DEBUG_DISPLAY: Prevents errors from being displayed on the website (useful for live sites).
    1. Save the file and re-upload it to your server if you’re editing locally.

    Enabling Debugging in wp-config.php (Replace with an actual screenshot of the wp-config.php file with the debug constants highlighted.)

    Result:

    With debugging enabled, WordPress will now log errors and warnings to a file called debug.log in the wp-content directory. You can review this file to find detailed information about any issues on your site.


    2. Use the Query Monitor Plugin

    Query Monitor is a powerful tool for debugging WordPress sites. It provides detailed information about database queries, PHP errors, hooks, and more directly from the WordPress admin bar.

    Step-by-Step Instructions:

    1. Install and activate the Query Monitor plugin from the WordPress Plugin Repository.
    2. After activation, you’ll see a new menu in the WordPress admin bar labeled “Query Monitor.”
    3. Click on the Query Monitor menu to view detailed information about the current page.
    • Queries: View all database queries and identify any slow or duplicated ones.
    • Hooks: Check which hooks are being triggered on the current page.
    • Errors: See PHP errors, warnings, and notices.

    Query Monitor Plugin Interface (Replace with an actual screenshot of the Query Monitor interface showing queries and errors.)

    Result:

    Query Monitor helps you identify performance bottlenecks and coding errors by providing a wealth of information directly within the WordPress admin.


    3. Debugging JavaScript and CSS

    JavaScript and CSS issues can often cause parts of your WordPress site to break or not function as expected. Using browser developer tools is the best way to debug these types of issues.

    Step-by-Step Instructions:

    1. Open your browser’s developer tools (usually accessible by pressing F12 or right-clicking on the page and selecting “Inspect”).
    2. Navigate to the “Console” tab to view JavaScript errors. The console will display errors, warnings, and messages that can help you identify issues.
    3. Use the “Elements” tab to inspect your site’s HTML and CSS. Here, you can see which CSS rules are being applied and make live edits to test fixes.
    4. Check the “Network” tab to monitor HTTP requests, which can help you debug issues with resources not loading or returning errors.

    Browser Developer Tools (Replace with an actual screenshot of the browser developer tools highlighting the Console and Network tabs.)

    Result:

    Browser developer tools allow you to debug client-side issues in real-time, making it easier to identify and fix JavaScript and CSS problems.


    4. Using Error Logs

    Sometimes, the errors might not be apparent in the debug.log or the front end. In such cases, accessing the server error logs can provide additional information.

    Step-by-Step Instructions:

    1. Access your server’s control panel (e.g., cPanel, Plesk) or connect via SSH.
    2. Navigate to the logs section and find the error logs. These logs are often located in the logs directory or accessible directly from the control panel.
    3. Look for recent errors corresponding to the times when the issues occurred.

    Server Error Logs (Replace with an actual screenshot of server error logs showing a recent error.)

    Result:

    Server error logs provide deeper insights into issues that may not be captured by WordPress’s own logging, helping you diagnose server-level problems.


    5. Debugging with Xdebug

    For more advanced debugging, especially if you’re developing custom themes or plugins, using a PHP debugger like Xdebug is invaluable.

    Step-by-Step Instructions:

    1. Install Xdebug on your local development environment. This usually involves updating your php.ini file with the Xdebug extension.
    2. Set up your IDE (e.g., PhpStorm, VS Code) to listen for Xdebug connections.
    3. Place breakpoints in your code where you want the execution to pause. This allows you to inspect variables, step through code, and identify where things are going wrong.

    Xdebug in Action (Replace with an actual screenshot of Xdebug in action within an IDE, showing breakpoints and variable inspection.)

    Result:

    Using Xdebug provides a deep level of control over your debugging process, allowing you to inspect and manipulate code execution in real-time.


    Conclusion

    Debugging WordPress code is a critical skill for anyone managing or developing a WordPress site. By enabling WordPress’s built-in debugging features, using plugins like Query Monitor, utilizing browser developer tools, and exploring server logs, you can identify and fix issues efficiently. For advanced users, tools like Xdebug provide even more control over the debugging process.

    Remember, a well-debugged site is a well-functioning site. Happy debugging!


    Feel free to replace the placeholder URLs with actual screenshots to make the post more visually engaging and informative.

    If you need me to custom code something for your WooCommerce store I might need to debug things, why not hire me. Jesus that was a reach to put a sales messages in this blog post.

    Photo by Krzysztof Niewolny on Unsplash

  • Monitoring User Actions on a WordPress Site: A Comprehensive Guide

    Monitoring User Actions on a WordPress Site: A Comprehensive Guide

    Running a WordPress site is more than just creating great content and maintaining a visually appealing design; it’s also crucial to understand what your users are doing on your site. Monitoring user actions can help you gain insights into your site’s performance, security, and user engagement. Whether you want to keep an eye on user logins, content changes, or other activities, WordPress offers several tools to make this process easier.

    In this blog post, we’ll explore why monitoring user actions is important, how you can do it on your WordPress site, and highlight some of the best plugins available for the job.

    Why Monitor User Actions?

    1. Security

    Monitoring user actions can alert you to suspicious activity, such as unauthorized logins or attempts to change critical site settings. This allows you to take action before any damage is done.

    2. User Engagement

    Understanding how users interact with your site helps you make informed decisions about content, design, and features. For example, you can see which pages users spend the most time on and which ones they quickly leave.

    3. Accountability

    If you have multiple users managing your site, monitoring can ensure that everyone is following the correct procedures. You can track changes made by different users and hold them accountable for their actions.

    How to Monitor User Actions in WordPress

    The best way to monitor user actions on your WordPress site is by using plugins. These tools provide detailed logs of user activity and often include features like alerts and reports.

    1. WP Activity Log

    WP Activity Log is one of the most comprehensive user activity monitoring plugins available. It keeps a detailed log of everything happening on your site, from user logins and logouts to changes in posts, pages, and settings.

    Key Features:

    • Real-time logging of user actions
    • Alerts for specific actions (e.g., failed login attempts)
    • Detailed reports
    • Easy to filter logs by user, role, or action

    You can find the plugin on the WordPress Plugin Repository.

    WP Activity Log Screenshot

    2. Simple History

    If you’re looking for a more lightweight solution, Simple History might be the right choice. This plugin logs user activity directly in your WordPress dashboard, allowing you to quickly see what’s happening on your site.

    Key Features:

    • Displays user actions in an easy-to-read timeline
    • Tracks changes in posts, pages, and widgets
    • Includes information about failed login attempts

    Check out the plugin on the WordPress Plugin Repository.

    Simple History Screenshot

    3. User Activity Log

    User Activity Log is another powerful plugin that offers detailed logs of user actions. It’s particularly useful for sites with multiple administrators or contributors.

    Key Features:

    • Logs activities such as post creation, updates, and deletion
    • Tracks login and logout times
    • Sends email notifications for specific actions
    • Export logs to CSV for detailed analysis

    The plugin is available on the WordPress Plugin Repository.

    User Activity Log Screenshot

    How to Choose the Right Plugin

    When selecting a plugin to monitor user actions on your WordPress site, consider the following factors:

    • Site Complexity: Larger sites with many users and a lot of content will benefit from more comprehensive logging solutions like WP Activity Log.
    • Ease of Use: If you prefer something simple and easy to manage, Simple History offers a straightforward approach.
    • Notifications and Alerts: If you need to be alerted to specific actions, such as failed login attempts or changes to critical content, ensure the plugin you choose offers these features.

    Conclusion

    Monitoring user actions on your WordPress site is essential for maintaining security, understanding user behavior, and ensuring accountability among your team. With the right plugin, you can easily keep track of all important activities on your site.

    By choosing a plugin that suits your needs, whether it’s WP Activity Log for detailed insights, Simple History for ease of use, or User Activity Log for customizable alerts, you’ll be able to ensure your site runs smoothly and securely.

    Have any questions or tips on monitoring user actions in WordPress? Share them in the comments below!


    Useful Links:

    Feel free to try out these plugins and take control of user actions on your WordPress site today!

    This blog post is now formatted for easier reading and better engagement. Feel free to customize it further to suit your specific needs!

    If you need help monitoring your site get in touch.

    Photo by Farzad on Unsplash

  • WooCommerce: How I Troubleshoot Shipping

    WooCommerce: How I Troubleshoot Shipping

    In this video I’ll show you the technique I use to troubleshoot issues I often see where a customer gets the wrong shipping zone and as a result the shipping fees are set incorrectly

    Wrong shipping fees can done one of two things, charge too little and you have to absorb expensive shipping fees, cutting into your profits.

    Too high shipping fees can cause cart abandonments and you lose customers, both situations are grim.

    Video

    Here’s a video to show you how I troubleshoot shipping feed.

    Wrap Up

    Are you looking for a freelance WooCommerce developer? Well you are in luck that’s what I do, let’s start a conversation about any requirements you have, get in touch.

    Photo by Sumit Kshirsagar on Unsplash

  • How to Log Emails Sent from WordPress: A Comprehensive Guide

    How to Log Emails Sent from WordPress: A Comprehensive Guide

    How to Log Emails Sent from WordPress – Managing a WordPress website often involves sending a variety of emails—order confirmations, user registrations, password resets, and more. However, sometimes these emails may not be delivered as expected, leading to confusion and potentially missed opportunities. To effectively monitor and troubleshoot email delivery issues, it’s essential to log the emails sent from your WordPress site.

    In this blog post, we’ll explore how to log emails in WordPress, why it’s important, and which plugins can help you achieve this.

    Why Log Emails in WordPress?

    Logging emails sent from your WordPress site offers several benefits:

    1. Troubleshooting Email Delivery Issues:
    • If users report not receiving emails, you can quickly check the logs to confirm if the emails were sent and diagnose where the problem might be (e.g., incorrect email address, server issues).
    1. Record Keeping:
    • Keeping logs of all sent emails helps in maintaining records for customer communications, especially useful for eCommerce sites and membership websites.
    1. Monitoring Email Performance:
    • By tracking your email logs, you can analyze patterns in your email sending and identify any consistent issues with specific types of emails.
    1. Compliance:
    • In some industries, having a log of sent emails is important for regulatory compliance, ensuring that communication records are maintained properly.

    How to Log Emails in WordPress

    WordPress does not have built-in email logging functionality, but you can easily add this feature using plugins. Below are some of the best plugins for logging emails in WordPress.

    1. WP Mail Logging by WPForms

    WP Mail Logging by WPForms is one of the most popular plugins for logging emails sent from WordPress. It’s lightweight, easy to use, and integrates seamlessly with any email setup on your site.

    Features:

    • Email Logs: View detailed logs of all emails sent from your site, including recipient, subject, and time.
    • Search Functionality: Easily search through your email logs to find specific communications.
    • Automatic Log Cleanup: Set a schedule to automatically clean up old email logs to save database space.
    • Export Logs: Export your email logs in CSV format for analysis or record-keeping.

    How to Use:

    1. Install and activate the WP Mail Logging plugin from the WordPress Plugin Repository.
    2. Once activated, go to WP Mail Logging > Logs in your dashboard to view the email logs.
    3. Configure the settings according to your needs, such as setting the log retention period.

    2. Email Log by Sudar

    Email Log by Sudar is another excellent plugin that provides comprehensive email logging capabilities. It is highly customizable and allows you to log emails with various details.

    Features:

    • Detailed Logs: Track every email sent from your site, including recipient, subject, date, and status.
    • Search and Filter: Easily search and filter logs based on different criteria.
    • View Email Content: Optionally log the full content of each email, including headers and body.
    • Export Logs: Export your logs to CSV for further analysis.

    How to Use:

    1. Install and activate the Email Log plugin from the WordPress Plugin Repository.
    2. Go to Email Log > Email Logs to view and manage your email logs.
    3. Configure settings to enable or disable logging of email content, headers, and attachments.

    3. WP Activity Log

    WP Activity Log is a comprehensive logging plugin that tracks all activities on your WordPress site, including email sending. While it’s primarily designed for security, its email logging feature is robust and detailed.

    Features:

    • Comprehensive Logging: Logs all activities on your WordPress site, including email sending.
    • Real-Time Alerts: Get notified in real-time if an email fails to send or encounters issues.
    • Detailed Reports: Generate detailed reports of email activities, useful for audits.
    • Integration: Works well with other plugins, including WP Mail SMTP and WooCommerce.

    How to Use:

    1. Install and activate the WP Activity Log plugin from the WordPress Plugin Repository.
    2. Navigate to WP Activity Log > Activity Log to monitor email and other site activities.
    3. Set up real-time alerts and reporting as needed.

    Best Practices for Email Logging

    1. Regularly Review Logs:
    • Periodically check your email logs to identify and resolve any issues before they affect users.
    1. Limit Log Retention:
    • To prevent your database from becoming bloated, set up automatic log cleanup schedules, retaining logs only for a necessary period.
    1. Export and Backup Logs:
    • Regularly export and backup your email logs, especially if they are critical for your business operations or compliance requirements.
    1. Monitor for Errors:
    • Keep an eye out for any errors in your email logs, such as emails failing to send, and address them promptly.

    Conclusion

    Email logging is an essential tool for any WordPress site that relies on email communication. Whether you’re managing an eCommerce site, a membership platform, or a simple blog, ensuring that your emails are sent and received reliably is crucial. Plugins like WP Mail Logging, Email Log by Sudar, and WP Activity Log provide powerful solutions for tracking your emails and troubleshooting any delivery issues.

    By implementing email logging, you gain valuable insights into your site’s email performance, can better manage customer communication, and ensure that your email delivery is as reliable as possible.

    If you need help with email from your WordPress site get in touch.

  • Why I Migrated From Jetpack Stats To Koko Analytics

    Why I Migrated From Jetpack Stats To Koko Analytics

    For years I have been using the Jetpack plugin for their lightweight stats feature. It’s a great little tool it gives me an overview of site traffic at a glance.

    For detailed analytics I use Google analytics, but I still like to have a feel of site visitors and pagee views at a glance.

    Jetpack stats was great for that. The stats plugin used to be a separate plguin then it was merged into Jetpack.

    Years back I must have created a non-commercial license for jetpack (I have no memory of this) and I’ve been using the stats on that license.

    A few weeks back I got an alert that they recognise I’m using a non-commercial license on a commercial site, fair enough, I can’t argue with that, I’m only using Jetpack for the stats and I can’t justify the price of more than £80 per year for a few stats, so I went looking for a replacement.

    Enter Koko Analytics a freemium plugin that does exactly what I need at no cost.

    Video

    Here’s a quick video tour of the Koko plugin so you can see it in action.

    Wrap Up

    Bye Jetpack it’s you not me, we need to break up.

    I recommend Koko Analytics if you are in the same situation.

    If you need help with your WooCommerce store get in touch.

    Photo by Anja Bauermann on Unsplash

  • How to Fix WordPress Email Delivery Issues with the WP Mail SMTP Plugin

    How to Fix WordPress Email Delivery Issues with the WP Mail SMTP Plugin

    If you’ve ever experienced problems with emails not being delivered from your WordPress site—whether they’re notifications, order confirmations, or password resets—you’re not alone. This is a common issue, and fortunately, there’s a reliable solution: using an SMTP plugin. In this blog post, we’ll walk you through how to install and configure the WP Mail SMTP plugin to ensure your emails reach your recipients’ inboxes.

    Why WordPress Emails Fail

    Before diving into the solution, it’s important to understand why emails from WordPress sometimes fail to be delivered. WordPress uses the PHP mail() function by default to send emails, but many hosting providers don’t configure this function correctly, leading to issues like:

    • Emails being marked as spam.
    • Emails not being sent at all.
    • Emails being delayed.

    These issues often occur because emails sent via PHP mail() lack proper authentication, which email clients like Gmail, Yahoo, and Outlook rely on to filter spam.

    The Solution: WP Mail SMTP Plugin

    The WP Mail SMTP plugin resolves these issues by reconfiguring WordPress to use an SMTP (Simple Mail Transfer Protocol) server for sending emails. SMTP is the industry-standard method for sending emails that are less likely to be marked as spam because they include proper authentication.

    Step-by-Step Guide to Setting Up WP Mail SMTP

    1. Install the WP Mail SMTP Plugin

    First, you need to install the WP Mail SMTP plugin. Here’s how:

    1. Log in to your WordPress dashboard.
    2. Navigate to Plugins > Add New.
    3. In the search bar, type “WP Mail SMTP.”
    4. Find the plugin named “WP Mail SMTP by WPForms” and click Install Now.
    5. Once installed, click Activate.

    2. Configure the WP Mail SMTP Plugin

    After activating the plugin, you’ll need to configure it to work with your SMTP service provider.

    1. Navigate to WP Mail SMTP Settings:
    • Go to WP Mail SMTP > Settings from your WordPress dashboard.
    1. Set the From Email:
    • Enter the email address you want your emails to be sent from. This should be an address from your domain (e.g., [email protected]) for best results.
    • Check the box labeled Force From Email to ensure all emails use this address.
    1. Set the From Name:
    • Enter the name you want the emails to appear from. For example, you can use your business name.
    • Check the box labeled Force From Name to apply this setting to all emails.
    1. Choose Your Mailer:
    • WP Mail SMTP supports several popular mailers. You can select one based on your preference and needs. Common options include:
      • SMTP: If you have SMTP credentials from your hosting provider or a third-party email service.
      • Gmail: To send emails using your Gmail or Google Workspace account.
      • SendGrid: A reliable service for sending large volumes of emails.
      • Mailgun: Another popular option for high deliverability rates.
    • For simplicity, we’ll cover the SMTP option, but the steps are similar for other mailers.
    1. Configure SMTP Settings:
    • SMTP Host: Enter the SMTP server address provided by your email provider (e.g., smtp.yourdomain.com).
    • Encryption: Choose either SSL or TLS based on your provider’s recommendation.
    • SMTP Port: Usually, 465 for SSL or 587 for TLS.
    • Authentication: Set this to Yes.
    • SMTP Username: Enter the username for your SMTP account (usually your full email address).
    • SMTP Password: Enter the password for your SMTP account.
    1. Save Settings:
    • Click Save Settings to apply your configurations.

    3. Test Your Email Configuration

    Once you’ve configured WP Mail SMTP, it’s important to test it to ensure everything is working correctly.

    1. Send a Test Email:
    • Go to WP Mail SMTP > Tools.
    • Enter an email address where you want to send a test email.
    • Click Send Email.
    1. Check the Test Email:
    • Go to your email inbox and check if the test email arrived.
    • If the email was delivered to the inbox, your setup is working correctly.
    • If you encounter issues, double-check your SMTP settings or consult your email provider for troubleshooting.

    Benefits of Using WP Mail SMTP

    • Improved Email Deliverability: By using SMTP, your emails are authenticated and less likely to be marked as spam.
    • Better Reliability: Avoid issues with the PHP mail() function that can result in emails not being sent.
    • Compatibility: WP Mail SMTP works with a wide range of email services, giving you flexibility in choosing the best one for your needs.
    • Detailed Logs: The plugin offers logging features to help you monitor and troubleshoot email delivery.

    Conclusion

    Fixing WordPress email delivery issues is essential for maintaining effective communication with your users. The WP Mail SMTP plugin provides a straightforward solution to this common problem, ensuring your emails are delivered reliably and securely. Whether you’re running a small blog or a large eCommerce site, setting up SMTP is a simple step that can make a significant difference in how you interact with your audience.

    By following the steps outlined in this guide, you can easily configure WP Mail SMTP and say goodbye to email delivery issues.

    If you are having issues sending email from your WordPress site get in touch.

    Photo by Andersen Jensen on Unsplash

  • How to Customize WooCommerce Email Templates: A Step-by-Step Guide with Code Samples

    How to Customize WooCommerce Email Templates: A Step-by-Step Guide with Code Samples

    WooCommerce is one of the most popular eCommerce platforms for WordPress, offering robust features and extensive customization options. One of the most critical aspects of any eCommerce store is the emails sent to customers, such as order confirmations, shipping notifications, and more. WooCommerce provides default email templates, but these may not always align with your brand or meet your specific needs. Customizing these email templates can enhance your customer experience and reinforce your brand identity.

    In this blog post, we’ll walk you through the process of customizing WooCommerce email templates with code samples and best practices to make the process smoother.

    1. Understanding WooCommerce Email Templates

    WooCommerce email templates are located in the WooCommerce plugin directory. The path to the email templates is:

    wp-content/plugins/woocommerce/templates/emails/

    Here, you’ll find a range of PHP files corresponding to different types of emails, such as:

    • customer-processing-order.php
    • customer-completed-order.php
    • customer-refunded-order.php
    • admin-new-order.php

    These templates control the content and structure of the emails sent to your customers.

    2. Creating a Custom Email Template

    Step 1: Copy the Template to Your Theme

    To customize an email template, you shouldn’t modify the core WooCommerce files directly. Instead, you should copy the template you want to customize into your theme or child theme. This ensures that your changes won’t be lost during WooCommerce updates.

    1. Create a new directory in your theme (or child theme) called woocommerce/emails.
    2. Copy the template file you want to customize from wp-content/plugins/woocommerce/templates/emails/ to wp-content/themes/your-theme/woocommerce/emails/.

    For example, if you want to customize the customer-completed-order.php template, you would copy:

    wp-content/plugins/woocommerce/templates/emails/customer-completed-order.php

    to

    wp-content/themes/your-theme/woocommerce/emails/customer-completed-order.php

    Step 2: Customize the Template

    Once the template is in your theme directory, you can open it in your code editor and start making changes.

    For example, let’s say you want to add a custom message to the completed order email. Open the customer-completed-order.php file and locate the area where you want to add the message. You might find a section like this:

    <?php
    /**
     * Customer completed order email
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-completed-order.php.
     *
     * @see https://docs.woocommerce.com/document/template-structure/
     * @package WooCommerce/Templates/Emails
     * @version 3.7.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
        exit;
    }
    
    echo $email_heading . "\n\n";
    
    echo __( 'Thanks for shopping with us. We hope you enjoy your purchase!', 'woocommerce' ) . "\n\n";
    
    do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email );
    
    // Add your custom message here
    echo __( 'Here is a special message from our team: Thank you for being a valued customer!', 'your-textdomain' ) . "\n\n";
    
    do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
    
    echo "\n****************************************************\n\n";

    In this example, the custom message “Here is a special message from our team: Thank you for being a valued customer!” has been added just before the order details.

    3. Customizing Email Styles

    WooCommerce emails use a base template (email-styles.php) for styling, located in the same emails directory. To customize the styles, follow the same process of copying the email-styles.php file to your theme’s woocommerce/emails/ directory.

    After copying, open the file and customize the CSS to match your branding. For example, you can change the primary color, font size, or add custom fonts:

    body {
        background-color: #f5f5f5;
        color: #333;
        font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
        font-size: 14px;
    }
    
    #body_content {
        background-color: #ffffff;
        color: #333;
        font-size: 14px;
    }
    
    #header_wrapper {
        background-color: #000;
        border-radius: 3px 3px 0 0;
    }
    
    h1 {
        color: #ffffff;
    }

    4. Using WooCommerce Hooks for Dynamic Content

    WooCommerce provides various hooks that you can use to inject dynamic content into your email templates. Here’s an example of how to use a hook to add custom content to the email:

    add_action( 'woocommerce_email_before_order_table', 'add_custom_email_content', 20, 4 );
    
    function add_custom_email_content( $order, $sent_to_admin, $plain_text, $email ) {
        if ( $email->id == 'customer_completed_order' ) {
            echo '<p style="color:#333;">Thank you for your purchase! As a token of our appreciation, use the code THANKYOU10 for 10% off your next order.</p>';
        }
    }

    In this example, the woocommerce_email_before_order_table hook is used to add a promotional message in the completed order email. This is a powerful way to tailor emails to specific customers or orders without hardcoding content.

    5. Testing Your Custom Emails

    After making changes, it’s crucial to test the emails to ensure they appear correctly across different email clients. WooCommerce has built-in testing features, or you can use third-party plugins like Email Template Customizer for WooCommerce to preview and test your emails.

    6. Best Practices for Email Customization

    • Backup Your Site: Before making any changes, always back up your WordPress site to avoid losing data.
    • Use a Child Theme: If you’re customizing templates in your theme, ensure you’re using a child theme to prevent losing changes during theme updates.
    • Test on Multiple Clients: Email clients like Gmail, Outlook, and Apple Mail all render HTML differently. Test your emails on multiple platforms to ensure consistency.
    • Keep Content Dynamic: Use WooCommerce hooks to keep content dynamic and relevant to each customer, which can enhance engagement.

    Conclusion

    Customizing WooCommerce email templates allows you to deliver a branded, personalized experience that resonates with your customers. By following the steps outlined in this post, you can easily modify email templates, add custom messages, and adjust the styling to align with your brand identity.

    Whether you’re adding a simple thank-you note or redesigning the entire email layout, the flexibility of WooCommerce ensures that you can create emails that not only look great but also drive customer loyalty and repeat business.

    If you need help to customise your WooCommerce emails you can hire me to do it for you.

    Photo by Thanhy Nguyen on Unsplash