/**
  * Bootstraps the class and hooks required actions & filters.
  *
  * @since 1.5
  */
 public static function init()
 {
     self::$setting_id = WC_Subscriptions_Admin::$option_prefix . '_sync_payments';
     self::$setting_id_proration = WC_Subscriptions_Admin::$option_prefix . '_prorate_synced_payments';
     self::$sync_field_label = __('Synchronise Renewals', 'woocommerce-subscriptions');
     self::$sync_description = __('Align the payment date for all customers who purchase this subscription to a specific day of the week or month.', 'woocommerce-subscriptions');
     // translators: placeholder is a year (e.g. "2016")
     self::$sync_description_year = sprintf(_x('Align the payment date for this subscription to a specific day of the year. If the date has already taken place this year, the first payment will be processed in %s. Set the day to 0 to disable payment syncing for this product.', 'used in subscription product edit screen', 'woocommerce-subscriptions'), date('Y', strtotime('+1 year')));
     // Add the settings to control whether syncing is enabled and how it will behave
     add_filter('woocommerce_subscription_settings', __CLASS__ . '::add_settings');
     // When enabled, add the sync selection fields to the Edit Product screen
     add_action('woocommerce_subscriptions_product_options_pricing', __CLASS__ . '::subscription_product_fields');
     add_action('woocommerce_variable_subscription_pricing', __CLASS__ . '::variable_subscription_product_fields', 10, 3);
     // Add the translated fields to the Subscriptions admin script
     add_filter('woocommerce_subscriptions_admin_script_parameters', __CLASS__ . '::admin_script_parameters', 10);
     // Save sync options when a subscription product is saved
     add_action('woocommerce_process_product_meta_subscription', __CLASS__ . '::save_subscription_meta', 10);
     // Save sync options when a variable subscription product is saved
     add_action('woocommerce_process_product_meta_variable-subscription', __CLASS__ . '::process_product_meta_variable_subscription');
     // WC < 2.4
     add_action('woocommerce_ajax_save_product_variations', __CLASS__ . '::process_product_meta_variable_subscription');
     // Make sure the expiration dates are calculated from the synced start date
     add_filter('woocommerce_subscriptions_product_trial_expiration_date', __CLASS__ . '::recalculate_product_trial_expiration_date', 10, 2);
     add_filter('woocommerce_subscriptions_product_expiration_date', __CLASS__ . '::recalculate_product_expiration_date', 10, 3);
     // Display a product's first payment date on the product's page to make sure it's obvious to the customer when payments will start
     add_action('woocommerce_single_product_summary', __CLASS__ . '::products_first_payment_date', 31);
     // Display a product's first payment date on the product's page to make sure it's obvious to the customer when payments will start
     add_action('woocommerce_subscriptions_product_first_renewal_payment_time', __CLASS__ . '::products_first_renewal_payment_time', 10, 4);
     // Maybe mock a free trial on the product for calculating totals and displaying correct shipping costs
     add_filter('woocommerce_before_calculate_totals', __CLASS__ . '::maybe_set_free_trial', 0, 1);
     add_action('woocommerce_subscription_cart_before_grouping', __CLASS__ . '::maybe_unset_free_trial');
     add_action('woocommerce_subscription_cart_after_grouping', __CLASS__ . '::maybe_set_free_trial');
     add_action('wcs_recurring_cart_start_date', __CLASS__ . '::maybe_unset_free_trial', 0, 1);
     add_action('wcs_recurring_cart_end_date', __CLASS__ . '::maybe_set_free_trial', 100, 1);
     add_filter('woocommerce_subscriptions_calculated_total', __CLASS__ . '::maybe_unset_free_trial', 10000, 1);
     add_action('woocommerce_cart_totals_before_shipping', __CLASS__ . '::maybe_set_free_trial');
     add_action('woocommerce_cart_totals_after_shipping', __CLASS__ . '::maybe_unset_free_trial');
     add_action('woocommerce_review_order_before_shipping', __CLASS__ . '::maybe_set_free_trial');
     add_action('woocommerce_review_order_after_shipping', __CLASS__ . '::maybe_unset_free_trial');
     // Set prorated initial amount when calculating initial total
     add_filter('woocommerce_subscriptions_cart_get_price', __CLASS__ . '::set_prorated_price_for_calculation', 10, 2);
     // When creating a subscription check if it contains a synced product and make sure the correct meta is set on the subscription
     add_action('save_post', __CLASS__ . '::maybe_add_subscription_meta', 10, 1);
     // When adding an item to a subscription, check if it is for a synced product to make sure the sync meta is set on the subscription. We can't attach to just the 'woocommerce_new_order_item' here because the '_product_id' and '_variation_id' meta are not set before it fires
     add_action('woocommerce_ajax_add_order_item_meta', __CLASS__ . '::ajax_maybe_add_meta_for_item', 10, 2);
     add_action('woocommerce_order_add_product', __CLASS__ . '::maybe_add_meta_for_new_product', 10, 3);
     // Make sure the sign-up fee for a synchronised subscription is correct
     add_filter('woocommerce_subscriptions_sign_up_fee', __CLASS__ . '::get_synced_sign_up_fee', 1, 3);
     // Autocomplete subscription orders when they only contain a synchronised subscription
     add_filter('woocommerce_payment_complete_order_status', __CLASS__ . '::order_autocomplete', 10, 2);
     // If it's an initial sync order and the total is zero, and nothing needs to be shipped, do not reduce stock
     add_filter('woocommerce_order_item_quantity', __CLASS__ . '::maybe_do_not_reduce_stock', 10, 3);
     add_filter('woocommerce_subscriptions_recurring_cart_key', __CLASS__ . '::add_to_recurring_cart_key', 10, 2);
 }
 /**
  * Bootstraps the class and hooks required actions & filters.
  *
  * @since 1.5
  */
 public static function init()
 {
     self::$setting_id = WC_Subscriptions_Admin::$option_prefix . '_sync_payments';
     self::$setting_id_proration = WC_Subscriptions_Admin::$option_prefix . '_prorate_synced_payments';
     self::$sync_field_label = __('Synchronise Renewals', 'woocommerce-subscriptions');
     self::$sync_description = __('Align the payment date for all customers who purchase this subscription to a specific day of the week or month.', 'woocommerce-subscriptions');
     self::$sync_description_year = sprintf(__('Align the payment date for this subscription to a specific day of the year. If the date has already taken place this year, the first payment will be processed in %s. Set the day to 0 to disable payment syncing for this product.', 'woocommerce-subscriptions'), date('Y', strtotime('+1 year')));
     // Add the settings to control whether syncing is enabled and how it will behave
     add_filter('woocommerce_subscription_settings', __CLASS__ . '::add_settings');
     // When enabled, add the sync selection fields to the Edit Product screen
     add_action('woocommerce_subscriptions_product_options_pricing', __CLASS__ . '::subscription_product_fields');
     add_action('woocommerce_variable_subscription_pricing', __CLASS__ . '::variable_subscription_product_fields', 10, 3);
     // Add the translated fields to the Subscriptions admin script
     add_filter('woocommerce_subscriptions_admin_script_parameters', __CLASS__ . '::admin_script_parameters', 10);
     // Save sync options when a subscription product is saved
     add_action('woocommerce_process_product_meta_subscription', __CLASS__ . '::save_subscription_meta', 10);
     // Save sync options when a variable subscription product is saved
     add_action('woocommerce_process_product_meta_variable-subscription', __CLASS__ . '::process_product_meta_variable_subscription');
     // WC < 2.4
     add_action('woocommerce_ajax_save_product_variations', __CLASS__ . '::process_product_meta_variable_subscription');
     // Make sure the expiration date is calculated from the synced start date
     add_filter('woocommerce_subscriptions_product_expiration_date', __CLASS__ . '::recalculate_product_expiration_date', 10, 3);
     // Display a product's first payment date on the product's page to make sure it's obvious to the customer when payments will start
     add_action('woocommerce_single_product_summary', __CLASS__ . '::products_first_payment_date', 31);
     // Display the "First Payment:" date on cart/checkout
     add_filter('woocommerce_cart_total_ex_tax', __CLASS__ . '::customise_subscription_price_string', 12);
     add_filter('woocommerce_cart_total', __CLASS__ . '::customise_subscription_price_string', 12);
     // Maybe mock a free trial on the product for calculating order totals
     add_filter('woocommerce_calculated_total', __CLASS__ . '::maybe_set_free_trial', 0, 1);
     add_filter('woocommerce_calculated_total', __CLASS__ . '::maybe_unset_free_trial', 10000, 1);
     // But don't display the free trial in cart subscription price strings unless the product actually has free trial
     add_filter('woocommerce_cart_subscription_string_details', __CLASS__ . '::maybe_hide_free_trial', 11, 4);
     // Set prorated initial amount when calculating combined_total or initial total
     add_filter('woocommerce_subscriptions_cart_get_price', __CLASS__ . '::set_prorated_price_for_calculation', 10, 2);
     // When creating an order, add meta if it's for syncing a subscription
     add_action('woocommerce_checkout_update_order_meta', __CLASS__ . '::add_order_meta', 10, 2);
     // Make sure the first payment date for a new subscription is correct
     add_filter('woocommerce_subscriptions_calculated_next_payment_date', __CLASS__ . '::maybe_set_payment_date', 15, 4);
     // Make sure the sign-up fee for a synchronised subscription is correct
     add_filter('woocommerce_subscriptions_sign_up_fee', __CLASS__ . '::get_sign_up_fee', 1, 4);
     // Make sure shipping isn't displayed with an up-front charge
     add_filter('woocommerce_subscriptions_cart_shipping_up_front', __CLASS__ . '::charge_shipping_up_front', 10, 4);
     // When manually adding a synchronised subscription product to an order, make sure it is synchronised and line totals are correct
     add_action('woocommerce_ajax_order_item', __CLASS__ . '::prefill_order_item_meta', 11, 2);
     // Autocomplete subscription orders when they only contain a synchronised subscription
     add_action('woocommerce_payment_complete_order_status', __CLASS__ . '::order_autocomplete', 10, 2);
 }