According to the WooCommerce Git Repo Subscription Manager , this is the function that he is trying to run:
public static function prepare_renewal( $subscription_id ) { $order_note = _x( 'Subscription renewal payment due:', 'used in order note as reason for why subscription status changed', 'woocommerce-subscriptions' ); $renewal_order = self::process_renewal( $subscription_id, 'active', $order_note );
You can see from this that it should get one parameter, which is an integer and must match the shop_subscription identifier.
So, here are a few things you are going to do to get this right. I proceed from the assumption that you do not want to dig too much in command line debugging, so as not to accidentally run cron jobs that can potentially change the situation in an unexpected way (this is usually a good idea when it can be avoided, especially when it involves other peoples money )
- First, make sure your error log is enabled using
define( 'WP_DEBUG_LOG', true ); - Secondly, you need to write the value of
$subscription_id as it exists when it is passed to the job.
Something like this in hook woocommerce_scheduled_subscription_payment :
error_log(sprintf('Parameter [%s] with type [%s] is the [$subscription_id], as passed to the job: [%s]', (string) $subscription_id, gettype( $subscription_id), 'WC_Subscriptions_Manager::prepare_renewal' ) );
This should pick up the identifier that is being transmitted and put it in its error log. Then wait until the task starts again or starts manually.
After completing the assignment, you need to check the following things:
- A message appeared in your journal (duh)
- The value of
$subscription_id is an integer and is not null or false. - The value of
$subscription_id corresponds to a valid shop_subscription message in your database.
This is probably in your posts table, but Woo is known to sometimes do some things in the database, so if you can't find it in posts , use the following query to find this:
SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'shop_subscription' AND TABLE_SCHEMA='YourDatabase';
You may need to play around with the header above to get the correct field, but between PhpMyAdmin or another MySql visualization tool and the INFORMATION_SCHEMA.COLUMNS query, you wonβt have to find it for so long.
If you confirm that you have confirmed that you are passing a valid identifier, so if it is still broken, your next step is to return Woo from the actual function and find out why it does not provide a value.
This delves a bit into the internal functions of Wordpress, so make sure you back up your site before using the Git or tar file or something else so that you donβt leave any hacks in the kernel or plugin. If it is still broken, start the backup at this point before proceeding.
The following, if you have not yet found the actual problem, is to enter the WC_Subscriptions_Manager::prepare_renewal and register two things from there (see the reposition link at the top of this answer to help jump). You want to register print_r( debug_backtrace(), 1) in order to register a complete back trace from Woo back (it will be big, don't leave it there when you finish if you don't like massive log files that clutter up your entire disk space).
You will also want to register the value of $subscription_id directly inside this method to ensure that it is the same value that it passed.
From the views of your mistake, it seems that it is not transmitted at all. This most likely indicates that you received a null result from the database or hook, and your problem should be resolved in the first part of this diagnosis. The second part is redundancy to ensure that you really fixed the problem.
- The task must be performed for each step that changes the code. Wait for the next run, run it manually, or run dryrun if possible to help with debugging.
If the previous developer hacked the Woo plugin, you can use Git to completely hide all its changes by following these steps:
cd /path/to/plugin git init git add --all git remote add origin git@github.com :wp-premium/woocommerce-subscriptions.git git commit git pull
then git diff one of the stable release commits from the github page. Any changes will be displayed in diff
This should cover quick debugging of the job, as well as highlighting any other problems with balances that you may have left with the previous developer, which you may not even know about yet.