• Resolved User

    (@lostguybrazil)


    Hi,

    Many thanks for this great plugin, which I am a subscriber of the Pro version.

    I have just turned my website into multilingual using Polylang – and the invoice attributes (e.g. “Rechnung”, “Beschreibung”) are kept correctly in German from the created template.

    Now I would like to know if it is possible to push/retrieve the product name and attribute/variations from the original german product (de)?

    If this functionality is not implemented into Germanized, would it be possible to accmplish this using custom PHP code?

    Many thanks and kind regards,
    Roberto

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author vendidero

    (@vendidero)

    Hi Roberto,

    currently we do not offer specific compatibility for Polylang (Pro) but I guess the actual issue might be that the corresponding order (items) already include the english title? That’s what being passed to the actual invoice object..

    Best,
    Dennis

    Thread Starter User

    (@lostguybrazil)

    Hi Dennis, thank you for your prompt answer. So basically how it works is that if I translate a product from German to English, a new product ID is generated. It would be nice to display the “Rechnung” always with the product name, attribute name and variation name in German.

    Maybe it would be possible to implement a logic to retrieve the product id for the German version of the product, and then obtain the corresponding German product name? This worked worked for me:

    <?php

    if (WC() && function_exists('pll_current_language') && function_exists('pll_get_post')) {

    // Settings
    $product_id = 31488; // Example of a product_id in English

    // Get the current language of the product
    $current_language = pll_get_post_language($product_id);

    // Check if the product is already in German
    if ($current_language !== 'de') {
    // Get the German product ID using Polylang
    $product_id_de = pll_get_post($product_id, 'de');

    if ($product_id_de) {
    // Load the German product
    $product_de = wc_get_product($product_id_de);

    if ($product_de) {
    // Get the product name
    $product_name_de = $product_de->get_name();
    }
    }

    } else {
    $product_id_de = $product_id;
    $product_name_de = $product_id->get_name();
    }

    // Output product name
    echo 'Product id (de): ' . $product_id_de . '<br>';
    echo 'Product name (de): ' . $product_name_de . '<br>';

    }

    Is it possible to create a WordPress hook that would implement this logic of retreving the product name, attribute and variation of the german version of a given product?

    Thanks!

    Plugin Author vendidero

    (@vendidero)

    Hi there,

    the thing is, as stated above, the invoice does not include products, but invoice lines, which reference order items (which have a title by itself as can be seen on the edit order page). You might of course retrieve product data based on invoice lines and swap the title but you’ll need some webdev to implement the custom logic for you. There are two ways to do that:

    1. Use filters that are applied during the syncing of an (new) invoice with an order and pass the adjusted item/product title to be stored within the invoice (preferred)
    2. Dynamically adjust the invoice line title (based on product data) – this will only work as long as the product still exists and might not be very suitable from a bookkeeping perspective.

    For 1.:

    Use the filter storeabill_woo_order_item_line_item_synced applied in woocommerce-germanized-pro/packages/storeabill/src/WooCommerce/OrderItemProduct.php

    You might retrieve the product id base on the object passed to the filter and set the name of the actual invoice line.

    PS: Please use our help desk for support on our pro version: https://vendidero.de/dashboard/help-desk

    Best,
    Dennis

    Thread Starter User

    (@lostguybrazil)

    Thanks!

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