• Resolved yendi

    (@yendi)


    Hello, first of all, thank you for this awesome plugin, it has been a life saver. However, we have two issues we would like to solve:

    1) Attributes print both after the short description and the normal description. We would like to show them ONLY after the short description.

    2) When we added a Content Block (via the Woocommerce conditional content plugin), when the conditional content is outputted, the attributes get displayed after it. It doesn’t matter which position we choose. See en example in our staging site here: https://staging1.portabebes.mx/producto/celeste-bambu-algodon/

    Can you help us solve this?
    Thank you!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author mjke87

    (@mjke87)

    Hi @yendi,

    The plugin uses the the_content filter, which triggered by WooCommerce the_content function call to insert the content within the description tab. It seems that your theme also uses this function within the short description (which isn’t standard) and so does the content block plugin.

    Therefore I suggest the following solution:

    remove_filter('the_content', array(\MJJ\WooProductAttributeTab\Tabs::instance(), 'extend_product_description'), 99, 1);
    add_action('woocommerce_after_template_part', function($template_name, $template_path, $located, $args) {
        if ($template_name == 'single-product/tabs/description.php') {
            echo \MJJ\WooProductAttributeTab\Tabs::instance()->extend_product_description('');
        }
    }, 50);
    

    Insert the above code snippet somewhere in your theme.

    Kind regards,
    Mike

    • This reply was modified 7 years, 2 months ago by mjke87.
    • This reply was modified 7 years, 2 months ago by stephencottontail.
    Thread Starter yendi

    (@yendi)

    Thanks Mike, I added the code in the functions.php of my theme, but it broke my site… I had to replace functions.php with my backup file. Could you double-check it for me? Thank you again!

    Plugin Author mjke87

    (@mjke87)

    Hi @yendi,

    I’ve tested this code and it works just fine.
    If you need further help, please provide an error message.

    Kind regards,
    Mike

    Thread Starter yendi

    (@yendi)

    Mike, my bad, back then there was an issued with saving the functions file through wordpress somehow truncated it, and had nothing to do with the piece of code you sent. I’ve been happily working with that for almost 6 months now, and I appreciate the help.

    However, this last woo commerce update has shaken things up a bit, and now I was forced to remove your code from my functions.php file because it did throw an error: It said this part

    add_action(‘woocommerce_after_template_part’, function($template_name, $template_path, $located, $args) {
    if ($template_name == ‘single-product/tabs/description.php’) {
    echo \MJJ\WooProductAttributeTab\Tabs::instance()->extend_product_description(”);
    }
    }, 50);

    Was sending the wrong number of attributes to the woo commerce function.

    Can you help me rewrite this for the new version?

    Thank you!!!
    Yendi

    Plugin Author mjke87

    (@mjke87)

    Hi Yendi,

    Glad to hear that the snippet had worked for you those past months ??

    Try this updated code snipped:

    
    remove_filter('the_content', array(\MJJ\WooProductAttributeTab\Tabs::instance(), 'extend_product_description'), 99, 1);
    add_action('woocommerce_after_template_part', function($template_name) {
        if ($template_name == 'single-product/tabs/description.php') {
            echo \MJJ\WooProductAttributeTab\Tabs::instance()->extend_product_description('');
        }
    }, 50, 1);
    

    I fixed the number or arguments of the callback function.

    Let me know if this works for you.
    Kind regards, Mike

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Attributes injected on several places’ is closed to new replies.