availability:

WooCommerce Multilingual Version: 3.8

description:

Add new WooCommerce endpoints to be ready for translation with WooCommerce Multilingual.

type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wcml_register_endpoints_query_vars', 'the_callback_function', 10, 3 );

There are three parameters passed to this filter:

$query_vars
(array) The WordPress query var (endpoint) array.
$wc_vars
(array) The WooCommerce default endpoint array.
$obj
(object) The WCML_Endpoints object.

 

hook example usage:

Example

/*
 * Add this code to the functions.php file of your theme.
 * This is extracted from the WCML WC Subscriptions compatibility class. 
 */
 
add_filter('wcml_register_endpoints_query_vars', 'register_endpoint', 10, 3 );

function register_endpoint( $query_vars, $wc_vars, $obj ){

    // Add the translation for the custom "view-subscription" endpoint.
    $query_vars[ 'view-subscription' ] = $obj->get_endpoint_translation( 'view-subscription',  isset( $wc_vars['view-subscription'] ) ? $wc_vars['view-subscription'] : 'view-subscription' );

    return $query_vars;
}