• Resolved Dani

    (@danimzyec)


    Hello,

    I’m using Astra as a child theme and also WooCommerce plugin.

    When I access to the Shop page, I want to check if the user is logged in and the role is “Example”. If conditions are true, I want to filter the products before loading the page and only show the article with an attribute with the “User” = “Example”.

    How can I modify it? I think that the easy way is to use a custom plugin or functions.php file. In the second option, if I need other changes, I could create a specific file and load it in the funtions.php and use this file to group all the changes in one specific file, like a “page-shop.php”.

    I don’t know how I can modify it.. using hooks or if It’s a good way to copy the template and editing… I think that the 2nd way is not the best one… Which one do you recommend? If there is another better way, I really appreciate it if you could explain it.

    If I wanted to modify a lot more things on the page, should I overwrite the template? I’m a bit worried about doing that because I think that if there is something new in new versions (kind of security topics) I won’t have them, is that correct?

    So, I have two questions. I don’t know the best way to execute it and also, the code to check the user and filter the products.

    Thanks you so much!

    • This topic was modified 1 year ago by Dani.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @

    Thanks for reaching out!

    When I access to the Shop page, I want to check if the user is logged in and the role is “Example”. If conditions are true, I want to filter the products before loading the page and only show the article with an attribute with the “User” = “Example”.

    If I understand you correctly, you would like to filter the products on your site based on the user’s role, right?

    If so, the premium extension Products Visibility by User Roles manages the catalog visibility based on user roles. This extension enables you to hide products and categories for specific user roles. You can manage visibility for multiple user roles, and display a custom error message or redirect to another URL when a user tries to access a restricted product or category.

    You can also manage visibility for guest users, and choose to allow/disallow Google to rank the restricted pages. The products will remain hidden from shop, categories, search, and other listing pages.

    You can learn more about the extension on this support documentation: https://woo.com/document/products-visibility-by-user-roles/

    In addition, kindly be informed that if you want to try our products, it comes with a 30-day refund policy. If the product doesn’t work the way you need it or you think another product would work better, we are more than happy to offer a full refund. You can read more about our refund policy on our website here.

    As per your other concern with regards to custom coding and overwriting of templates, you are correct that this is not the best option, not unless you are confident enough to this, or else, hire a developer to do it for you.

    Hope this helps!

    Thread Starter Dani

    (@danimzyec)

    Thanks you so much for your answer!

    I don’t want to use any plugin, because I’m going to do many other changes.

    Now, after some researches, I understood that I need to copy the template and modify it. I need to add a table, new ways to define the different prices and so on.

    Could you please, tell me how I can know when I need to update my new page with the changes you could have done in a new version? I mean, after I copy and modify the template, you release a new version. How can I know that you did a modification on the template and I need to add in my new page?

    Thanks!!

    Hi @danimzyec

    When you override WooCommerce templates in your theme, it’s important to keep track of updates. Each template file has a “Version” number in the header comments. This is the version of WooCommerce that the template file is compatible with.

    When WooCommerce is updated, you should compare the version numbers of your overridden templates with the version numbers of the templates in the updated WooCommerce plugin. If the version number in the plugin is higher, that means the template file has been updated.

    You can find these updates in the WooCommerce > Status > System Status > Templates section of your WordPress admin. Overridden templates are highlighted in red and you can view the version difference there.

    Please remember to always make a backup of your website before updating templates or the WooCommerce plugin to prevent any loss of data.

    Furthermore, you can also check the changelog here for your reference.

    Hope this helps!

    Thread Starter Dani

    (@danimzyec)

    Perfect, thanks you!

    Hi @danimzyec

    We’re glad that we’re able 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/

    Thread Starter Dani

    (@danimzyec)

    Done! ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Editing Shop page WooCommerce’ is closed to new replies.