Adding code to functions.php breaks Header/Footer (Anything with Visual Composer

Home Forums WordPress Themes Adding code to functions.php breaks Header/Footer (Anything with Visual Composer

This topic contains 28 replies, has 2 voices, and was last updated by  vhwebvision 1 day, 2 hours ago.

Website URL: https://vhprojects.nl/onlinebabyplants.com/shop/
Theme:
Purchase Code: Please provide correct purchase code

  • Author
    Posts
  • #40043

    vhwebvision
    Participant

    Hi,

    We installed the plantmore theme and this works fine. We have a WooCommerce store running and want to show the out of stock products as last on our shop page.

    This works with this code in other themes we have built/used:

    class iWC_Orderby_Stock_Status{

    public function __construct()
    {

    // Check if WooCommerce is active

    if ( class_exists( ‘WooCommerce’ ) ) {
    add_filter(‘posts_clauses’, array(
    $this,
    ‘order_by_stock_status’
    ) , 2000);
    }
    }

    public function order_by_stock_status($posts_clauses)
    {
    global $wpdb;

    // only change query on WooCommerce loops

    if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag()))
    {
    $posts_clauses[‘join’].= ” INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) “;
    $posts_clauses[‘orderby’] = ” istockstatus.meta_value ASC, ” . $posts_clauses[‘orderby’];
    $posts_clauses[‘where’] = ” AND istockstatus.meta_key = ‘_stock_status’ AND istockstatus.meta_value <> ” ” . $posts_clauses[‘where’];
    }

    return $posts_clauses;
    }
    }

    new iWC_Orderby_Stock_Status;

    However when adding this to our Plantmore (Child) functions.php it makes the footer and header disappear on our shop page. We think its cause of the Visual Composer that causes a bug but cant figure it out.

    Could you look into this?

    Thanks in advance!

    Regards,

    Alan

  • #40045

    vhwebvision
    Participant

    Hi,

    Another issue.

    The Visual Composer isnt the most recent version? But we cant update it because we don’t have a license for it? We expected each plugin to be the newest version by buying the theme, could you provide us the newest version of the Visual Composer?

    At the moment the theme widgets (see screenshot: http://prntscr.com/l72841) don’t work when loading them in the visual composer.

    It seems like something causes a bug for the VC.

    Could you check this out too?

    Regards,

    Alan

  • #40055
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,
    Can you provide for us FTP or Cpanel, Dashboard account and Code license ?
    We will check it for you
    Regards
    RT Team

  • #40063

    vhwebvision
    Participant
    This reply has been marked as private.
  • #40086
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,

    we updated latest version VC for you. You can check again

    Kind Regards

    RT Team

  • #40089

    vhwebvision
    Participant

    Hi,

    Thanks! But nothing changed sadly..

    If you go into WPBakery Page Builder > Templates > Header 2 and try to click on Mini cart, Product Search (Dropdown), etc it pops up with a blank screen, indicating there’s still an error.

    Also when I uncomment my Functions.php code the visual composer elements on the shop page also disappear.

    It seems there’s a bug between the theme elements and the composer.

    Hope you can check it out.

    Thanks,

    Alan

  • #40095
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,

    Product Search (Dropdown), etc it pops up with a blank screen ->  This only is short code to call to page. It doesn’t has option

    Thanks!

  • #40116

    vhwebvision
    Participant

    Hi,

    Okay clear.

    What about the other Issue I mentioned? We have a WooCommerce store running and want to show the out of stock products as last on our shop page. This works with this code in other themes we have built/used:

    class iWC_Orderby_Stock_Status{

    public function __construct()
    {

    // Check if WooCommerce is active

    if ( class_exists( ‘WooCommerce’ ) ) {
    add_filter(‘posts_clauses’, array(
    $this,
    ‘order_by_stock_status’
    ) , 2000);
    }
    }

    public function order_by_stock_status($posts_clauses)
    {
    global $wpdb;

    // only change query on WooCommerce loops

    if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag()))
    {
    $posts_clauses[‘join’].= ” INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) “;
    $posts_clauses[‘orderby’] = ” istockstatus.meta_value ASC, ” . $posts_clauses[‘orderby’];
    $posts_clauses[‘where’] = ” AND istockstatus.meta_key = ‘_stock_status’ AND istockstatus.meta_value <> ” ” . $posts_clauses[‘where’];
    }

    return $posts_clauses;
    }
    }

    new iWC_Orderby_Stock_Status;

    However when adding this to our Plantmore (Child) functions.php it makes the footer and header disappear on our shop page. We think its cause of the Visual Composer that causes a bug but cant figure it out.

    Thanks in advance!

  • #40122

    vhwebvision
    Participant

    Hi,

    We added the header that came with the theme but not all widgets are working correctly. Our menu cart only shows when adding a product to the cart. Otherwise it’s not visible, see page:

    https://vhprojects.nl/onlinebabyplants.com/shop/

    It seems as if the items are not loaded in on page load.

     

  • #40128
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,

    We can’t load your website now.  You can check this.

    http://prntscr.com/l9p1j3

    Thanks!

  • #40132

    vhwebvision
    Participant

    Hi,

    It’s back online!

    Regards,

    Alan

  • #40156
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,

    We disabled plugin ( Disable Cart Fragments)  and  cart show normal. 

    You can check again.

  • #40164

    vhwebvision
    Participant

    Hi,

    Thanks!

    Our last issue is the one I mentioned as first in this. If you visit the shop page now, you can see the header & footer arent showing (visual composer) this happens when I insert the custom code in my functions.php to show the out of stock items as last. The code does do what it’s supposed to do.

    Can you look into what might be causing this? Because on other websites where we use this code it doesnt crash the header and footer.

    Thanks!

    Regards,

    Alan

  • #40312

    vhwebvision
    Participant

    Hi,

    Have you got an update for us?

    Thanks!

    Regards,

    Alan

  • #40328
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,

    We see shop page works normal now. Have you fixed it ?

    Thanks!

  • #40330

    vhwebvision
    Participant

    Hi,

    We turned it off cause we needed to show the client the website.

    I added the code to the functions again now. You can check what happens to the store page.

    Regards,

    Alan

  • #40332
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,

    Can you provide for us Cpanel account ?

    Thanks!

  • #40333

    vhwebvision
    Participant

    Hi,

    Unfortunately thats not possible as it’s shared with other websites.

    What do you need? Access to FTP? Database? We can create seperate login’s for that.

    Regards,

    Alan

  • #40335
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,

    So, You can compress your website include both   code and database then upload and provide link for us download

    We will install on localhost and fix it for you

    Thanks!

  • #40339

    vhwebvision
    Participant
    This reply has been marked as private.
  • #40356
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,

    We have tried best to fix it but we can’t find the reason. It doesn’t show errors so  It’s difficult to fix

    Can you turn off this feature ?

    Thanks!

     

  • #40358

    vhwebvision
    Participant

    Hi,

    Yes we already saw that.

    We actually need this feature because our client specifically asked for it. We think it’s a problem with VisualComposer however, cause we didnt get a license key for VisualComposer with this theme, we can’t contact them..

    Is there a direct way to contact them where they can offer support? Or can you contact them?

    Thanks,

    Regards,

    Alan

  • #40508

    vhwebvision
    Participant

    Hi,

    Another issue we have is that the site seems slow. This happened directly after installing the theme.

    What can be done about this?

    Regards,

    Alan

  • #40625
    Kevin Sobo
    Kevin Sobo
    Keymaster

    We installed cache plugin and your website load well now.  You can check again.

    Thanks!

  • #40743

    vhwebvision
    Participant

    Hi,

    This has sped it up a bit yeah, thanks!

    One more issue, I managed to get an error code to be shown on the shop page where we want to add the functions.php code. Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in functions.php on line 73. This refered to the plantmore theme, not my child theme.

    This might be causing the bug that deletes the Visual Composer parts when adding my custom code. However I cant find that constant on line 73 as its probably loaded in somewhere else.

    Could you check that out? Thanks!

  • #40752
    Kevin Sobo
    Kevin Sobo
    Keymaster

    Hi,

    We can’t connect to FTP.

    You can find see it at line 73 in file functions.php  our theme

    http://prntscr.com/li4l9a

    You can change it $_SERVER[REQUEST_URI]   to  $_SERVER[‘REQUEST_URI’]

  • #40761

    vhwebvision
    Participant

    Hi,

    That’s the thing, there isn’t such a code in your functions.php on that line 73, I couldnt find it. The error code isn’t displaying at the moment so maybe it was nothing.

    We contacted WpBakery Pagebuilder (bought support for it) about the problem we had with the shop page but they said there plugin is working fine and that the problem that causes the header and footer to disappear isn’t because of their plugin.

    They told us to contact you for a solution because it happens in your theme. We would like to get a solution for the problem (header and footer dissappearing when adding custom code to functions.php).

    I look forward to the answer/help.

    Regards,

    Alan

  • #40762

    vhwebvision
    Participant

    UPDATE

    We figured out that that line of code was caused by malware. It’s been solved now.

    Now we only need help with the shop page

  • #40763

    vhwebvision
    Participant

    UPDATE 2:

    Wpbakery disabled their plugin and the header and footer didnt load as raw text. This shows its not related to their plugin. Just something colliding in the header and footer files.

You must be logged in to reply to this topic.

Browser our premium, beautiful WooCommerce WordPress themes for your online store