Back to Documentation

Function Reference

Javascript Considerations

FoxyShop uses several jQuery libraries. If you are already using these libraries it is suggested that you disable the FoxyShop versions to avoid conflicts.

FoxyShop uses the latest stable jQuery release from the Google CDN. If you are already using a different version of jQuery, you can uncheck the “Automatically Insert jQuery” option on the settings page. Note that FoxyShop uses WordPress’s enqueue method so it won’t conflict with any other plugins which are using jQuery includes “the right way.”

Foxyshop uses PrettyPhoto 3.1.2 for slideshow display. If you want to use your own gallery plugin that is just fine. To disable, look in foxyshop-single-product.php.

Foxyshop uses Uploadify 2.1.4 for custom file upload. If you are already loading Uploadify on a site-wide basis, comment out the include lines in foxyshop-custom-upload.php in your theme file. Uploadify is also loading swfobject 2.2 so that might have to be commented out as well.

Helper Functions

The helperfunctions.php file is located in the plugin folder and has all the functions that make FoxyShop so easy to use. I’ll describe each function here and give you some tips and tricks.

If there is anything that you really want to change in the core, please contact me and let’s talk. I want to make this developer friendly and I’ll figure out a way to help you get what you are after.


This simply loads in the FoxyCart includes to the head of your document. If you haven’t entered your FoxyCart domain yet on the settings page, this won’t load at all and shopping cart links and forms will act screwy if you try to submit them.


Within the loop or any other time you need to access a product, call this function and it will get all the product data and load it into an array. It also loads all associated images into a sub-array of $product['images'] and variations into $product['variations']. Weight and sale prices are also calculated in this function. It’s nice not having to do this stuff manually all the time.


This function initializes the form and sets all the hidden values that are needed.


This function loops through all the variations and shows the proper type of field. It’s easily the most complicated section of the code. For your sake, I hope you don’t have to mess with it. The next two functions are part of this one: foxyshop_run_variations() and foxyshop_add_spaces().

You can pass in the location of the Quantity Box (above, below, or hidden), whether price variations should be shown, and any special code you’d like added above or below each variation. By default, there’s no wrapping div around each variation and each includes a clearing div at the end. You can easily overwrite this if your markup doesn’t like the clearing div’s.


Returns the “Multiple Ship To” fields if that feature is turned on. Note that this references a javascript file in the plugin folder to do the magic cookie and display stuff.


Returns the quantity box or dropdown box with appropriate values filled in. It is usually called by foxyshop_product_variations() but you can call it yourself if you so desire.


This creates an “add to cart” link for any product. Just pass in the link text (you can use %name% as a replaceable string if you like). If you just want a link, set the second parameter to true. The third parameter allows you to pass in variations as an array or serialized (“color=Green&size=Large”).


This function returns your price and sale price if applicable. The class names are important so that the variation processor javascript can update the price when a dropdown is changed.


This is a handy function if you want to know whether the product is currently on sale or not. It simply compares the price and original price. Returns true or false.


This function accepts a number (14 by default) and will return true if the product is newer than x days.


Returns the url for the main image. If there is a featured image, it pulls that one. If not, it uses the first image it finds. If no image is found it returns /wp-content/plugins/foxyshop/images/no-photo.png. Feel free to change this file (or the location) if you want. By default, the function will return the thumbnail size, but you can pass in any size: thumbnail, medium, large, or full. You could even pass in id, title, or featured if you wanted to get those details.


If there is more than one image, this function will write an unordered list (class: foxyshop_slideshow) with all the images. By default it pulls the thumbnail and links to the full image. If you prefer, you can pass in a different size for the actual image returned but it will always link to the full. Also, it will include the featured image by default (true) unless you ask it to skip the featured image since it is already shown above. If using ikey’s, it’s going to force this parameter to be true.


This function writes out all the child categories for the parent (or top level if nothing is passed in). This automatically checks for images being used by the Taxonomy Images plugin.


Write’s a simple unordered list of all your categories. You can set the depth as well. This is similar to wp_list_categories() except that it uses the custom FoxyShop ordering so your category ordering is honored. The foxyshop_category_writer() function is part of this process as well.


Creates the hashes and encryption on each form element to prevent link tampering. Will skip if the FOXYSHOP_SKIP_VERIFICATION cosntant is defined in your wp-config.php file. Disabling the verification is discouraged, though. You should have a good reason if you do this.


This code wins second prize for most complicated. Hope you don’t have to mess with it! Note that you can pass in a separator. By default it uses right angled double brackets: ». It’s also worth noting that if a product is in multiple categories it will search the page referrer for a parent category. If there’s no match it simply show the breadcrumbs for the first matched category it finds.


This function is used on the single product page to check the inventory levels of any product codes for which inventory has been set. You can pass in the specific wording you want to use and also set whether backordering should be allowed or whether the add to cart button should be disabled if there is no stock.


Simple function to return whether the main product code is in stock, out of stock, or on stock alert.


This function writes out a list of products for any one category. It’s used by the FoxyShop Category Widget or can be called independently if widgets aren’t really your thing (and if you’ve made it this far, I’m betting they’re not). Parameters are the category name (slug), an option to show an Add To Cart Button, an option to show a More Details button, and a maximum number of entries to return which defaults to unlimited (-1).


This function writes out the formatted FoxyCart link to launch the shopping cart in a modal window. It accepts two arguments: link text and an option to hide the link if the cart is empty. Link text can be written with the variables %q% for quantity and %p% for price. These will be updated on the fly by FoxyCart which is pretty slick.

if (function_exists('foxyshop_cart_link')) foxyshop_cart_link('View Cart');


This is called from the bottom of the main product page and returns a list that shows all of the products attached to the parent product when setting it up. Pass in the title of the section as well as the maximum number of products. The default maximum is 5 and will only be used when doing related products by tag. If you have manually attached 30 related products, they’ll all show up. foxyshop_related_order() is used by this function.


Returns an array with the sort order selections. This array can be merged into the query on applicable theme pages.


Can be called on the single category template to allow the customer to order the products on the fly.


This includes the store header and footer files.


This function checks the stylesheet path, the template path, and finally the FoxyShop plugin themefiles path for theme files. This is what makes the custom theme files work.


Lets you easily display a customer’s order history.


Is a subscription active? Looks for the current user and checks a product code to see if a subscription is active. Helpful for subscription management and quickly telling whether a user should have access to a particular area.


This is a native pagination function written by Robert Basic. Huge props to him as it works amazingly well.


Taking care of all the currency conversion dirty work in one place. Note that Window’s doesn’t support money_format or localized currency symbols so the $ and £ are hardcoded in if you are using Windows. If you need more currencies, let me know.

Back to Documentation