Support » Theme: Storefront » Guide for removing actions with Storefront 2.5.0

  • Resolved klewis

    (@blackawxs)


    I’m running…
    * WordPress 5.2.1
    * WooCommerce 3.6.4
    * StoreFront 2.5.0

    I have a child theme set in place for storefront. The child folder is labeled as storefront-child, and its activated.

    I see that the storefront hooks are all located on inc/storefront-template-hooks.php

    When I attempt to copy them over to my functions.php file and do a remove_action(...) for each one, nothing changes on my website. For example this…

    /**
    * Homepage
    *
    * @see storefront_homepage_content()
    */
    remove_action( ‘homepage’, ‘storefront_homepage_content’, 10 );

    Does nothing. I still see my storefront (home page) content.

    Is this a major bug, or am I missing something…?

    Thanks

    • This topic was modified 1 year, 11 months ago by klewis.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Same here.

    remove_action( 'homepage', 'storefront_popular_products', 50 );
    remove_action( 'homepage', 'storefront_best_selling_products', 70 );

    These two hooks are not effective (not removing the sections).

    Eagerly waiting for the answer.

    • This reply was modified 1 year, 11 months ago by champdor.

    Hi there @blackawxs & @champdor,

    Just out of curiosity first here, are your homepages still using the Homepage template or would they be converted over to using blocks?

    https://cld.wthms.co/00EMBb

    ^ See this video for an example that is now used as the Storefront homepage instead of the Homepage template. Those are all blocks and wouldn’t be effected by the actions. You can confirm by looking at the Page Attributes section and the Template would say Full width instead of Homepage.


    Link to image: https://cld.wthms.co/1g2BMC

    Of course I use the Homepage template since there was no warning that it will not work properly. So the old hooks are not compatible with 2.5 Homepage template?

    Yes I know I can rebuild the homepage with Gutenberg and take control over the content but I was hoping that I can spare the extra work.

    Thanks anyway.

    Thread Starter klewis

    (@blackawxs)

    @ryanr14, in my case, with a clean install of Storefront, WooCommerce and WordPress, it does not matter what is selected for the template attribute. The ability to remove_action() from a child location of functions.php file or a child location of inc/storefront-template-hooks.php, does not work.

    • This reply was modified 1 year, 11 months ago by klewis.
    Thread Starter klewis

    (@blackawxs)

    So I think it boils down to this…within the functions.php for Storefront 2.5.0, the following required files fail to work in child themes:

    	require 'inc/woocommerce/storefront-woocommerce-template-hooks.php';
    	require 'inc/woocommerce/storefront-woocommerce-template-functions.php';
    	require 'inc/woocommerce/storefront-woocommerce-functions.php';
    

    – In code, I commented out all 3 required files.
    – From wp-admin, I then enabled the homepage template attribute on my Gutenburg Homepage. This allows me to control the look and feel directly from blocks.
    – One flaw I see it gives Customizer no “extending” power for the homepage.

    IMHO, I would rather have customers manage homepage features in the Customizer over Gutenburg blocks any day. This will allow developers to extend additional Customizer fields for them when needed from the back-end.

    On the flip side, I can see how blocks can help out clients who would like to manage there homepage. They then would not need to go into Customizer for that reason, but! they will need to go into Customizer for other reasons anyway!

    I’m done rambling. So what is the direction? Was this a major bug or intentionally depending on blocks moving forward?

    • This reply was modified 1 year, 11 months ago by klewis.
    • This reply was modified 1 year, 11 months ago by klewis.
    • This reply was modified 1 year, 11 months ago by klewis.
    • This reply was modified 1 year, 11 months ago by klewis.
    • This reply was modified 1 year, 11 months ago by klewis.
    Thread Starter klewis

    (@blackawxs)

    With a little more testing, when I am in my child theme and I switch my homepage layout away from ‘Homepage’ and use ‘fullwidth’, I see that I am now able to override the storefront-woocommerce-template-hooks.php in my child theme. But the storefront-template-hooks.php do not work at all.

    I believe this is the core issue I am facing for Storefront 2.5.0

    • This reply was modified 1 year, 11 months ago by klewis.
    • This reply was modified 1 year, 11 months ago by klewis.

    Hi @champdor & @blackawxs,

    I was just curious if your homepages were using blocks yet, as then obviously the homepage template hooks wouldn’t help you out any. 🙂

    I would definitely recommend considering using blocks moving forward, and I know it might be not ideal via the customizer but that will change in time. Block editing will be everywhere in WordPress at some point!

    Nonetheless, if you’d prefer to use the Homepage template compared to blocks you need to wrap your remove_action() in a function of some sort and hook it into ‘init’. Take the following snippet and tweak to your needs to remove what you’d like to remove from the Storefront Homepage page template.

    
    function remove_actions_parent_theme() {
    	remove_action('homepage', 'storefront_homepage_content', 10);
    	remove_action('homepage', 'storefront_product_categories', 20 );
    	remove_action('homepage', 'storefront_recent_products', 30 );
    	remove_action('homepage', 'storefront_featured_products', 40 );
    	remove_action('homepage', 'storefront_popular_products', 50 );
    	remove_action('homepage', 'storefront_on_sale_products', 60 );
    	remove_action('homepage', 'storefront_best_selling_products', 70 );
    };
    
    add_action( 'init', 'remove_actions_parent_theme', 1);
    

    Also, the numbers ranging from 10-70 are important as well. Those are priorities of when the action will fire. So if you changed say remove_action( 'homepage', 'storefront_on_sale_products', 60 ); and used a number smaller than 60. The remove_action() would fire before the actual action that adds that section. Thus it would still show up for you.

    I hope that helps, if you’d like to see more hooks check out this guide.

    Thread Starter klewis

    (@blackawxs)

    @ryanr14 perfect! Thanks for helping out in solving this process. Moving forward, I’ll do my best to accommodate to block use sense that is the long term direction.

    Thanks again!

    @blackawxs

    Very happy to help! I hope the block editor grows on you as it matures and gets better. Thanks for being willing to give it an honest try at the least. 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Guide for removing actions with Storefront 2.5.0’ is closed to new replies.