Translate and customize Autoship text

Customizing Autoship Text

You can use Wordpress to customize the Autoship text to better fit your brand and site experience using filters.  For example, you may want to change the text "Autoship" - that appears on the Product page and Cart page - to "Subscribe".

In the following code snippet example, we use a filter within the Autoship Cloud plugin to change the term "Autoship" to "Subscribe" and when there is a price savings, use the term "Subscribe and Save".  This logic is added to the active Wordpress theme's functions.php to apply the change.

/**
* Change Product Page and Cart Autoship labels
*
* @param string $label The current option label.
* @param string $option_type if this is the autoship radio or 'no' if this is the one time purchase
* @param bool $savings if there is a savings associated with autoship else false.
* @param WC_Product $product The current product object.
*
* @return string the filtered label
*/
function xx_rename_autoship( $label, $option_type, $savings, $product ){

  if ( 'yes' == $option_type ){

    return $savings ? __('Subscribe and Save') : __('Subscribe');

  } else {

    return __('Purchase Only Once');

  }

}
add_filter('autoship_radio_label', 'xx_rename_autoship', 10, 4 );

Translating Autoship Text

All of the text in the Autoship Cloud plugin is passed through the Wordpress translation filter with the text domain 'autoship'.

The easiest way to translate the text added your site by Autoship is to use the Loco Translate plugin to customize the text displayed on the site.

1. Install the Loco Translate plugin

  1. Navigate to the Plugins page in the Wordpress Admin section of your site.
  2. Click the button to "Add New" plugin.
  3. Search for the 'Loco Translate' plugin in the Wordpress plugin repository.
  4. Install Loco Translate.
  5. Activate Loco Translate.

2. Add a new translation

  1. Navigate to Loco Translate > Plugins in the Wordpress Admin section of your site.
  2. Select the Autoship Cloud plugin from the list.
  3. Select the current language of the site and click the button to "Start translating".

  4. Use the Loco Translate editor to change the desired text to your liking.

  5. Save your changes in the Loco Translate editor.

Still need help? Contact Us Contact Us