[WooCommerce] How do I Change the Default Autoship Frequency Options?
The default frequency options displayed for all Autoship products are:
- Every 1 Months
- Every 2 Months
- Every 3 Months
- Every 4 Months
- Every 5 Months
These frequency options can be customized per product and product variation at the individual product level or site-wide.
Changing the Default Frequency for an Individual Product
You can learn more about setting individual product frequencies here: Autoship Product Settings. Autoship Frequency Options include the following frequency types:
- Days
- Example: Every 30 Days
- Weeks
- Example: Every 3 Weeks
- Months
- Example: Every 3 Months
- DayOfTheWeek
- Example: Every Wednesday (frequency = 4 since Sunday = 1)
- DayOfTheMonth
- Example: Every 1st of the Month
Individual product frequencies can be changed on the WP-Admin > Products > Edit Product page. These options are found under the "Override Defaults" checkbox on the Autoship Tab (Simple & Variable products) or Variations tab (Variable products: individual variation) under "Frequency Options".
You can also learn more here: WP-Admin: Default Product Frequency Override Option
How To Change Your Frequencies Site-Wide
To change your frequency settings for all Autoship products (site-wide), please see the examples outlined below. These code snippets can be added to your WooCommerce child theme's functions.php file using FTP or SFTP. Please note that all changes to your site should be tested in a staging environment before being applied to a live site.
The default frequency options can be changed by implementing the filter 'autoship-default-frequency-options'.
Examples
Example 1: Change default frequency options to "Every 30 Days" and "Every 60 Days" and "Every 90 Days"
function autoship_new_default_frequency_options( $options ) { // Return a new set of default frequency options of 30, 60, 90 Days return array( array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Days', // Frequency (integer) 'frequency' => 30, 'display_name' => 'Every 30 Days' ), array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Days', // Frequency (integer) 'frequency' => 60, 'display_name' => 'Every 60 Days' ), array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Days', // Frequency (integer) 'frequency' => 90, 'display_name' => 'Every 90 Days' ) ); } add_filter( 'autoship-default-frequency-options', 'autoship_new_default_frequency_options' );
Example 2: Change the default frequency options to "Every 1 Week", "Every 2 Weeks", "Every 3 Weeks", "Every 4 Weeks"
function autoship_new_default_frequency_options( $options ) { // Return a new set of default frequency options of 1 through 4 Weeks return array( array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Weeks', // Frequency (integer) 'frequency' => 1, 'display_name' => 'Every Week' ), array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Weeks', // Frequency (integer) 'frequency' => 2, 'display_name' => 'Every 2 Weeks' ), array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Weeks', // Frequency (integer) 'frequency' => 3, 'display_name' => 'Every 3 Weeks' ), array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Weeks', // Frequency (integer) 'frequency' => 4, 'display_name' => 'Every 4 Weeks' ) ); } add_filter( 'autoship-default-frequency-options', 'autoship_new_default_frequency_options' );
Example 3: Change the default frequency to to "Every 2 Weeks", "Every 1 Month", and "Every 2 Months"
function autoship_new_default_frequency_options( $options ) { // Return a new set of default frequency options return array( array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Weeks', // Frequency (integer) 'frequency' => 2, 'display_name' => 'Every 2 Weeks' ), array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Months', // Frequency (integer) 'frequency' => 1, 'display_name' => 'Every 1 Month' ), array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Months', // Frequency (integer) 'frequency' => 2, 'display_name' => 'Every 2 Months' ) ); } add_filter( 'autoship-default-frequency-options', 'autoship_new_default_frequency_options' );
Example 4: Change the default frequency options to "A Week" and "A Fortnight"
function autoship_example_default_frequency_options( $options ) { // Return a new set of default frequency options return array( array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Weeks', // Frequency (integer) 'frequency' => 1, 'display_name' => 'A Week' ), array( // Days, Weeks, Months, DayOfTheWeek, DayOfTheMonth 'frequency_type' => 'Weeks', // Frequency (integer) 'frequency' => 2, 'display_name' => 'A Fortnight' ) ); } add_filter( 'autoship-default-frequency-options', 'autoship_example_default_frequency_options' );