Native UI: Customize Displayed Frequency Options
Customizes the Frequency Options displayed by the Native UI to customers when editing a Scheduled Order within My Account > Scheduled Orders
Important: Always test customizations to your site on a staging environment before making changes to your live / production site. If you are not experienced with testing changes on a staging site, here is a good article to review.
/**
* Adjust the Frequency Values available in the Native UI.
*
* @param array $default_frequency_options The current default options
* @param array $autoship_order The current autoship order.
* @return array The filtered Autoship Frequency Option
*/
function xx_adjusted_ui_frequency_options ( $default_frequency_options, $autoship_order ){
$numWord = array('one','two','three','four','five');
$new_frequency_options= array();
for ( $i = 1; $i < 6; $i++ ) {
$new_frequency_options[$i] = array(
'frequency_type' => 'Weeks',
'frequency' => $i,
'display_name' => 1== $i ? sprintf( __('Every week (Every %d days)') , $i * 7 ) : sprintf( __('Every %s weeks (Every %d days)') , $numWord[ $i - 1 ], $i * 7 ) ,
);
}
return $new_frequency_options;
}
add_filter( 'autoship_get_all_valid_order_change_frequencies', 'xx_adjusted_ui_frequency_options', 10, 2 );