Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hello there,
    hope you are doing well! ??

    You can change the gift cards endpoint to “gutscheine” adding the next code in the functions.php of your active theme:

    if ( function_exists( 'YITH_YWGC' ) ) {
    
    	if (!function_exists('yith_ywgc_change_endpoint_slug')) {
    
    		function yith_ywgc_change_endpoint_slug(){
    
    			$class = YITH_YWGC_Frontend::get_instance();
    
    			remove_action('init', array($class, 'yith_ywgc_add_endpoint'));
    			remove_action('query_vars', array($class, 'yith_ywgc_gift_cards_query_vars'));
    			remove_action('woocommerce_account_menu_items', array($class, 'yith_ywgc_add_gift_cards_link_my_account'));
    			remove_action('woocommerce_account_gift-cards_endpoint', array($class, 'yith_ywgc_gift_cards_content'));
    
    		}
    
    		add_action('init', 'yith_ywgc_change_endpoint_slug');
    	}
    
    	add_action('init', 'yith_ywgc_add_endpoint_custom');
    	add_action('query_vars', 'yith_ywgc_gift_cards_query_vars_custom');
    	add_action('woocommerce_account_menu_items', 'yith_ywgc_add_gift_cards_link_my_account_custom');
    	add_action('woocommerce_account_bon-cadeau_endpoint', 'yith_ywgc_gift_cards_content_custom');
    
    	function yith_ywgc_add_endpoint_custom(){
    		add_rewrite_endpoint('gutscheine', EP_ROOT | EP_PAGES);
    	}
    
    	function yith_ywgc_gift_cards_query_vars_custom($vars){
    		$vars[] = 'gutscheine';
    
    		return $vars;
    	}
    
    	function yith_ywgc_add_gift_cards_link_my_account_custom($items){
    
    		$item_position = (array_search('orders', array_keys($items)));
    
    		$items_part1 = array_slice($items, 0, $item_position + 1);
    		$items_part2 = array_slice($items, $item_position);
    
    		$items_part1['gutscheine'] = apply_filters('yith_wcgc_my_account_menu_item_title', __('Gift Cards', 'yith-woocommerce-gift-cards'));
    
    		$items = array_merge($items_part1, $items_part2);
    
    		return $items;
    	}
    
    	function yith_ywgc_gift_cards_content_custom(){
    		wc_get_template('myaccount/my-giftcards.php',
    			'',
    			'',
    			trailingslashit(YITH_YWGC_TEMPLATES_DIR));
    	}
    }

    Could you check it and let us know any news, please?

    Have a nice day!

    Thread Starter deathbydisco

    (@deathbydisco)

    Hi,

    i have added the code to my functions file but now i have 2 gift card taps under my account page.

    One points to the new endpoint but doesnt display any gift cards and the second one points to the old endpoint and dispalys all gift cards.

    Have you tested the code ?

    Plugin Author YITHEMES

    (@yithemes)

    Hello there,

    hope you are doing well!

    Please, try this new code by replacing the previous one we sent you in the functions.php file of your active theme:

    if ( function_exists( 'YITH_YWGC' ) ) {
    	if ( ! function_exists( 'yith_ywgc_change_endpoint_slug' ) ) {
    		function yith_ywgc_change_endpoint_slug() {
    			$class = YITH_YWGC_Frontend::get_instance();
    
    			remove_action( 'init', array( $class, 'yith_ywgc_add_endpoint' ) );
    			remove_action( 'query_vars', array( $class, 'yith_ywgc_gift_cards_query_vars' ) );
    			remove_action( 'woocommerce_account_menu_items', array( $class, 'yith_ywgc_add_gift_cards_link_my_account' ) );
    			remove_action( 'woocommerce_account_gift-cards_endpoint', array( $class, 'yith_ywgc_gift_cards_content' ) );
    
    		}
    
    		add_action( 'init', 'yith_ywgc_change_endpoint_slug' );
    	}
    
    	add_action( 'init', 'yith_ywgc_add_endpoint_custom' );
    	add_action( 'query_vars', 'yith_ywgc_gift_cards_query_vars_custom' );
    	add_action( 'woocommerce_account_menu_items', 'yith_ywgc_add_gift_cards_link_my_account_custom' );
    	add_action( 'woocommerce_account_gutscheine_endpoint', 'yith_ywgc_gift_cards_content_custom' );
    
    	function yith_ywgc_add_endpoint_custom() {
    		add_rewrite_endpoint( 'gutscheine', EP_ROOT | EP_PAGES );
    	}
    
    	function yith_ywgc_gift_cards_query_vars_custom( $vars ) {
    		$vars[] = 'gutscheine';
    
    		return $vars;
    	}
    
    	function yith_ywgc_add_gift_cards_link_my_account_custom( $items ) {
    		$item_position = ( array_search( 'orders', array_keys( $items ) ) );
    		$items_part1 = array_slice( $items, 0, $item_position + 1 );
    		$items_part2 = array_slice( $items, $item_position );
    		$items_part1['gutscheine'] = apply_filters( 'yith_wcgc_my_account_menu_item_title', __( 'Gift Cards', 'yith-woocommerce-gift-cards' ) );
    		$items = array_merge( $items_part1, $items_part2 );
    
    		return $items;
    	}
    
    	function yith_ywgc_gift_cards_content_custom() {
    		wc_get_template( 'myaccount/my-giftcards.php',
    			'',
    			'',
    			trailingslashit(YITH_YWGC_TEMPLATES_DIR ) );
    	}
    }

    Let us know any news, please.

    Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to change the endpoint ?’ is closed to new replies.