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.

Assigning a new category

UPUP Member
in Bugs & Feature Requests edited May 2011

I have what I think is a fairly simple question regarding categories. Having created a new category, for products with free shipping, how do I apply this to particular products in my store?

I currently have 3 shipping options, for UK, European and US delivery, but I want this new category to provide free shipping to the UK only, for a particular set of products.

Can anyone help me to assign my newly formed category (Free shipping) to the product set when delivering to the UK please?

Many thanks in advance.

  • fc_adamfc_adam FoxyCart Team
    Hey Matt,

    If you were applying free shipping to certain products for any customer from any country, categories would work fine for you.

    As you're only wanting to give free shipping to certain products to people only from the UK, that makes things a little more difficult - but still achievable.

    To answer your first question, to apply a category to a product, you simply add it as a parameter to the form or link. For a form you would just add the following:
    <input type="hidden" name="category" value="CategoryCode" />
    For a link, it would be:

    To achieve what you're wanting though would require a little bit of custom javascript on the checkout - and is different depending if you're using live rates for your normal shipping products or flat rate figures? To get you started though, there as some threads linked to here:
  • UPUP Member
    Thanks for getting back to me Adam.

    I'm using flat rates for shipping. Does it make it any easier if I were to offer free shipping to the UK on any product over £200? This would work just as well for me.

    The site is

    Thanks very much.

  • I'm having issues with categories today as well. I've created a couple of new categories and set up some handling fees but none seem to be working... not even for default items.

    For example, I have a 2.00 handling fee (flat fee per shipment) set for my default category that I know has worked in the past without any problem.

    Now, however, no product in the cart/checkout seems to have fees associated with them - even though DEFAULT is clearly being selected behind the scenes
    "id": "5359306",
    			"name": "Broccoli",
    			"code": "hhnc-84-92",
    			"options": {"type":"alacarte"},
    			"quantity": 1,
    			"price_each": 4,
    			"price": 4,
    			"weight_each": 0,
    			"weight": 0,
    			"shipto": "",
    			"category": "DEFAULT",
    			"sub_frequency": "",
    			"sub_startdate": "0000-00-00",
    			"sub_nextdate": "0000-00-00",
    			"sub_enddate": "0000-00-00"

    This was definitely working as of just a few days ago. Any insight here would be appreciated.
  • lukeluke FoxyCart Team
    @webandflow It looks like the delivery type for that category is a non-shippable delivery type. Handling fees are only for shippable products, though that isn't spelled out very clearly in the admin at the moment. We have an open ticket to fix that.
  • UPUP Member
    Could anyone help me any further on this please?

    I'm using flat rates for shipping. Does it make it any easier if I were to offer free shipping to the UK on any product over £200? This would work just as well for me.

    Many thanks for your help.

  • brettbrett FoxyCart Team
    Hey @UP. @fc_adam can help you figure out the appropriate javascript to use. It shouldn't be too difficult, but unfortunately at this point it isn't a built-in solution so it does require just a little tweaking.
  • fc_adamfc_adam FoxyCart Team

    Could you give me some specifics on how you calculate your shipping? I'd be happy to help you get some code going, but I'll need some specifics before we can start. Perhaps the best approach would be to break down the different categories you'll be having, and how the shipping is calculated for these products, both depending on the products present and the shipping destination.

    Also, how is your handle on Javascript?
  • UPUP Member
    Hi Adam

    Thanks very much for looking into this for me, I wouldn't be able to sort it on my own.

    I used some custom code from the forums to set up my shipping options, as follows (which works great):

    <h1>Choose Delivery Option</h1>
    <div class="fc_row fc_shipping_methods_container" id="fc_shipping_methods_container">
    <div class="fc_radio_group_container fc_row fc_shipping_methods" id="fc_shipping_methods">
    <input type="hidden" value="0" id="shipping_service_id" name="shipping_service_id">
    <input type="text" style="display:none;" value="" id="shipping_service_description" name="shipping_service_description">
    <input type="text" value="" id="shipping_details" name="Shipping_Details" style="display:none;" />
    <div class="fc_shipping_methods_inner" id="fc_shipping_methods_inner">

    <label for="shipping_service_standard" class="fc_radio">
    <input type="radio" class="fc_radio fc_required" value="standard|6.99" id="shipping_service_standard" name="shipping_service" />
    <span class="fc_shipping_carrier">Delivery</span>
    <span class="fc_shipping_service">to Mainland UK</span>
    <span class="fc_shipping_cost">£6.99</span>

    <label for="shipping_service_usa" class="fc_radio">
    <input type="radio" class="fc_radio fc_required" value="USA|49.99" id="shipping_service_usa" name="shipping_service" />
    <span class="fc_shipping_carrier">Delivery</span>
    <span class="fc_shipping_service">to USA (lower 48 States)</span>
    <span class="fc_shipping_cost">£49.99</span>

    <label for="shipping_service_european" class="fc_radio">
    <input type="radio" class="fc_radio fc_required" value="european|28.99" id="shipping_service_european" name="shipping_service" />
    <span class="fc_shipping_carrier">Delivery</span>
    <span class="fc_shipping_service">to European countries outside of UK</span>
    <span class="fc_shipping_cost">£28.99</span>

    I want to be able to offer free shipping to UK customers, when they spend £200 or over, but UK customers only (basically to replace the first category, £6.99 shipping, but for this to happen automatically when UK customers spend over £200, so that customers outside of the UK can't select it as an option).

    Is this something you can help with?

    Many thanks for your time.

  • UPUP Member
    I forgot to say that I'm not very conversant in Javascript, I'll need hand holding I'm afraid!

  • fc_adamfc_adam FoxyCart Team

    I'm assuming your working off of my code here?

    So basically what you'll want to do is adjust step one to include the following. The '...' represent the code that's currently there:
    <script type="text/javascript">
    jQuery(document).ready(function() {
    function updateUKShipping() {
    var country_code = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_country").val() : $("#customer_country").val());
    if (country_code == "GB" && fc_json.total_price >= 200) {
    } else {
    // Set shipping cost for the initially selected country
    FC.checkout.config.orderFlatRateShipping = updateUKShipping();
    // Update shipping cost based on categories and country when updating the price
    FC.checkout.overload("updatePriceDisplay", "updateUKShipping", null);

    Let me know how that goes. If that doesn't work, if you could link me to your checkout page, that would be awesome.
  • fc_adamfc_adam FoxyCart Team
    @Matt {response to whisper}

    You've got a little error in the formatting of the javascript, try this one:
  • fc_adamfc_adam FoxyCart Team
    @Matt {response to whispers}

    My bad, I had an error in the code I linked to. Try these:

    So the expected outcome to this code is that when you have a total price of over 200 in the cart and the persons country is the United Kingdom, the UK shipping option to set to 0, if not, its set to 6.99. So you'll still need to select a delivery type even with a total price over 200.
  • UPUP Member
    Thanks ever so much Adam, that's worked a treat.

Sign In or Register to comment.