Frequently Asked Questions
Functionality
Where can I find my products?
FoxyShop uses URL rewrite to create pages for all your products and categories. Products are found at http://yoururl/products/product-slug/. Product categories can be found at http://yoururl/product-cat/. A list of all products can be found at http://yoururl/products/.
How can I change the look of the product pages?
Copy the files from the ‘themefiles’ folder inside the plugin into your theme directory or child theme directory. You may now edit these files and upgrade safely. It’s recommended, though, that you only move the files you are intending to edit. Read more about customization.
What are the FoxyShop system requirements?
-
PHP 5.1.2 or higher
-
WordPress 3.0 or higher
-
FoxyCart 0.7.0 or higher
Can I import my products?
FoxyShop works very nicely with the CSV Importer plugin. Click here for a sample import file and lots of tips for a successful import.
Can I add products and categories to my WordPress menu?
Yup! Just browse to your menu screen and press the “Screen Options” button at the top of the window. Click “Products” and “Product Categories” and now these two boxes will show up in the menu sidebar. Just add to your menu and drag to sort. If you want to add /products/ or /product-cat/ to your menu, you’ll have to add these as special custom links.
Can FoxyShop be used as a catalog without FoxyCart?
Yes. If you don’t enter anything in the FoxyCart domain field the FoxyCart includes won’t be added. You can then edit your foxyshop-single-product.php template and comment out the Add To Cart links.
How do I sell downloadable products?
FoxyCart supports downloadable products directly (there’s a 250mb limit per file). Setting this up is a two-step process.
- Upload the file to the FoxyCart downloadables section and assign a product code to each one.
- In FoxyShop, add the products with the product code to match the uploaded product.
Make sure you set up a shipping category for downloadables on FoxyCart and a corresponding FoxyShop shipping category as well. You can setup FoxyShop shipping categories on the settings page.
Any other suggested plugins?
Sure! There are a few plugins that work well will FoxyCart and bring some advanced functionality:
- The Duplicate Posts plugin works great for letting you quickly copy products.
- The Taxonomy Images plugin will let you easily add product category images.
- The Cimy User Extra Fields plugin extends the functionality of the WordPress user registration system.
- The Custom Field Bulk Editor lets you edit a bunch of products at once. Here are some tips.
- The Capability Manager makes it easy to manage roles and capabilities if you want to create different types of users who can do different things (think wholesale).
Can I change the slug from ‘products’ to something else?
Sure! Just put this code in your wp-config.php file:
define('FOXYSHOP_PRODUCTS_SLUG','yourproductslug');
define('FOXYSHOP_PRODUCT_CATEGORY_SLUG','yourproductcategoryslug');
Here’s a full list of these advanced customizations.
Can I use a WordPress Framework with FoxyShop?
FoxyShop uses get_header()
and get_footer()
and some WordPress frameworks (Thesis, Yoo, Headway) bypass these default WordPress functions. So without customization, FoxyShop pages will show up unstyled for these frameworks. A workaround is to put a static version of your site in the header.php and footer.php or to use the product shortcodes to place products on pages.
Here are some working code samples for various Frameworks:
Do I have to use the FoxyShop datafeed?
Of course not, but if you want any of the functionality provided by the FoxyShop feed or need to build your own it is very helpful. And if you have more than one integration that needs to use the datafeed, there’s a feature in the datafeed template file which will let you load in as many third-party datafeeds as you want. The FoxyData will be fed to each of these each time FoxyCart sends data to your endpoint. If there’s an error, you’ll get an email with the exact error details.
Is QuickBooks integration available?
Yes! Check out the ConsoliBYTE’s QuickBooks connector service. For $10/mo they will feed your orders directly into QuickBooks.
Is there any UPS integration?
I’ve written some code which will allow you export orders from the order admin. It creates a XML file which you can then import into WorldShip. Just paste this code into your functions.php file: http://pastebin.com/qYj0aMvT
Use FoxyCart Account on Two WordPress Installs
Your FoxyCart account can be used on two WordPress installs. Because FoxyShop assigns an API key, however, you’ll need to do a settings dump from WordPress install to the other. Go to the FoxyShop tools page on your main site and export the FoxyShop settings by copying the encoded settings string. Then go to the FoxyShop tools page on your new site and import the settings string by pasting it and clicking Import. Your old settings along with the FoxyShop-assigned API key will now be loaded on your new site.
Troubleshooting
When I add a product to the cart, I get two carts and the product adds twice
This is actually a pretty common problem and is caused when there are two sets of FoxyCart includes in the header. FoxyShop puts a set in, so just go into the header and remove the set you put in manually.
My product pages just show up as a 404.
Make sure that your permalinks are set to Month and Name or Day and Name. Sometimes you may need to flush your permalink settings to get new values to show up. To do that, just save your permalink settings again and the rewrite rules will be rewritten.
The plugin ‘Bad Behavior’ breaks my add-to-cart forms
This plugin adds a hidden form input to every form. This breaks validation and adds junk to your FoxyCart checkout form. The easiest way around this is to add this piece of code to your functions.php file. This will keep the code from being added to any FoxyShop pages (product pages and category pages).
add_filter("wp_head", "foxyshop_bb_fix", 1); function foxyshop_bb_fix() { if (!defined("IS_FOXYSHOP")) return; global $bb2_javascript; $bb2_javascript = ""; }
I’m getting a “Not Set Up” alert box on every page
If you are receiving a JavaScript alert box that your store is not fully setup on every page of your site, this means that your store has not been fully set up in your FoxyCart admin. You need to make sure to add a product category, setup a default payment method (testing), add the default FoxyCart template for cart and checkout, and the default email settings. This just takes a few minutes and will make this warning go away. If you just want to make the warning go away immediately, you can temporarily remove the domain in the FoxyShop settings page and this will keep the FoxyCart includes from being placed in your header. Click here for setup instructions from FoxyCart if you get lost during the process.
I’m clicking “Add to Cart” but nothing is being added.
Make sure that your FoxyCart domain is set properly and that your API key has been copied to the FoxyCart admin. Additionally, make sure that you have checked the Cart Validation checkbox in the advanced settings tab of the FoxyCart admin.
Image Upload Problems
If you are getting an error when uploading an image through the FoxyShop Image Manager, here are a few things to look at:
- Make sure that your permalinks are set to Month and Name or Day and Name.
- Flush your rewrite rules – there’s a button to do this on the FoxyShop tools page.
- Make sure that your image upload folder is writeable. There will be a warning in your settings page if this is the problem.
- On the WordPress General Settings page, make sure that the WordPress Address and Site Address have the same base url. If one is www and the other isn’t, you’ll get security errors.
- Check your SecFilterEngine and SecFilterScanPOST settings from this page.
- Are you in Maintenance Mode? If so, you need to exclude your image upload url path. More info here.
- If all else fails, you can upload your images through the standard WordPress upload feature to attach the media item to the product.
Trouble With Local Currency
If you are having trouble setting your local currency, you can use WordPress filters found in FoxyShop 3.4+ to override the defaults with your currency setting. Here’s an example for replacing EUR with €.
add_filter("foxyshop_currency", "force_euro_currency"); add_filter("foxyshop_form_l18n", "force_euro_currency"); function force_euro_currency($str) { return str_replace("EUR", "€", $str); }
Additionally, many locale lists are now using “en_US.utf-8” or “en_GB.utf-8”. If the currency fields aren’t working, be sure to check with your host for the proper locale code for your system.
You could try something like this in your funtions.php file
setlocale(LC_MONETARY, 'en_US.utf-8');
Please note that WP-Engine uses .UTF-8
at the end of all their locale codes.
I’m using Windows and the Permalinks aren’t working
Windows IIS hosting has some quirks and often requires that index.php be part of the url. This can be fixed by putting this in your wp-config.php.
define('FOXYSHOP_URL_BASE','/index.php');
It’s also worth noting that Windows doesn’t handle currency formats the same way as Linux so the $ or £ are hard-coded into the system. If you need another currency, send in a support request with the info.
Helpful Code Snippets
Remove Rewrites and Automatic URL’s
If you want to remove all template redirect rewrites, the following code placed in your functions.php file should take care of it for you (since version 4.2).
remove_action('template_redirect', 'foxyshop_theme_redirect', 1); add_filter('foxyshop_register_post_type', 'my_foxyshop_register_post_type'); function my_foxyshop_register_post_type($args) { $args['public'] = false; unset($args['rewrite']); return $args; }
How can I get quantities in a dropdown on the product page?
Here’s some code to help you get quantity ranges (like 10, 50, 100) in a dropdown on the product page. Put this code in your functions.php file. Then in your single product template, change the product variations function to read:
foxyshop_product_variations(0); my_foxyshop_qty();
Add that second function after it. Then you can add your quantity ranges separated by comma in the new “Qty Groups” box on the product entry page.
Add Custom Fields to Products
You can add checkboxes, text fields, or anything else to your product details meta box. Add this code to your functions.php as a starting point.
Open Product Detail Pages in a Modal Window
If you want to open your detail pages in a modal window from the category page, you’ll want to remove the get_header() and get_footer() calls from the foxyshop-single-product.php template file and add this to the jQuery script section of foxyshop-single-category.php. Only tested in 0.7.2.
$(".foxyshop_product_list .foxyshop_product_box a").each(function() { $(this).attr("href", $(this).attr("href") + "?modal=true") }); $(".foxyshop_product_list .foxyshop_product_box a").colorbox(); $("form.foxyshop_product").submit(function() { $.colorbox.close(); });
You may also want to consider adding writing a conditional into the foxyshop-single-product.php template to check for the isset($_GET['modal'])
querystring variable so that direct links to the product pages will still show a nicely formatted page.
Create a Dynamic Link to the Cart
Straight Link:
<?php foxyshop_cart_link('View Cart'); ?>
Writes “View Cart (0) ($0.00)”
<?php foxyshop_cart_link('View Cart (%q%) ($%p%)'); ?>
Hides the Link if the Cart is Empty:
<?php foxyshop_cart_link('View Cart', true); ?>
Show Price Range
Here’s a function which you can stick in your functions.php file to show the price range for a product. The function looks through all the variations for a particular product and checks for high and low prices. When it finishes, it spits out a string like “$15.00 – $19.00”. You can comment out the foxyshop_price() in foxyshop-product-loop.php and put echo my_high_low_price($product);
in its place. Download the code here.
Show a Table of Discounts
Here’s a function that will show your customer a table of discounts that will be applied for quantity purchases. Note that this table is looking for Discount Quantity Amount only.
Remove FoxyCart Includes From a Specific Page
Note, as of FoxyShop 3.9. this feature is built-in. Visit the settings page to manage this.
If you are using FoxyCart’s template caching functionality and want to remove the FoxyCart headers from a specific page (like the checkout or receipt page), paste the following code into your functions.php file:
add_action('wp_head', 'my_remove_foxycart_headers', 1); function my_remove_foxycart_headers() { $no_include_pages = array( 'page-slug', 'page-slug-2' ); if (is_page($no_include_pages)) { remove_action('wp_head', 'foxyshop_insert_foxycart_files'); } }
The $no_include_pages array should list out the slugs or ID’s of all the pages where the FoxyCart includes should not be inserted.
How To Treat Products in Different Categories Differently
Let’s say you want to have a different template for products in different categories. Open up your foxyshop-single-product.php template and enter this code after the product has been initialized:
$product_categories = wp_get_post_terms($product['id'], 'foxyshop_categories', array("fields" => "names"));
Now, you can use some simple logic:
if (in_array('Pets', $product_categories)) { //Special Instructions For the Pets category } else { //Instructions For Everyone Else }
Remove Cents From FoxyShop Price
If your prices are all full dollars and you don’t want to show any cents ($1 instead of $1.00), then you can use the following code snippets to make this happen.
Place this code in your theme’s functions.php file:
add_filter("foxyshop_currency", "my_currency_config"); function my_currency_config($amt) { $amt = str_replace(".00", "", $amt); return $amt; }
Place this javascript snippet in your foxyshop-single-product.php file near the end (not necessary if you don’t use variations):
<script type="text/javascript"> function foxyshop_after_variation_modifiers(new_code, new_codeadd, new_price, new_price_original, new_ikey, current_product_id) { jQuery(".foxyshop_currentprice").each(function() { jQuery(this).text(jQuery(this).text().replace(".00","")); }); jQuery(".foxyshop_oldprice").each(function() { jQuery(this).text(jQuery(this).text().replace(".00","")); }); } </script>
This requires FoxyShop 3.4+ and will only remove the cents if they are “.00” – $1.12 will still display the full price.
Get a JSON Feed From the Product Page
If you would like to be able to get a JSON (or JSONP for that matter) feed of a single product from the product page, you can use this code snippet. Since you’ll lose your modifications when the FoxyShop plug-in updates if you modify the original plug-in file, you’ll want to make a copy of the file themefiles/foxyshop-single-product.php, add the code snippet below to the copied file, then upload the copy to the WordPress folder of your selected theme (typically at /wordpress/wp-content/themes/your-selected-theme).
You’ll insert this at the very top of the file (before get_header()
);
if (isset($_GET['json'])) { while (have_posts()) : the_post(); global $product; $product = foxyshop_setup_product(); $jsonval = json_encode($product); if (isset($_REQUEST['callback'])) { //This creates JSONP wrapper $jsonval = sanitize_title($_REQUEST['callback']) . "($jsonval)"; } echo $jsonval; die; endwhile; }
To access the JSON feed, use the product’s URL plus
?json=1
For example:
https://wordpress.your-site.com/products/your-product/?json=1
Show the computed product code on the product page
Take a look at this bit of code and paste it into your single page template. It will take any new computed code (ex: c+123) and show the complete code in a new div right in front of the price.
Donation Code: Let Users Enter Their Own Price
Read this blog post for how to create flexible pricing.
Mailing List Integration: Code for Mailchimp
If you’d like to let your users sign up to your MailChimp mailing list during checkout, it’s a cinch. Tutorial available here.
Using a Pop-up Calendar as a Variation
If you would like to have a pop-up calendar appear when a date field variation is clicked, here is some sample code to get you started. Put this code in your functions.php file and then put this code in your foxyshop-single-product.php file before the end of the form. You may want to tweak it a little bit, but this will give you a good head start. Some notes:
- WordPress 3.1+ required. If you can’t do that, you can load in the jQuery UI includes yourself.
- Create variation (single line of text) called “Start Date”
- If you want to set a date range, set custom fields on the product called “minDate” and/or “maxDate”. These values can be a date (m/d/y – must use forward slashes) or it can be a number of days(+1, -20, etc) or, it can be a string (+1M +1D). See the jQuery UI Datepicker documentation for more details. Be default it disables all past dates since FoxyCart will reject a subscription starting in the past anyway.
- If you want to exclude certain dates, make a custom field called excludeDates” and add your comma-separated dates like this: “1/1/2013, 2/13/2013, 9/10/2013”.
- If you want to disable all weekends, uncomment the first two lines in getExcludedDates() and comment the third line.
Subscription as a Variation
Here’s some code to allow for a regular product and a subscription product on the same page (chosen by variation). Here’s the basic idea for a delivery service that has different services: weekly, biweekly, or just once:
- Edit the individual product template (source found at foxyshop/themefiles/foxyshop-single-product.php) and put this code into the file, starting on around line 182. Just make sure it goes in before your form ends: http://pastebin.com/Ygu9KRUw
- Put that edited template file in your theme folder
- Create a dropdown variation called “Delivery Frequency” and add values called ”Weekly”, “Every Two Weeks”, and “Once”
- You can change the field name and the wording, but you’ll need to update the javascript to search for your new wording.
If you just want your users to be able to choose between different types (like 1m, 2m, or 3m) use this code: http://pastebin.com/GTCsBjpS
Multiple Receipt Formats
If you’d like to have multiple receipt formats available, just put this code in your foxyshop-receipt.php template file. There are instructions with the code, but you are simply adding a non-printable UL to the top of your template page which will let you choose which template you would like to print. It’s a little ugly and could use some styling but will get you pointed in the right direction.
Add Your Own Custom Functions
If you’d like to add your own custom functions to FoxyShop, here is a bit of sample code to get you pointed in the right direction: http://pastie.org/2306208
This code will add a new button to the Order Management screen which will then process order information. You might also check out the foxyshop_print_invoice() function on orders.php for some more sample code.
Additionally, here’s some sample code for hard-coding in meta values to the admin and grabbing them on the product page. Built for book publishers.
Put the Category Name in the Product URL
If your SEO requirements call for putting the category slug in the product URL, this is possible. Doing this, will break some internal functions and the product View and Preview buttons from the admin will no longer work. First, put this code in your wp-config.php file:
define('FOXYSHOP_PRODUCTS_SLUG','products/%foxyshop_categories%');
This rewrites the slug so that it includes the product category (if you have multiple cagegores, it picks one). Secondly, put this code in your theme’s functions.php file. Your product URL’s will now look like this: http://mysite.com/products/category-parent/category-child/product-slug/.
Password Protect a Product
The default WordPress feature doesn’t work out of the box (here’s why) but a tweak in your template code will get it working nicely. Paste this code into your foxyshop-single-product.php file and you’ll be all set..
Currency Conversion
FoxyCart doesn’t support multiple currencies, but if you want to let your users do their own currency conversion on the product page, here is some code that will help you get started: http://pastebin.com/NmtUB5qP. This script will let the user query Google’s currency conversion tool for the product price. Paste this code in your foxyshop-single-product.php template file. Then, you’ll need to save this code as ajax_converter.php and put it in your theme folder.
SalesForce Integation
If you use SalesForce for your CRM and would like to have your customers be added in as new leads, here is a code snippet to put in your datafeed template: http://pastebin.com/ahFdnUWW. Put this in “custom code to be run for each order” section.
SmartTurn Fulfillment Integration
If you use SmartTurn software for your product fulfillment, there are some code samples to push new orders directly to SmartTurn. You can see it here: http://wiki.foxycart.com/integration/smartturn or check out the FoxyTools Order Desk for automatic integration.
Require that users be logged in before viewing any product pages
If you’d like to make sure that your users are logged in before viewing any product pages you can place the following code snippet in your functions.php file: http://pastebin.com/8B5m1rj9
Capability-Based Pricing
FoxyShop user Jacob Dubail submitted this helpful script for capability-based pricing: http://pastebin.com/ubrQYRAm. This script would go in the functions.php file.