• Resolved edwardsmark

    (@edwardsmark)


    this is probably (yet another) dumb question, but according to the documentation the way I interpreted it, all the add_filter(0) code is supposed to go into the child theme function.php script.

    so i am currently putting all of my custom code into:
    /wp-content/themes/astra-child/functions.php

    is this correct? i am assuming if we happen to change themes, this code would need to be migrated to the new theme function.php script.

    or is there a special wooCommerce function.php script its supposed to go into? perhaps one of these?

    ./wp-content/plugins/woocommerce-product-addon/inc/functions.php
    ./wp-content/plugins/woocommerce/src/StoreApi/functions.php
    ./wp-content/plugins/woocommerce/src/Blocks/Domain/Services/functions.php
    ./wp-content/plugins/woocommerce/packages/action-scheduler/deprecated/functions.php
    ./wp-content/plugins/woocommerce/packages/action-scheduler/functions.php

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello edwardsmark

    Thank you for contacting Woo support.

    May I ask which documentation you are referring to?
    Usually, if there is something that requires coding knowledge, we put a note in the docs that you may need to consult a professional developer.

    Also, custom coding questions are not covered by our support policy.
    But I will be happy to provide general guidance.

    1- To use a child theme’s function.php file for placing custom code, you must activate the child theme and set it as your active theme.
    2- If you happen to change themes, you will also need to migrate the code from the first theme’s function.php to the new theme’s function.php file.
    3- There is no special function.php in the WooCommerce plugin to place your custom code.

    There is a plugin called Code Snippets that allows you to place custom code directly in the WordPress dashboard. I suggest you also look into that.

    I hope this helps. ??

    Best regards.

    Thread Starter edwardsmark

    (@edwardsmark)

    >>>May I ask which documentation you are referring to?

    according to:

    https://woocommerce.com/document/introduction-to-hooks-actions-and-filters/

    custom actions and filters go into the child theme functions.php file.

    >>> Usually, if there is something that requires coding knowledge, we put a note in the docs that you may need to consult a professional developer.

    sorry, i should have explained that i have successfully added a custom action to the functions.php file. so i am verifying this indeed is still correct to add it to the child functions.php file.

    it just seems like a strange place to add custom code. when the theme is updated, or we change themes, we would need to be very careful not to lose the code.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @edwardsmark

    is this correct? i am assuming if we happen to change themes, this code would need to be migrated to the new theme function.php script.

    Yes, you are correct. Custom actions and filters should indeed be added to your child theme’s functions.php file. This is the standard WordPress practice, and it helps to ensure that your customization don’t get overwritten when you update your theme.

    However, you’re also correct in noting that if you change themes, you’ll need to manually migrate your custom code to the new theme’s functions.php file. This is something to keep in mind when you’re considering changing themes.

    Alternatively, you might consider using a plugin like Code Snippets, which allows you to add custom code directly from your WordPress dashboard. This can be a safer and more convenient way to manage custom code, as it’s not tied to your theme.

    I hope this clears up any confusion. If you have any other questions, feel free to ask!

    Thread Starter edwardsmark

    (@edwardsmark)

    code-snippits – excellent suggestion thank you.

    Hi @shameemreza,

    We’re happy to help!

    If you have a few minutes, we’d love if you could leave us a review:?https://www.ads-software.com/support/plugin/woocommerce/reviews/

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘location of add_filter custom code’ is closed to new replies.