The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

[Foxyshop] Function to test if "is_foxyshop"?

KerriKerri Member
in Help edited April 2012
Hi there,
I'm using the foxyshop Wordpress plugin to add a store onto a site using an existing custom template. I'm trying to avoid re-doing what already exists and make this work. Problem: my headers/footers/css styles are conditional based on whether any page/slug is a "page" or blog "post" (using functions like "is_page()", "is_front_page", "is_home()", etc). I need all of the foxycart screens to be rendered as if they are "pages", but wordpress considers them "posts", so my theme is currently calling up the wrong set of design elements. I can write in a test for post_type equalling "foxyshop_product", but that's only good for individual products, and I need to capture any page that is foxyshop-related (e.g.

Summary: Is there any way or function to test for "if is any foxyshop-related page"? Thanks!
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Hi Kerri, this is something that I have needed a few times and I have always sort of danced around the actual issue by doing some convoluted conditionals. Your idea is great, though. That would be really helpful to be able to have a simple function that would determine whether you are on a FoxyShop page. So here's what I've done: I've updated the template redirect file and I'm setting a new value in the $wp_query object called is_foxyshop on the appropriate pages. To get what you are looking for, you'll want to put this at the end of helperfunctions.php:
    function is_foxyshop() {
    	global $wp_query;
    	return $wp_query->is_foxyshop;

    And then replace your templateredirect.php with this one: Or if you'd rather just update the whole plugin email me at web -at- sparkweb (dot) net and I'll send you all the files at once. Thanks for the great idea.

    For anyone finding this in the future, this feature will be built into FoxyShop 4.1.4+
  • KerriKerri Member
    As always, your responsiveness is amazing! Thanks so much!
  • KerriKerri Member
    edited May 2012
    OK, one issue: Do you have any inkling as to why this function only seems to work in my header.php file, but not sidebar.php or footer.php (and additionally, functions.php)?
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Kerri, you are right. After working with this some more, the $wp_query object is being reset somewhere along the way. I've switched this to a constant and it works properly now. I've updated 4.1.4 at the repo with this change. You can either update to 4.1.4 if you haven't yet or just grab this and get helperfunctions.php and template_redirect.php out of it and replace them in your FoxyShop folder. Thanks for the head's up.
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Something else I should note: this function won't work until after the 'template_redirect' action has been run. So if you are going to test for this in functions.php, you should put it in an action set to run on maybe wp_head. Here's the WordPress action reference:

    You could actually use template_redirect itself since the FoxyShop function runs first. This would work:
    add_action('template_redirect', 'your_test_function_name');
    function your_test_function_name() {

  • KerriKerri Member
    Thank you! Your responsiveness is the best!
  • Excellent! I used this with a custom menu to add the "current-nav-item" class to a menu item titled "Shop" so that it is always highlighted when users are on any FoxyShop related page. Thank you David!
Sign In or Register to comment.