Woocommerce order update webhook not firing - wordpress

I am using woo commerce and I have been looking at the webhooks.
All of them have logs (aka they have been firing)
However, the order.updated webhook is the only one which does not have any logs.
Can anybody help me? I have contacted woo themselves and have not had a response + checked many many threads but there does not seem to be a clue anywhere.
Thanks.
Dan

Have tried your approach created a Webhook with the order.updated as action.
Now ordered a product. And did the following
Changed the status from the following buttons.
But the webhook didn't fired at all.
Then went to the respective order and added some custom field value and clicked on save order.
Then checked the Webhook log. Yes for this above action a webhook triggered.
Now i tried with changing the status of the order from the order edit page itself.
Here changed from processing to on-hold status and did save order.
(Status processing was set previous while trying to update status from the order list dashboard itself.)
Again checked the webhook log for the same.
Yes and now the webhook had one more trigger logged in it.
Finally got to a conclusion that this order.updated action is triggered when any changes are made and saved view the editing the single order page.
A Collaborator has suggested to use action.woocommerce_order_status_changed instead.

In my case the cron-jobs were deactivated, due to an Error of our hosting provider.
The cron jobs can be viewed using this URL. Over the GUI i could not find the cron Job page.
https://{yourDomain}/wp-admin/tools.php?page=action-scheduler&status=past-due&order=asc&

Related

WooCommerce can't retrieve the order ID from order key in the URL when trying to charge recurring payment

I am running a Wordpress website with WooCommerce and Cartflows installed. I want to take subscription payment using the official WooCommerce Subscription plugin, however, I am facing an issue with the recurring payment process. The initial authorization is successful, but when the plugin tries to charge the recurring payment, I get an error and a failed order.
I checked the failed-scheduled-actions log file, and the following error message appeared: "DEBUG WooCommerce couldn't retrieve the order ID from order key in the URL." I have tried to troubleshoot the problem on my own, but I have not been able to find a solution.
If anyone has any experience with this issue or has any suggestions, I would greatly appreciate it. Thank you in advance for your help.

Stripe callback for successful payment from redirectToCheckout

Currently have a web app hosted on github pages.
I want to use firebase functions + stripe to handle payments.
I have most things set up and now am calling the method stripe.redirectToCheckout({ sessionId })
However, on a successful payment, I want to update the database but I don't see an option add a callback. It only redirects me to a success/failure page. Im thinking of maybe redirecting back to the webapp but with some queryParams. Then check if query param is there on page load, update DB. But that seems incorrect and people could just then navigate to the specific URL to be added into the database.
How do I achieve what I am trying to do?
You should ideally use Stripe Webhooks. You can create a HTTP function and specify it's URL for the webhook from Stripe Dashboard. So whenever an event (e.g. checkout session completed or failed) triggers the webhook, it'll send the event details to your Cloud Function and there you can update the database as required. There is no client side involved in this so risk is negligible.
Also checkout the Firebase Stripe Extension that might do most of the work for you.

WooCommerce pay for manually created orders without logging in

I have a situation where customers cannot check out for manually created orders without logging in. When checking out via the direct pay link, if they are not logged in they are still able to see the order total and check out via PayPal or card, however when checking out via PayPal they will be returned to an empty cart page and when checking out via card, they will be sent to the page before the 3D secure redirect and thus their order will not be processed.
We had taken payments before in this way, via manually created orders and sending the customer the payment link however I believe updating Wordpress/PHP caused this error. Can anyone help?
I think this snippet will surely help to allow customer to pay without login in.
Please have a look over here

woocommerce empty cart via api not working

I'm building an SPA using wordpress and woocommerce. Everything works fine (displaying products, handling payments, etc), except for emptying the user's cart after payment is complete. I wrote most endpoints custom.
In my payment handling endpoint, I wrote WC()->cart->empty_cart() after successful payments. This seems to work when I check WC()->cart->get_cart before and after emptying it (it's full before, empty after), however, when I subsequently open my cart modal (also using WC()->cart->get_cart(), but via a GET request), the items are still in there. If I complete the checkout via the woocommerce standard checkout pages instead of the SPA the cart empties just fine.
I know there are some other questions on this forum regarding this issue, but none of the solutions work for me. I tried WC()->cart->empty_cart(true) and setting 'cart' in the WC()->session to an empty array. I don't really know where else the cart is stored, or how WC()->cart accesses this information, but I'm guessing it has to do with the fact that I'm trying to empty via an asynchronous request?
As it turns out, this problem only occurred for logged in users. There is a persistent cart for logged in users, that is supposed to be cleared when true is passed into empty_cart (default). However, since this request is made via API, the wordpress function get_current_user_id that is used by empty_cart returns 0 because it doesn't have access to the correct user global on the server. This can be solved by adding a wordpress nonce in the headers of the ajax request to make the user available to the server. When this nonce is supplied, the aforementioned function to clear the cart works just fine. More info about nonces: https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/
PHP call too WC()->cart->empty_cart() won't magically call the frontend work which is needed to refresh the HTML.
to update the HTML you would have to do something like
jQuery(document.body).trigger('wc_fragment_refresh');
Feel free to check wp-content/plugins/woocommerce/assets/js/frontend/cart-fragments.js and see what it actually does.

WooCommerce sends order confirmation to customer every few minutes

My WooCommerce shop keeps sending order confirmation mails every (around) 10 minutes to a certain customer. And it does not stop.
I already changed the order status to "on hold", but it does not help. Is there a way to tell WooCommerce or the server to stop sending these emails?
I believe WordPress emails run on a Cron that shoots out emails to everything "flagged" within the table. I am not sure what it is off the top of my head, but you might be able to manually go into the MySQL table and just alter that data for his order.
This link may help, too:
https://docs.woocommerce.com/document/email-faq/
So,
I don't know if this helps anyone because it seems a rare case. But with our webshop it was zapier. We created a zap that hooks to the order confirmation mails. Deactivating this zap solved the problem.

Resources