/** * Processes an AJAX request to check if a product has a variation which is either sync'd or has a trial. * Once at least one variation with a trial or sync date is found, this will terminate and return true, otherwise false. * * @since 2.0.18 */ public static function check_product_variations_for_syncd_or_trial() { check_admin_referer('one_time_shipping', 'nonce'); $product = wc_get_product($_POST['product_id']); $is_synced_or_has_trial = false; if (WC_Subscriptions_Product::is_subscription($product)) { foreach ($product->get_children() as $variation_id) { if (isset($_POST['variations_checked']) && in_array($variation_id, $_POST['variations_checked'])) { continue; } $variable_product = wc_get_product($variation_id); if ($variable_product->subscription_trial_length > 0) { $is_synced_or_has_trial = true; break; } if (WC_Subscriptions_Synchroniser::is_syncing_enabled() && (!is_array($variable_product->subscription_payment_sync_date) && $variable_product->subscription_payment_sync_date > 0 || is_array($variable_product->subscription_payment_sync_date) && $variable_product->subscription_payment_sync_date['day'] > 0)) { $is_synced_or_has_trial = true; break; } } } wp_send_json(array('is_synced_or_has_trial' => $is_synced_or_has_trial)); }