Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1321800

    Hi Enfold team,

    probably quite similar to my other other open support thread after my recent update jump from 4.2ish to 4.8 the comments shortcode is acting up when created by a custom shortcode and then parsed (meaning I insert a short custom shortcode into a page, which then creates a longer page of shortcodes and parses them to create the whole page). Background of this is to automatically create a variety of similar pages (custom product pages) with a certain layout (once created in the advanced layout builder) but with different images, product IDs, video links etc.

    When inserting the comments shortcode regularly into a page, everything works fine, but when outputed via the custom shortcode php structure and then parsed it shows “comments are deactivated”.
    My custom shortcode php is below, as well as examples for both a working page (comments shortcode regularly placed via editor) and a broken page.

    I already tried updating the shortcode-generator from [av_comments_list] to the new [av_comments_list xxx] (where xxx are various extra parameters which seem to be introduced since the update.

    Any support is greatly appreciated, thank you in advance!
    Jörg

    • This topic was modified 3 years, 3 months ago by joerka27. Reason: extended rexplanation
    #1322025

    Hey joerka27,

    Thank you for inquiry.

    We replied in the previous thread and provided a filter that will hopefully fix the issue that you are having with the shortcode. For the comments issue, try to add this filter in the functions.php file.

    add_filter("comments_open", function() {
       return true;
    }, 9999);
    

    And make sure that comments are enabled in the Settings > Discussion panel.

    Best regards,
    Ismael

    #1322537

    Hey Ismael,

    yeah that code worked, thanks a lot! Comments were enabled in Settings -> Discussion all along, but good additional point :-).

    Issue can be closed!
    Best regards,
    Jörg

    #1322613

    Hi Ismael,
    sorry it’s me again – I just found out that the code also added comments to other pages like for example the checkout page (although on the checkout page comments are disabled in the page settings). See pic below for reference:

    That’s clearly not the intended behavior, so I had to remove the code again. Do you have another solution for this issue by chance?
    Best regards,
    Jörg

    #1322889

    Hi,

    Try to add conditional functions inside the filter to toggle the comments on certain pages.

    add_filter("comments_open", function($open) {
       if(is_wocommerce() || is_checkout() || is_cart()) {
         $open = false;
       }
       return $open;
    }, 9999, 1);
    

    This will disable the comments on Woocommerce pages including the shop, cart and checkout page.

    Best regards,
    Ismael

    #1323043

    Hi Ismael,

    unfortunately that didn’t work, see the critical error message below. Seems like WooCommerce conditional functions were not (yet) loaded, I tried to insert a check if they were and otherwise to load them, but that also produced the critical error:

    add_filter("comments_open", function($open) {
    	if ( !function_exists( 'is_woocommerce' ) ) { 
    				require_once '/includes/wc-conditional-functions.php'; 
    			}
       if(is_wocommerce() || is_checkout() || is_cart()) {
         $open = false;
       }
       return $open;
    }, 9999, 1);

    Did I miss something here? Thanks already for your time,
    Jörg

    #1323120

    Hey,
    I just noticed that somehow the bug disppeared and the comments are postable again (no “comments closed” error). Not really sure what did it – I implemented two small suggest fixes from Günter (other threads with other issues) for the template-builder.php and section.php and fixed a bug where the comments box was shown twice (via CSS visibility:hidden for the second one).

    Anyhow – as this works now, this thread can be closed – thanks for your help along the way!
    Best regards,
    Joerka

    #1323135

    Hi,

    Sorry about that. There is a minor syntax error in the code. Please look for this line..

    if(is_wocommerce() || is_checkout() || is_cart()) {
    

    .., and replace it with:

    if(is_woocommerce() || is_checkout() || is_cart()) {
    
    

    Or just remove this part.

    is_woocommerce() || 
    

    Best regards,
    Ismael

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