• I would like to replace the Storefront theme’s default product search with the standard wp page/post search.
    When i modified the storefront-woocommerce-template-functions.php from the storefront theme, the search is replaced and it works:

    	function storefront_product_search() {
    		if ( storefront_is_woocommerce_activated() ) {
    			?>
    			<div class="site-search">
    				<!--<?php the_widget( 'WC_Widget_Product_Search', 'title=' ); ?>-->
    				<?php the_widget( 'WP_Widget_Search', 'title=' ); ?>
    			</div>
    			<?php
    		}
    	}

    but actually thats not a good way.

    When I try it with my Chield Theme, it does not work, I still have the Woocommerce product search!

    Content of functions.php in my chield theme:

    <?php
    // Exit if accessed directly
    if ( !defined( 'ABSPATH' ) ) exit;
    
    // BEGIN ENQUEUE PARENT ACTION
    // AUTO GENERATED - Do not modify or remove comment markers above or below:
    
    if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
        function chld_thm_cfg_locale_css( $uri ){
            if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
                $uri = get_template_directory_uri() . '/rtl.css';
            return $uri;
        }
    endif;
    add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
    
    // END ENQUEUE PARENT 
    
    //replace product search in header with site search (storefront_product_search)
    function child_theme_replace_header_search() {
        remove_action( 'storefront_header', 'storefront_product_search', 40 );
        add_action( 'storefront_header', 'replacement_header_search', 40 );
    }
    
    function replacement_header_search () {
        ?>
            <div class="site-search">
                <?php the_widget( 'WP_Widget_Search', 'title=' ); ?>
            </div>
        <?php
    }
    
    add_action( 'init', 'child_theme_replace_header_search', 90 );

    what i’m doing wrong?

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter hardynet

    (@hardynet)

    
    ### WordPress Environment ###
    
    WordPress address (URL): https://weinbaugenossenschaft.hardynet.ch
    Site address (URL): https://weinbaugenossenschaft.hardynet.ch
    WC Version: 3.8.1
    REST API Version: ? 1.0.2
    Log Directory Writable: ?
    WP Version: 5.3.2
    WP Multisite: ?
    WP Memory Limit: 256 MB
    WP Debug Mode: ?
    WP Cron: ?
    Language: de_DE
    External object cache: –
    
    ### Server Environment ###
    
    Server Info: LiteSpeed
    PHP Version: 7.3.11
    PHP Post Max Size: 16 MB
    PHP Time Limit: 30
    PHP Max Input Vars: 1000
    cURL Version: 7.62.0
    OpenSSL/1.0.2k
    
    SUHOSIN Installed: –
    MySQL Version: 5.7.26-log-cll-lve
    Max Upload Size: 15 MB
    Default Timezone is UTC: ?
    fsockopen/cURL: ?
    SoapClient: ?
    DOMDocument: ?
    GZip: ?
    Multibyte String: ?
    Remote Post: ?
    Remote Get: ?
    
    ### Database ###
    
    WC Database Version: 3.8.1
    WC Database Prefix: wgsch_
    Datenbank-Gesamtgr??e: 9.45MB
    Datenbank-Datengr??e: 6.92MB
    Datenbank-Indexgr??e: 2.53MB
    wgsch_woocommerce_sessions: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_woocommerce_api_keys: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_woocommerce_attribute_taxonomies: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_woocommerce_downloadable_product_permissions: Daten: 0.02MB + Index: 0.06MB + Engine InnoDB
    wgsch_woocommerce_order_items: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_woocommerce_order_itemmeta: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_woocommerce_tax_rates: Daten: 0.02MB + Index: 0.06MB + Engine InnoDB
    wgsch_woocommerce_tax_rate_locations: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_woocommerce_shipping_zones: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_woocommerce_shipping_zone_locations: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_woocommerce_shipping_zone_methods: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_woocommerce_payment_tokens: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_woocommerce_payment_tokenmeta: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_woocommerce_log: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_blogmeta: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_blogs: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_blog_versions: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_commentmeta: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_comments: Daten: 0.30MB + Index: 0.44MB + Engine InnoDB
    wgsch_failed_jobs: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_links: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_litespeed_img_optm: Daten: 0.02MB + Index: 0.09MB + Engine InnoDB
    wgsch_litespeed_optimizer: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_loginizer_logs: Daten: 0.00MB + Index: 0.00MB + Engine MyISAM
    wgsch_mailchimp_carts: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_mailchimp_jobs: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_nextend2_image_storage: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_nextend2_section_storage: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_nextend2_smartslider3_generators: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_nextend2_smartslider3_sliders: Daten: 0.03MB + Index: 0.00MB + Engine InnoDB
    wgsch_nextend2_smartslider3_sliders_xref: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_nextend2_smartslider3_slides: Daten: 0.05MB + Index: 0.00MB + Engine InnoDB
    wgsch_options: Daten: 1.19MB + Index: 0.08MB + Engine InnoDB
    wgsch_postmeta: Daten: 1.45MB + Index: 0.23MB + Engine InnoDB
    wgsch_posts: Daten: 2.39MB + Index: 0.36MB + Engine InnoDB
    wgsch_queue: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_registration_log: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_signups: Daten: 0.02MB + Index: 0.06MB + Engine InnoDB
    wgsch_site: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_sitemeta: Daten: 0.25MB + Index: 0.03MB + Engine InnoDB
    wgsch_termmeta: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_terms: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_term_relationships: Daten: 0.06MB + Index: 0.05MB + Engine InnoDB
    wgsch_term_taxonomy: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_usermeta: Daten: 0.05MB + Index: 0.03MB + Engine InnoDB
    wgsch_users: Daten: 0.02MB + Index: 0.05MB + Engine InnoDB
    wgsch_wc_admin_notes: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_wc_admin_note_actions: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_wc_category_lookup: Daten: 0.02MB + Index: 0.00MB + Engine InnoDB
    wgsch_wc_customer_lookup: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_wc_download_log: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_wc_order_coupon_lookup: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_wc_order_product_lookup: Daten: 0.02MB + Index: 0.06MB + Engine InnoDB
    wgsch_wc_order_stats: Daten: 0.02MB + Index: 0.05MB + Engine InnoDB
    wgsch_wc_order_tax_lookup: Daten: 0.02MB + Index: 0.03MB + Engine InnoDB
    wgsch_wc_product_meta_lookup: Daten: 0.02MB + Index: 0.09MB + Engine InnoDB
    wgsch_wc_tax_rate_classes: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_wc_webhooks: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_yoast_seo_links: Daten: 0.02MB + Index: 0.02MB + Engine InnoDB
    wgsch_yoast_seo_meta: Daten: 0.17MB + Index: 0.00MB + Engine InnoDB
    
    ### Security ###
    
    Secure connection (HTTPS): ?
    Hide errors from visitors: ?Fehlermeldungen sollten Besuchern nicht angezeigt werden.
    
    ### Active Plugins (41) ###
    
    Akismet Anti-Spam: von Automattic – 4.1.3
    Better Font Awesome: von Mickey Kay – 1.7.1
    Facebook for WooCommerce: von Facebook – 1.9.15 – Nicht getestest mit der aktiven WooCommerce-Version
    Jetpack von WordPress.com: von Automattic – 8.0
    Loginizer: von Raj Kothari – 1.4.3
    Mailchimp for WooCommerce: von Mailchimp – 2.3 – Nicht getestest mit der aktiven WooCommerce-Version
    Storefront Blog Customiser: von WooCommerce – 1.3.0
    Storefront Hamburger Menu: von WooCommerce – 1.2.2
    Storefront Homepage Contact Section: von WooThemes – 1.0.5
    Storefront Powerpack: von WooCommerce – 1.5.0
    Storefront Reviews: von WooCommerce – 1.0.6 – Nicht getestest mit der aktiven WooCommerce-Version
    WooCommerce Admin: von WooCommerce – 0.24.0
    WooCommerce PayPal Checkout Gateway: von WooCommerce – 1.6.18
    WooCommerce Stripe-Gateway: von WooCommerce – 4.3.1
    WooCommerce Services: von Automattic – 1.22.2
    WooCommerce: von Automattic – 3.8.1
    wpCentral: von Softaculous Ltd. – 1.4.7
    Yoast SEO: von Team Yoast – 12.8
    Very Simple Event List: von Guido – 11.3
    Recent Posts Widget With Thumbnails: von Martin Stehle – 6.6.1
    Opening Hours: von Jannik Portz – 2.2.0
    Advanced Gutenberg: von JoomUnited – 2.3.1
    Child Theme Configurator: von Lilaea Media – 2.5.2
    Storefront Hamburger Menu: von WooCommerce – 1.2.2
    Storefront Footer Bar: von WooThemes – 1.0.4
    Storefront Parallax Hero: von WooCommerce – 1.5.7
    Storefront Product Hero: von WooThemes – 1.2.13
    Storefront Mega Menus: von WooCommerce – 1.6.2 – Nicht getestest mit der aktiven WooCommerce-Version
    Homepage Control: von WooThemes – 2.0.3
    WooCommerce Admin: von WooCommerce – 0.24.0
    Ultimate Add-Ons für Gutenberg: von Brainstorm Force – 1.14.6
    Simple Custom CSS: von John Regan
    Danny Van Kooten – 4.0.3
    
    WooCommerce Show Attributes: von Isabel Castillo – 1.6.4 – Nicht getestest mit der aktiven WooCommerce-Version
    SiteOrigin CSS: von SiteOrigin – 1.2.4
    What The File: von Never5 – 1.5.4
    WooCommerce Payrexx Gateway: von Payrexx – 1.6.16
    Content Views: von Content Views – 2.2.0
    Smart Slider 3: von Nextend – 3.3.25
    WooCommerce Bl?cke: von Automattic – 2.5.9
    Ivory Search: von Ivory Search – 4.4.6
    Jetpack von WordPress.com: von Automattic – 8.0
    
    ### Inactive Plugins (6) ###
    
    AMP: von AMP Project Contributors – 1.4.2
    Hello Dolly: von Matt Mullenweg – 1.7.2
    LiteSpeed Cache: von LiteSpeed Technologies – 2.9.9.2
    Simple Custom CSS and JS: von SilkyPress.com – 3.28
    Storefront Pricing Tables: von WooCommerce – 1.1.0
    Storefront Product Sharing: von WooCommerce – 1.0.6
    
    ### Dropin Plugins (1) ###
    
    advanced-cache.php: advanced-cache.php
    
    ### Settings ###
    
    API Enabled: –
    Force SSL: –
    Currency: CHF (CHF)
    Currency Position: left_space
    Thousand Separator: '
    Decimal Separator: .
    Number of Decimals: 2
    Taxonomies: Product Types: external (external)
    grouped (grouped)
    simple (simple)
    variable (variable)
    
    Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
    exclude-from-search (exclude-from-search)
    featured (featured)
    outofstock (outofstock)
    rated-1 (rated-1)
    rated-2 (rated-2)
    rated-3 (rated-3)
    rated-4 (rated-4)
    rated-5 (rated-5)
    
    Connected to WooCommerce.com: ?
    
    ### WC Pages ###
    
    Shop-Basis: #6 - /shop/
    Warenkorb: #7 - /warenkorb/
    Kasse: #8 - /kasse/
    Mein Konto: #9 - /mein-konto/
    Allgemeine Gesch?ftsbedingungen: ? Seite nicht festgelegt
    
    ### Theme ###
    
    Name: Storefront Wgs
    Version: 1.0.0.1566495180
    Author URL: https://woocommerce.com/
    Child Theme: ?
    Parent Theme Name: Storefront
    Parent Theme Version: 2.5.3
    Parent Theme Author URL: https://woocommerce.com/
    WooCommerce Support: ?
    
    ### Templates ###
    
    Overrides: –
    
    ### Action Scheduler ###
    
    Complete: 682
    Oldest: 2019-12-09 21:07:14 +0000
    Newest: 2020-01-09 20:25:05 +0000
    
    Pending: 1
    Oldest: 2020-01-09 21:22:43 +0000
    Newest: 2020-01-09 21:22:43 +0000
    
    Canceled: 0
    Oldest: –
    Newest: –
    
    In-progress: 0
    Oldest: –
    Newest: –
    
    Failed: 0
    Oldest: –
    Newest: –
    
    

    If you move the remove/add actions outside of the child_theme_replace_header_search() function does it work then? It may be some conflict in the init add_action that is causing it to not work. When testing on my local default install its working for me.

    Thread Starter hardynet

    (@hardynet)

    I moved it like this:

    <?php
        remove_action( 'storefront_header', 'storefront_product_search', 40);
        add_action( 'storefront_header', 'replacement_header_search', 40 );
    // Exit if accessed directly

    but i still have the product search

    Interesting, did you try deactivating any active plugins and seeing if the code works then? If so, you can reactivate each plugin one by one to find the culprit then.

    HJ

    (@coach-henk)

    This was discussed in this forum post. Works like a charm.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Replace Product Search with WordPress Search’ is closed to new replies.