Forum Replies Created

Viewing 15 replies - 16 through 30 (of 162 total)
  • Thread Starter devsaredead

    (@devsaredead)

    Sure, thank you very much indeed for trying. I will let you know if I find a solution… ??

    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…

    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' ))

    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?

    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' ) )

    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 ??

    Thread Starter devsaredead

    (@devsaredead)

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

    Thread Starter devsaredead

    (@devsaredead)

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

    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)

    sure, thank you for your time. The actual code is this:


    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"]' );
    }
    }
    }
    Thread Starter devsaredead

    (@devsaredead)

    sorry I understand the logic but not the syntax, I’m not a PHP dev….

    If I substitute the callback it gives me an error, so I have to add it ? but it doesn’t work… sorry for the dum question


    'callback' => 'woo_new_product_tab_content', // TAB CONTENT CALLBACK
    );
    }
    function woo_new_product_tab_content_us() {
    // ENGLISH TAB CONTENT
    global $product;
    echo 'rent request for ' . $product->get_name();
    echo do_shortcode( '[forminator_form id="1059"]' );
    }


    Thread Starter devsaredead

    (@devsaredead)

    ok it’s 1 parameter but it has 2 echos

        function woo_new_product_tab_content() {
    // ITALIAN TAB CONTENT
    global $product;
    echo 'richiesta noleggio volo per ' . $product->get_name();
    echo do_shortcode( '[forminator_form id="1046"]' );
    }

    and

    function woo_new_product_tab_content() {
    // ENGLISH TAB CONTENT
    global $product;
    echo 'rent request for ' . $product->get_name();
    echo do_shortcode( '[forminator_form id="1059"]' );
    }

    Thread Starter devsaredead

    (@devsaredead)

    I don’t get it. Where does it fetch the $tabs from?

    Thread Starter devsaredead

    (@devsaredead)

    I apologize, in the code above I wrote the shortcode [contact form] thinking it was not important to you, but as a matter of fact it’s a different shortcode for the 2 languages (i.e. contactform id=1 and contactform id=2). I can see that it does make a difference, so I do apologize if I have to ask you to adapt the code again (also there was a little error

    'title' => ( )

    was missing __(

    Besides that, I don’t think it works because I can see the contact form in both product categories

    Thread Starter devsaredead

    (@devsaredead)

    Yes I have the following code in my function.php file. This is an example of the product where the custom tab is visible (/product_cat/noleggio/ (Italian) and /product_cat/rents (English)), and this is an example where the tab is visible but I wish it was hidden (all other product_cat).

    /* NEW PRODUCT TAB IN 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( '[contact form]' );
    }
    }
    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( '[contact form]' );
    }
    }
    }
Viewing 15 replies - 16 through 30 (of 162 total)