Foxy Forum Status

We're no longer responding to questions via our forum, but we will keep it up for historical reasons. If you can't find the answer you're looking for, please visit our knowledge base or contact us. If there's enough interest in the future, we may bring the forum back.

FoxyShop customizing helper functions

ethanmillerethanmiller Member
in Help edited September 2014
In order to implement a store design I need to modify the appearance of the variation option menus that are native to FoxyShop. These variations menus are generated in the `foxyshop_product_variations()` function in FoxyShop's helperfunctions.php file. The situation I am encountering is one in which I'm having to modify after-the-fact the html content that this function generates. It's very hacky! Is there a best-practices method for customizing FoxyShop's helper functions so that I don't break things for future updates?
  • brettbrett FoxyCart Team
    @sparkweb, could you chime in on this one?
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk

    Hi, I'd be happy to help. Could you show me an example of what kind of updates you are making? In general the best-practice is to build a filter and store it in your functions.php file, but there aren't really filters available on the variation selects. Tell me what you are looking for and I'll see what is available in terms of filtering or perhaps, if appropriate I can add some filters to the core for you.

  • Hi @sparkweb, I've now forgotten what specifically it was that I wanted to do. I think I worked around it somehow. But the problem has come up any number of times. The issue is very plainly that there keep occurring cases in which I need to change slightly what these functions output. For example, just now I needed to have the image dumped out be of a large resolution. Or I need to add a class for my own purposes. In some cases, these things could be handled by adding parameters to these functions that allow users to, say, specify a class that is added or something like that. Not sure what the right solution is. Just keep encountering this problem. My use-cases exceed what the design allows.
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Hi Ethan,

    Right, I see what you are saying. I've tried to put filters all throughout the code to places where you might want to edit something. If you do find that there's a particular function that needs more editing than the filters allow, you can copy the function, put it in your functions.php file, and rename it like "my_xyz_function" -- then you can just call that function instead of the FoxyShop one. This allows you to upgrade a lot more safely.

    I need to be careful with function arguments because they can get out of control pretty easily, but if you have some filter suggestions please let me know and I'd be happy to consider adding them.

    Thanks for the good feedback,
  • Got it that makes sense!! I think one obvious one that would help would be the ability to add additional classes, say, to the image items. It would also be nice to be able to control the size of the image that is loaded. I'll think on this a bit more and get back to you if I have other ideas.
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    @ethanmiller, whenever I need to customize the foxyshop_build_image_slideshow() function very much I just build it out directly on my product page. It's there for convenience, but doesn't hold a lot of logic so it's fine to do that. Then you can set your own file size. The file size on the category get set by editing the template itself.
  • @sparkweb got it. thanks!
  • @sparkweb one thing i'm definitely noticing as a i build out our store with FoxyShop is that many of the helper functions would be much more useful if we could add options to modify what html is returned -- options that, for example, would allow one to add a class or other relevant modifications where they are relevant. an example of what i'm talking about is built into, say, the `the_post_thumbnail` function of WP. See here:
  • @sparkweb, actually maybe i'm just missing the point of the way you've set this up. the helper functions return very basic content. the idea is that we build our own html around that...
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    @ethanmiller, right - either that or in some cases (like related items) you can use WP filters to edit the returned value.
Sign In or Register to comment.