Hey @christian1983
the hook “wc_amazon_async_polling” is being used for checking the status of Amazon charges and charge permissions async.
But why is it that the hook with the same args ([“BXX-XXXXXXX-XXXXXXX”,”CHARGE_PERMISSION”])/ for the same order needs to run almost 10 times a day for every day?
public function schedule_hook( $id, $type ) {
$args = array( $id, $type );
// Schedule action to check pending order next hour.
if ( false === $this->is_next_scheduled( 'wc_amazon_async_polling', $args, 'wc_amazon_async_polling' ) ) {
wc_apa()->log( sprintf( 'Scheduling check for %s %s', $type, $id ) );
as_schedule_single_action( strtotime( '+10 minutes' ), 'wc_amazon_async_polling', $args, 'wc_amazon_async_polling' );
}
}
According to “wp-content/plugins/woocommerce-gateway-amazon-payments-advanced/includes/class-wc-amazon-payments-advanced-ipn-handler.php:542” it seems to me as after an event “wc_amazon_async_polling” has run, the next one is beenig scheduled in 10 Minutes?
Why does this plugin need to run a polling functionality in the first place? e.g. the Stripe and Paypal plugins don’t need that and are running code only when it’s necessary e.g. while loading the order edit page in backend or while processing scheduled payments.
The removal of the completed actions in the database should be handled by Action Scheduler itself after 30 days of their completion. Do you have completed actions older than that? In the article, there is also an example to use a filter and change the 30 days settings period.
Yes there are older completed entries for this hook. For whatever reason the automated cleanup seems to work for hooks like ‘wc-admin_import_orders’ or ‘woocommerce_scheduled_subscription_payment’ but not for the ‘wc_amazon_async_polling’ hook.
I have lowered the cleanup schedule already to 7 days.
So I guess I can also delete the ‘complete’ and ‘failed’ together with the matching log entries manually, right?
Thanks
Regards