Site logo

[Resolved] Can I change the default opened tab depending on the link/?

Home Forums Support [Resolved] Can I change the default opened tab depending on the link/?

Home Forums Support Can I change the default opened tab depending on the link/?

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #2545128
    Jusung

    When it is a certain link, can I change the opened tab link?

    by default, I open the first tap, but when It is from other link, I want to open the second tab.

    #2545235
    David
    Staff
    Customer Support

    Hi there,

    if you select the Tab Item, and in Advanced add a unique HTML Anchor. For example tab-2

    Then when you can use that Jump Link, eg. https://mywebsite.com/page-slug/#tab-2 and that link will jump to and open that tab.

    #2545291
    Jusung

    Hello.

    I can’t understand.
    I tried to add it as you said, but nothing happened.

    When the link is from those, I want to open third tap.

    Then what can I add?
    Is it possible to add 2 html anchor?
    I tried to add billing, but nothing happened.

    maybe I can use “edit-address” this one??

    #2545366
    David
    Staff
    Customer Support

    Those URLs are for an account page, i would need a login for them

    #2545409
    Jusung

    I added the ID and PW.

    On third tap, when I click edit, the link includes “edit-address” this one.

    #2545464
    David
    Staff
    Customer Support

    See here:

    2023-02-24_13-35-18

    In the Tab Item -> Advanced –> HTML Anchor i add my anchor: my-anchor

    Now i got to: https://mysite.com/page-name/#my-anchor

    And that URL will take me to and open that Tab.

    You will need to just the Jumplink methods instead of the standard Woocomerce URLs as you have relaced their tabs with your own

    #2545723
    Jusung

    I understand now.

    So, I added the html anchor like test111
    and after that, I have to add #test111 at the end of the link.

    For woocommerce, I need to change the end point using php code..
    Is this right?

    #2546125
    Jusung
    // Change the edit billing address link
    add_filter( 'woocommerce_billing_fields', 'my_custom_billing_fields' );
    function my_custom_billing_fields( $fields ) {
        $fields['billing_address_1']['custom_link'] = wc_get_account_endpoint_url( 'edit-address', 'billing' ) . 'https://abc/my-account/edit-address/billing/#address-tab';
        return $fields;
    }
    
    // Change the edit shipping address link
    add_filter( 'woocommerce_shipping_fields', 'my_custom_shipping_fields' );
    function my_custom_shipping_fields( $fields ) {
        $fields['shipping_address_1']['custom_link'] = wc_get_account_endpoint_url( 'edit-address', 'shipping' ) . 'https://abc/my-account/edit-address/shipping/#address-tab';
        return $fields;
    }
    
    // Replace the link in the billing address template
    add_filter( 'woocommerce_my_account_edit_address_url', 'my_custom_edit_billing_address_link', 10, 3 );
    function my_custom_edit_billing_address_link( $url, $type, $id ) {
        if ( $type == 'billing' ) {
            $url = wc_get_account_endpoint_url( 'edit-address', 'billing' ) . 'https://abc.com/my-account/edit-address/billing/#address-tab';
        }
        return $url;
    }
    
    // Replace the link in the shipping address template
    add_filter( 'woocommerce_my_account_my_address_formatted_address', 'my_custom_shipping_address_link', 10, 3 );
    function my_custom_shipping_address_link( $address, $customer_id, $address_id ) {
        $address['edit']['url'] = wc_get_account_endpoint_url( 'edit-address', 'shipping' ) . 'https://abc.com/my-account/edit-address/shipping/#address-tab';
        return $address;
    }
    

    These are the link I used, but doen’s make any change.

    #2546448
    David
    Staff
    Customer Support

    Try URL:

    https://abc.com/my-account/edit-address/#address-tab

    As all endpoints are simply a query var.
    But you’re hacking the way Woocommerce works, so i cannot really advise on this, as you could make bigger problems doing this, and we cannot support Woocommrce custom development

    #2546533
    Jusung

    Thank you for help !!

    #2547243
    David
    Staff
    Customer Support

    You’re welcome

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.