mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
https://stackoverflow.com/questions/77077625/cod-payment-with-woocommerce-subscriptions-renewals-customize-order-status
14 lines
598 B
Text
14 lines
598 B
Text
add_filter( 'wcs_new_order_created', 'customize_renewal_cod_order_status', 10, 3 );
|
|
function customize_renewal_cod_order_status( $order, $subscription, $type ) {
|
|
$parent_order = $subscription->get_related_orders('all', 'parent');
|
|
$parent_order = reset($parent_order);
|
|
|
|
if ( $type === 'renewal_order' && $parent_order->get_payment_method() === 'cod' && $order->has_status('on-hold') ) {
|
|
$order->set_status('wc-processing');
|
|
$order->save();
|
|
|
|
$subscription->set_status('wc-active'); // Optional
|
|
$subscription->save(); // Optional
|
|
}
|
|
return $order;
|
|
}
|