vendredi 6 mai 2016

How to set Next Payment date in Woocommerce Subscriptions?

I would like to change the next payment date of active subscriptions after the Initial (first) order was created.

current code which does not work. Why? What am i missing?

//fires when new order payment is complete (NOT RENEWAL but original order!)
add_action('woocommerce_payment_complete', 'fm_upate_next_payment_datetime');

function fm_upate_next_payment_datetime ( $order_id ) {
    global $wpo_wcpdf;

if (WC_Subscriptions_Order::order_contains_subscription( $order_id ) == false) return;      
$subscription_key = WC_Subscriptions_Manager::get_subscription_key( $order_id, $product_id
= '');

 //hard code next payment date...(must be in future)
$next_payment = date( 'Y-m-d H:i:s', '2016-05-20 00:10:10' );

//set the new payment date  
WC_Subscriptions_Manager::set_next_payment_date( $subscription_key, $user_id = '', $next_payment );

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire