• Hello, is it possible to translate functions, IDs, for instance

    'title' => __( 'Preventivo', 'woocommerce' ), // TAB TITLE
    echo 'richiesta noleggio volo per ' . $product->get_name(); // TAB TEXT
    echo do_shortcode( '[form id="1046"]' ); // CHANGE SHORTCODE IF SECOND LANGUAGE IS DETECTED

    or custom html and URLs I put in my widget, like

    [button text="torna al catalogo" url="my-language-url"]

    … I guess not, right?

Viewing 15 replies - 31 through 45 (of 48 total)
  • Plugin Author sbouey

    (@sbouey)

    the change i give you before are not in this code

    Thread Starter devsaredead

    (@devsaredead)

    ?? that is the code that works showing the custom tab to every product. I could not understand where to include the changes you proposed in order to filter out all product_cat except noleggio/rents, I have made many attempts but either I modify it wrong or maybe it doesn’t work. Please be so kind to amend the code as it really should be, because I’m really lost, I’d appreciate a lot ??

    Thread Starter devsaredead

    (@devsaredead)

    hello, I’m catching up because you left me without a solution. Can you look at this again? thanks

    Plugin Author sbouey

    (@sbouey)

    Hi, it’s hard to help you more, i give you the logic and the code to add in function.php

    But without making it myself to see what’s wrong , it’s complicated. i have only some parts of the code

    with widget classic you can put a widget by language

    Thread Starter devsaredead

    (@devsaredead)

    Thank you for your time anyway. It looked like we were close to the solution ??

    Plugin Author sbouey

    (@sbouey)

    Can you put back here the full code of function.php

    Thread Starter devsaredead

    (@devsaredead)

    hello again. You can read the full code hereby:

    /* New Product Tab @ WooCommerce Single Product */
    if (class_exists( 'Falang' )) {
    $current_locale = Falang()->get_current_language()->locale;
    if ($current_locale == 'it_IT') {
    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab', 9999 );
    function woo_new_product_tab( $tabs ) {
    $tabs['docs'] = array(
    'title' => __( 'Preventivo', 'woocommerce' ), // TAB TITLE
    'priority' => 50, // TAB SORTING (DESC 10, ADD INFO 20, REVIEWS 30)
    'callback' => 'woo_new_product_tab_content', // TAB CONTENT CALLBACK
    );
    return $tabs;
    }
    function woo_new_product_tab_content() {
    // The new tab content
    global $product;
    echo 'richiesta noleggio volo per ' . $product->get_name();
    echo do_shortcode( '[forminator_form id="1046"]' );
    }
    }
    if ($current_locale == 'en_US') {
    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab', 9999 );
    function woo_new_product_tab( $tabs ) {
    $tabs['docs'] = array(
    'title' => __( 'Quotation', 'woocommerce' ), // TAB TITLE
    'priority' => 50, // TAB SORTING (DESC 10, ADD INFO 20, REVIEWS 30)
    'callback' => 'woo_new_product_tab_content', // TAB CONTENT CALLBACK
    );
    return $tabs;
    }
    function woo_new_product_tab_content() {
    // The new tab content
    global $product;
    echo 'rent request for ' . $product->get_name();
    echo do_shortcode( '[forminator_form id="1059"]' );
    }
    }
    }

    This is the category where the code appears (just open a product and see the custom tab “Preventivo/Quotation”), whereas it should not appear in all other categories. Looking forward to your kind help ??

    Plugin Author sbouey

    (@sbouey)

    I wouldn’t have written my code like that but can you try this

    /* New Product Tab @ WooCommerce Single Product */
    if (class_exists( 'Falang' )) {
    $current_locale = Falang()->get_current_language()->locale;
    if ($current_locale == 'it_IT') {
    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab_it', 9999 );
    function woo_new_product_tab_it( $tabs ) {
    $tabs['docs'] = array(
    'title' => __( 'Preventivo', 'woocommerce' ), // TAB TITLE
    'priority' => 50, // TAB SORTING (DESC 10, ADD INFO 20, REVIEWS 30)
    'callback' => 'woo_new_product_tab_content_it', // TAB CONTENT CALLBACK
    );
    return $tabs;
    }
    function woo_new_product_tab_content_it() {
    // The new tab content
    global $product;
    echo 'richiesta noleggio volo per ' . $product->get_name();
    echo do_shortcode( '[forminator_form id="1046"]' );
    }
    }
    if ($current_locale == 'en_US') {
    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab_en', 9999 );
    function woo_new_product_tab_en( $tabs ) {
    $tabs['docs'] = array(
    'title' => __( 'Quotation', 'woocommerce' ), // TAB TITLE
    'priority' => 50, // TAB SORTING (DESC 10, ADD INFO 20, REVIEWS 30)
    'callback' => 'woo_new_product_tab_content_en', // TAB CONTENT CALLBACK
    );
    return $tabs;
    }
    function woo_new_product_tab_content_en() {
    // The new tab content
    global $product;
    echo 'rent request for ' . $product->get_name();
    echo do_shortcode( '[forminator_form id="1059"]' );
    }
    }
    }
    Thread Starter devsaredead

    (@devsaredead)

    I can spot the small difference in the code but it doesn’t work. I mean, it changes the tab content as per language, but the tab is visible for all categories. As a matter of fact, I don’t see anything that could recall a logic like “check if the product is from category X and: show custom tab if it is, hide the tab if it isn’t”.

    It looks like you removed/forgot the if ( has_term( 'noleggio|rents', 'product_cat' ) )

    Plugin Author sbouey

    (@sbouey)

    No threre are nothing about categories in the code but now the content is set correctly for each language ?

    Thread Starter devsaredead

    (@devsaredead)

    …yes the content is correct, but it was also in the original code ??

    I guess we just need to insert the 2 categories IF statements:

    if ( has_term( 'noleggio', 'product_cat' ) ) and if ( has_term( 'rents', 'product_cat' ) )

    but they must go outside if (class_exists( 'Falang' )), right?

    Plugin Author sbouey

    (@sbouey)

    it’s the same but like i said before i wouldn’t have write my code like this

    don’t put an AND but OR you have to display it for noleggio OR rents

    Thread Starter devsaredead

    (@devsaredead)

    don’t put AND but OR, you have to display it for noleggio OR rents

    yes but I have no idea how to do this, I’m no coder ?? sorry. Something like this, maybe?

    if ( has_term( ['noleggio','rents'], 'product_cat' ) ) {
    if (class_exists( 'Falang' ))

    Plugin Author sbouey

    (@sbouey)

    try this,

    /* New Product Tab @ WooCommerce Single Product */
    if (class_exists( 'Falang' )) {
    if ( has_term( 'noleggio', 'product_cat' ) || has_term( 'rents', 'product_cat' ) ) {
    $current_locale = Falang()->get_current_language()->locale;
    if ($current_locale == 'it_IT') {
    add_filter('woocommerce_product_tabs', 'woo_new_product_tab_it', 9999);
    function woo_new_product_tab_it($tabs)
    {
    $tabs['docs'] = array(
    'title' => __('Preventivo', 'woocommerce'), // TAB TITLE
    'priority' => 50, // TAB SORTING (DESC 10, ADD INFO 20, REVIEWS 30)
    'callback' => 'woo_new_product_tab_content_it', // TAB CONTENT CALLBACK
    );
    return $tabs;
    }

    function woo_new_product_tab_content_it()
    {
    // The new tab content
    global $product;
    echo 'richiesta noleggio volo per ' . $product->get_name();
    echo do_shortcode('[forminator_form id="1046"]');
    }
    }
    if ($current_locale == 'en_US') {
    add_filter('woocommerce_product_tabs', 'woo_new_product_tab_en', 9999);
    function woo_new_product_tab_en($tabs)
    {
    $tabs['docs'] = array(
    'title' => __('Quotation', 'woocommerce'), // TAB TITLE
    'priority' => 50, // TAB SORTING (DESC 10, ADD INFO 20, REVIEWS 30)
    'callback' => 'woo_new_product_tab_content_en', // TAB CONTENT CALLBACK
    );
    return $tabs;
    }

    function woo_new_product_tab_content_en()
    {
    // The new tab content
    global $product;
    echo 'rent request for ' . $product->get_name();
    echo do_shortcode('[forminator_form id="1059"]');
    }
    }
    }
    }
    Thread Starter devsaredead

    (@devsaredead)

    …unfortunately it’s still not able to detect the product category and the custom tab is visible in every product. We must try a different syntax…

Viewing 15 replies - 31 through 45 (of 48 total)
  • You must be logged in to reply to this topic.