// Add custom field to subscription edit screen add_action('sumosubscriptions_after_subscription_details', 'custom_subscription_plan_selector'); function custom_subscription_plan_selector($subscription_id) { $current_plan = get_post_meta($subscription_id, 'sumo_get_product_id', true); $available_plans = wc_get_products(array( 'type' => array('subscription', 'variable-subscription'), 'limit' => -1 )); echo '
'; echo '

' . __('Change Subscription Plan', 'sumosubscriptions') . '

'; echo ''; echo '

' . __('Select new plan and update subscription to apply changes', 'sumosubscriptions') . '

'; echo '
'; } // Process plan changes when subscription is updated add_action('save_post_sumosubscriptions', 'handle_manual_plan_change', 20, 3); function handle_manual_plan_change($post_id, $post, $update) { if (!isset($_POST['sumo_new_plan']) || empty($_POST['sumo_new_plan'])) return; $new_plan_id = absint($_POST['sumo_new_plan']); $current_plan_id = get_post_meta($post_id, 'sumo_get_product_id', true); // Exit if no change if ($new_plan_id == $current_plan_id) return; // Get subscription and new product $subscription = sumo_get_subscription($post_id); $new_product = wc_get_product($new_plan_id); if (!$new_product) return; // Update subscription details update_post_meta($post_id, 'sumo_get_product_id', $new_plan_id); update_post_meta($post_id, 'sumo_get_recurring_amount', $new_product->get_price()); // Maintain sync date $sync_day = get_option('sumo_sync_day', 1); $next_payment = sumo_calculate_next_payment_date($sync_day); update_post_meta($post_id, 'sumo_get_next_payment_date', $next_payment); // Add admin note $note = sprintf( __('Plan manually changed from %s to %s by admin. Next payment synchronized to %s.', 'sumosubscriptions'), get_the_title($current_plan_id), get_the_title($new_plan_id), date_i18n(get_option('date_format'), strtotime($next_payment)) ); sumo_add_subscription_note($note, $post_id); } // Calculate next payment date based on sync settings function sumo_calculate_next_payment_date($sync_day) { $current_day = date('j'); $current_month = date('n'); $current_year = date('Y'); if ($current_day < $sync_day) { // Use this month's sync day return date('Y-m-d', strtotime("{$current_year}-{$current_month}-{$sync_day}")); } else { // Use next month's sync day $next_month = date('Y-m-d', strtotime('+1 month')); return date('Y-m-d', strtotime(date('Y-m', strtotime($next_month)) . "-{$sync_day}")); } } Clearance - UK Wax Melts from Classic Candle
FREE DELIVERY when you spend £30

Clearance

Join our monthly wax melt subscription club

Starting from only £8.00