Changing the default frequency options

The default frequency options displayed for Autoship products are below:

  • 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. Otherwise, the default frequency options can be changed by implementing the filter 'autoship-default-frequency-options'. 

How to add the code snippet to your Wordpress Site

You'll want to add the code snippet to your WooCommerce child theme's functions.php file using FTP or SFTP.
If you are unfamiliar with this, please contact us and we'll be happy to assist you!

Example: Change the default frequency options

Example 1: Change default frequency options to "Every 30 Days" and "Every 60 Days" and "Every 90 Days"

<?php
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"

<?php
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 options to "A Week" and "A Fortnight"

<?php
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' );

Still need help? Contact Us Contact Us