You can use the woocommerce_order_status_changed action to find a failed order transition, and syslog to write your log, assuming the function is not disabled in your PHP configuration.
add_action( 'woocommerce_order_status_changed', function ( $order_id, $old_status, $new_status ) {
if ( 'failed' !== $new_status ) {
return;
}
$order = wc_get_order( $order_id );
if ( ! $order ) {
return;
}
$ip = $order->get_customer_ip_address();
openlog( 'wordpress', LOG_PID | LOG_ODELAY, LOG_LOCAL0 );
syslog( LOG_WARNING, "woocommerce.payment_failed ip=$ip order=$order_id" );
closelog();
}, 10, 3 );
You should get something like this in your syslog:
Sep 18 14:25 host wordpress[12345]: woocommerce.payment_failed ip=1.2.3.4 order=1234
Hope this helps!
Related Posts:
- Getting the gallery images from products in woocommerce?
- Get product details by url key in WordPress woocommerce
- Where is the “default attribute” values located in the phpMyAdmin in Woocommerce?
- Reverse engineering of WooCommerce Storefront filters
- Use WooCommerce function in other WordPress plugin
- WooCommerce Cart – Group Products By Category
- WooCommerce – update order item price and recalculate totals
- Add product description (content) to WooCommerce customer processing order email
- woocommerce – get_image_size() deprecated [closed]
- Woocommerce: How to remove page title from storefront theme homepage
- Remove checkout fields with Woocommerce depending on one of several shipping methods
- Replace one coupon to another after coupon added
- WooCommerce Multi-Currency shortcode not working
- Avada & WooCommerce Customization – Replacing product_title in woo-config.php [closed]
- How to unset fields in woocommerce product quick edit?
- WooCommerce template page for category
- Custom PLU field in woocommerce email
- Change how the Subtotal Price in cart being calculated [closed]
- Display Advanced Custom Fields value in Woocommerce admin order details
- Some images aren’t shown on wordpress after installation on host
- Show only one variaton in catalog on meta key
- WordPress & WooCommerce: Localhost, Staging and production environments and how to sync them without losing data
- PayPal Express on product page in WooCommerce – doesn’t seem to work on product page?
- Woocommerce – Want to block a user agent from accessing specific product pages
- Reset all stock status in woocommerce
- how customise Woocommerce style of custom theme
- Display Sales Quantity by product – Woocommerce [closed]
- wc_get_products() not return the images details
- Adding Product Name on Admin Panel Order list and User’s My-Account Order List
- woocommerce – how to get product link by id
- woocommerce_register_post action not firing [closed]
- How to change woocommerce checkout privacy policy, terms and condition text [closed]
- Woocommerce Email show HTML source code [closed]
- Add SKU in Product Title
- add to cart button not adding products in cart only in safari and edge browser [closed]
- WC Lightbox, Zoom and Slider not loading [closed]
- Send admin new order email to logged in user as well
- Woocomerce pulling wrong time from server -5 hrs difference
- I want hide view more button if price is blank
- What happens in the database when you link variations in woocommerce? [closed]
- Display custom product option in admin order details
- Archive product loop does not work with product filters
- remove sale price after finished countdown in woocommerce
- Woocommerce. How can I charge a fee from seller
- Please help me get rid of conflict with the JavaScript – I’m using WooCommerce with product blocks (Gutenb)
- Order Status without Email check. Only with Order-Number
- wc_get_product_id_by_sku() returns 0 for products added programatically via update_post_meta
- Display “Add to basket” and “Read more” buttons in the products shop page with woocommerce
- How to use decimal in quantity fields in WooCommerce for certain categories?
- Getting WordPress fatal error when hitting WooCommerce API
- Adding Tracking Details for Advanced Shipment Tracking Plugin From Order Notes
- check shipping amount in woocommerce_after_checkout_validation?
- How to display woocommerce product details on wp page
- Is it ok to 301 redirect product-category pages to custom pages?
- how i can limit woo Category number like as ‘posts_per_page’ => -1, but it cannot work please help me
- Update a list of product to featured if product have meta value (Mysql not wpquery)
- How to set up dynamic purchase pixel in Woocommerce?
- WooCommerce related product – only show from primary category
- Woocommerce: Variable Product – get variation name
- Forgot password flow does not work, getting email with a link but after clicking link it’s not working
- Html code is not showing in woocommerce shop page on adding in header.php?
- Is this code collecting user password?
- Removing Product from Woocommerce checkout page using Ajax
- WordPress Migration
- Replace product link with just product name on WooCommerce downloads page
- Importing Attributes in to Woocommerce
- woocomerce products and categories don’t display fixed
- Update Custom Post Meta Even if Draft
- Woocommerce Shipping based on condition and cart value
- Clone and modify Woocommerce Products catalog
- Update order status based on condition
- Category with description and thumbnail
- How to add ajax loading icon after click add to cart button on woocommerce
- Give auto discount to upsells products
- WooCommerce Table Rates not splitting up
- How can I let the user choose size of a shoe in the store? [closed]
- Hide/show specific products for backend users in woocommerce
- I’d like to add a button under the “Add to Cart” button which says “Buy on Amazon” and links to my Amazon product page [closed]
- If YITH Wishlist page is set to the WooCommerce my-account endpoint, the endpoints stop working all together. Any solution?
- WooCommerce pay per photo upload [closed]
- Override woocommerce template from parent theme
- Woocommerce checkout column total too small can not get it wider [closed]
- WooCommerce – How to add a custom field to only a specific email template [closed]
- Adding a column to woocomerce admin order page that can be sorted
- WordPress error
- Hide price, “add to cart” button and show message “Please log in to shop” [closed]
- Auto generating API keys using the Application Authentication Endpoint [closed]
- Is there a way to conditionally check if i’m on product variation page url like mydomain.com/myproduct?attribute_pa_color=red
- Critical error on woocommerce checkout page
- Can’t add variable products since update WooCommerce [closed]
- Add custom ID to WooCommerce product tab
- Account Status/Login on Main Menu with Avatar Pictures
- Custom plugin development with paypal subscription method
- Make Admin Side Fields Mandatory/Required
- Recalculate Completed Orders on WooCommerce to subtract Tax from Order Total
- Product reviews in my sql database
- How can I get the product permalink on the WooCommerce shop page?
- WP_Query->get_posts() take too long time to load data maybe 33 sec
- Searching in categories AND custom fields
- How to detect changes in WooCommerce store (react)?