Okay
  Public Ticket #3484740
WooCommerce My Account Item in Menu
Closed

Comments

  •  15
    hahni started the conversation

    The with kalium delivered option for the menus looks nice and the possibility to have automatic text on login or not logged in state is perfect.

    But one addition by me: The "menu mini widget" is not for multi language sites. 

    in header-functions.php on line 591 and following there is the code not ready for translations based on custom input. It would be nice to have the same "mini-widget" with WPML compatibility.

    // WooCommerce My Account Link
    case 'woocommerce-account-link':
        $option_login_text     = kalium_get_array_key( $options, 'login_text' );
        $option_logged_in_text = kalium_get_array_key( $options, 'logged_in_text' );
        $option_link_icon      = kalium_get_array_key( $options, 'link_icon' );
        if ( kalium()->is->woocommerce_active() ) {
            $content        = $option_login_text;
            $widget_classes = [
                'woocommerce-account-link',
                $option_skin,
            ];
            // Logged in user
            if ( is_user_logged_in() ) {
                $content = $option_logged_in_text;
            }
            // With icon
            if ( kalium_validate_boolean( $option_link_icon ) ) {
                $icon_svg = kalium_get_svg_file( 'assets/images/icons/single-neutral-circle.svg' );
                if ( trim( $content ) ) {
                    $content = sprintf( '<i class="woocommerce-account-link__icon">%1$s</i> <span class="woocommerce-account-link__label">%2$s</span>', $icon_svg, $content );
                } else {
                    $content = sprintf( '<i class="woocommerce-account-link__icon">%1$s</i>', $icon_svg );
                }
                $widget_classes[] = 'woocommerce-my-account-link--has-icon';
            }
            // Display my account link
            kalium()->helpers->build_dom_element( [
                'tag_name'   => 'a',
                'attributes' => [
                    'href'       => wc_get_page_permalink( 'myaccount' ),
                    'class'      => $widget_classes,
                    'aria-label' => 'My Account',
                ],
                'content'    => $content,
                'echo'       => true,
            ] );
        }
        break;
    

  • [deleted] replied

    Hi Andre,

    You are correct on this, thank you for letting us know. Can you please add the following code in this file:

    medium
    (view large image)

    The code:

    'woocommerce-account-link' => [
        'login_text',
        'logged_in_text',
    ],

    And see if it will be elligible for translation.

    In Kalium v4.0 we are going to change header builder and this should be automatically translatable.

  •  15
    hahni replied

    I tried it but couldn't found the string in the .mo / .po files. Or do you mean to translate it with string translation?

  • [deleted] replied

    Hi Andre,

    Yes, it will be auto registered using wpml_register_single_string hook on String Translation since it is dynamic string.

    Have you tried searching these values in WPML String Translation management page?

  •  15
    hahni replied

    Now i tried to translate via MO / PO but you are absolutely right - it' only a string and it's there now.

    Thanks.

    Attached files:  Screenshot (365).png

  • [deleted] replied

    Yes, all multilingual plugins treat dynamic strings and we provide full support for WPML.

    For your information, you can check these functions implementation:

    medium
    (view large image)