Reputation: 3
With my header file i have the following code below. However if I switch off Woocommerce plugin I receive alot of error codes (see below)
<ul class="site-header-cart menu">
<li>
<?php storefront_cart_link(); ?>
</li>
<li>
<?php the_widget( 'WC_Widget_Cart', 'title=' ); ?>
</li>
</ul>
/////////////////
it's something to do with this line - does this need to be an if statement. I've been trying to fix for a couple of hours but had no success. I am only a novice php guide with basic understanding
When 'woocommerce' is switched on the page looks fine with no errors however some jquery errors are evident in the console chrome - hence trying to fix the bug code
Fatal error: Uncaught Error: Call to undefined function storefront_cart_link() in /home/mpex/tiltrak.com/public/webdev/wp-content/themes/storefront-child/header.php:43 Stack trace: #0 /home/mpex/tiltrak.com/public/webdev/wp-includes/template.php(688): require_once() #1 /home/mpex/tiltrak.com/public/webdev/wp-includes/template.php(647): load_template('/home/mpex/tilt...', true) #2 /home/mpex/tiltrak.com/public/webdev/wp-includes/general-template.php(41): locate_template(Array, true) #3 /home/mpex/tiltrak.com/public/webdev/wp-content/themes/storefront-child/page.php(5): get_header() #4 /home/mpex/tiltrak.com/public/webdev/wp-includes/template-loader.php(74): include('/home/mpex/tilt...') #5 /home/mpex/tiltrak.com/public/webdev/wp-blog-header.php(19): require_once('/home/mpex/tilt...') #6 /home/mpex/tiltrak.com/public/webdev/index.php(17): require('/home/mpex/tilt...') #7 {main} thrown in /home/mpex/tiltrak.com/public/webdev/wp-content/themes/storefront-child/header.php on line 43
Any help greatly appreciated
<?php
/**
* The header for our theme.
*
* Displays all of the <head> section and everything up till <div id="content">
*
* @package storefront
*/
?><!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2.0">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<style>
@import url('https://fonts.googleapis.com/css?family=Montserrat');
</style>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<!-- Start of Top Navigation -->
<div class="container-fluid grey-nav-bar">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-5 col-lg-5">
<?php wp_nav_menu( array( 'theme_location' => 'customer-menu' ) ); ?>
</div>
<div class="col-xs-12 col-sm-12 col-md-5 col-lg-5">
<?php wp_nav_menu( array( 'theme_location' => 'place-adverts' ) ); ?>
</div>
<div class="col-xs-12 col-sm-12 col-md-2 col-lg-2">
<ul class="site-header-cart menu">
<li>
<?php storefront_cart_link(); ?>
</li>
<li>
<?php the_widget( 'WC_Widget_Cart', 'title=' ); ?>
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- End of Top Navigation -->
<!-- Start of Top Logo and Product Search -->
<div class="container-fluid">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="main-logo"><a href="https://tiltrak.com/webdev/home"><img src="https://tiltrak.com/webdev/wp-content/uploads/2018/11/tiltrak-automotive-marketplace-buy-sell-cars-classic-cars-motorcycles-vans-commercial-vehicles-autojumble-motor-factors-accessories-shop-uk.jpg" alt="tiltrak automotive marketplace buy sell cars classic cars motorcycles vans commercial vehicles autojumble motor factors accessories shop uk"></a> </div>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="search-tophold">
<div class="site-search">
<?php if ( function_exists( 'aws_get_search_form' ) ) { aws_get_search_form(); } ?>
</div>
<div class="contact-header">Tel: <a href="tel:01925394434">01925 394 434</a> • Email: <a href="mailto:[email protected]">[email protected]</a></div>
</div>
</div>
</div>
</div>
</div>
<!-- End of Top Logo and Product Search -->
<?php do_action( 'storefront_before_site' ); ?>
<?php do_action( 'storefront_before_header' ); ?>
<header id="masthead" class="site-header" role="banner" style="<?php storefront_header_styles(); ?>">
<?php
/**
* Functions hooked into storefront_header action
*
* @hooked storefront_header_container - 0
* @hooked storefront_skip_links - 5
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_header_container_close - 41
* @hooked storefront_primary_navigation_wrapper - 42
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
* @hooked storefront_primary_navigation_wrapper_close - 68
*/
do_action( 'storefront_header' ); ?>
</header><!-- #masthead -->
<?php
/**
* Functions hooked in to storefront_before_content
*
* @hooked storefront_header_widget_region - 10
* @hooked woocommerce_breadcrumb - 10
*/
do_action( 'storefront_before_content' ); ?>
<div id="content" class="site-content" tabindex="-1">
<div class="col-full">
<?php
do_action( 'storefront_content_top' );
Upvotes: 0
Views: 296
Reputation: 2295
Assuming this template is custom, and this behaviour is due to the template expecting WooCommerce to always be installed, you can simply remove the reference to the undefined function in the header.php file that you posted:
<div class="col-xs-12 col-sm-12 col-md-2 col-lg-2">
<ul class="site-header-cart menu">
<li>
<?php //storefront_cart_link(); ?>
</li>
<li>
<?php the_widget( 'WC_Widget_Cart', 'title=' ); ?>
</li>
</ul>
</div>
Above I've commented-out the storefront_cart_link();
function call. I have no idea what the implications are for removing the function call. It's best to test it once you've tried this and see if it helps!
Upvotes: 0