• Resolved dieSuse

    (@diesuse)


    Hi there,

    I’m trying since hours but I have no idea anymore.
    I want to translate attribute values of a variable product. As described at “Known Issues” of this plugin I tried “[:de]wert1[:en]value1[:] | [:de]wert2[:en]value2[:]” or “{:de}wert1{:en}value1{:} | {:de}wert2{:en}value2{:}” seperated by “|” but the select box always stays empty except the “Choose an option”.
    Translating the attribute name this way works fine, but the values won’t.
    If I just change the attribute value to “value1 | value2” (so, only English for testing) makes it work as supposed. That tells me, that all the other things are correct. Changing the attribute value back to qtranslate-code as seen above and the select box is empty again.

    It’s driving me crazy. So please help!

    Regards,
    Suse

    Using WooCommerce version 2.5.2
    WooCommerce&qTranslate-X version 1.3
    (WooCommerce Germanized 1.5.1)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dieSuse

    (@diesuse)

    Hi found a solution. Maybe not a very elegant one but it works and it is update safe.

    I found out, that the attribute values read out in woocommerce/includes/class-wc-product-variable.php are on the one hand ($assigned_text_attributes) the translated ones and on the other hand ($text_attributes) the raw ones using the qtranslate-x code [:de]…[:fr]…[:]. Of course this way, there were no matching values found and the select box stays empty.
    I solved this issue but just translating the raw $text_attributes by myself.

    Since changing the code in the core file is not update safe, I created a class My_WC_Product_Variable deriving from WC_Product_Variable. This class has only one method get_variation_attributes() where the foreach-loop to translate the attribute values is added.

    In my funktions.php I managed to use class My_WC_Product_Variable and the select box is filled with correct translated attribue values.

    Thread Starter dieSuse

    (@diesuse)

    Close this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Translate product attribute values’ is closed to new replies.