• Resolved Sam

    (@sammazza)


    I want to write a hook s for woocommerce_template_single_add_to_cart.
    I have already written some other hooks that work nicely mostly for a child theme.
    As far as I understand one can write hooks for woo/functions that are in the template directory by duplicating the folder structure.

    But this function in woocommerce-template.php located in the template directory. I have tried to hook it and it does not work. I had heard that function in the woocommerce folder are not hook-able.

    Nevertheless the documentation (https://docs.woothemes.com/document/hooks/ second hook from top)

    says that is his hook-able. So how is this done?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You cannot hook just any function, the function must provide access to your hook function by calling either apply_filters() or do_action() (or one of the ref_array variants). If that is done, it usually doesn’t matter much where you add your hook function, all code loaded for any particular request shares the same name space. What folder structure is used has nothing to do with it.

    Folder structure has some bearing on implementing child themes. It has nothing to do with plugins. Each plugin does it’s own structure, any interaction is through the common name space.

    Your linked reference says it is a complete list of all hooks and actions for woocommerce. ‘woocommerce_template_single_add_to_cart’ does not exist on that list, which would explain why you cannot hook into it. You need to find a way to do what you want with only the tags listed.

    Thread Starter Sam

    (@sammazza)

    Thank you for that. Just a few minutes ago, I was able to resolve this issue. Your explanation is on the stop.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hooks for wooCommerce’ is closed to new replies.