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.

Customer Entered Product Options

dasharddashard Member
in Help edited May 2010
I've scavenged around the forums looking for this one, so forgive me if I missed it somewhere.

I have a client who sells a particular item by the inch and another by the yard. It's easy enough to add the text input field to allow the customer to enter how many inches/yards they want, but I can't for the life of me get any javascript (using jQuery) to do the math and pass along a product total to the cart. I don't want to go the route of having the "Quantity" in the cart control this -- though it clearly could -- since the "Total Items in Cart" numbers would start to get ridiculous and would not represent anything real: ordering 12" of something would show 12 items in the cart. Not good.

My other problem is that if a customer wants 3 yards of productX, and then a separate buy of 2 yards of productX, the cart lumps it into 5 yards (presuming I did the 'Quantity-as-yards' thing). Can't figure out how to keep multiple additions of *this product alone* as separate entries when adding to the cart.

Any help would be appreciated, esp with multiplying the customer-entered length amount by the cost/per length. If I could get that working, I wouldn't need the cart quantity to change.

Finally, does FC capture somewhere how many times an item's been 'added' to the cart? Is there an internal counter that I could piggyback onto to perhaps change the item_code by increments, thus avoiding the lumping of multiple purchases of the same item into one?

Help, and thanks.
  • brettbrett FoxyCart Team
    Good question, but it sounds more like a javascript issue yeah? Do you have a form set up that we could help you work through? That's easier and way more productive than one of us trying to create a form like you're thinking of.

    I envision a text input for the length, a select or radio for inches or yards, and an add to cart button. Right?

    As far as lumping products together, FoxyCart will only combine them if they're identical, which doesn't sound like the case here. You'd add qty = 1 of a product with length = 2', qty=1 of a product with length = 3' of another, so they're not identical and wouldn't group.

    Make sense?
  • dasharddashard Member
    Brett -- thanks for getting back to me.

    At the get-go it seems to be a javascript issue, and I would be lying if I didn't say that I acknowledge the pretty impressive Javascript chops exhibited around here. Thus it makes more sense to throw out the plea here than in, say, a jQuery forum since it's a DAMNED SIMPLE cart-related thing I'm trying to do but can't seem to.

    URL in question is here:

    That's a product detail page where a customer is presented with product options and ONE text input in which to enter the length (in yards) of the product that they want. On hitting the 'Add to cart" link it's supposed to calculate the price-per-yard by how many yards the customer enters and dynamically add the price and some text to the "name". Seems simple but I can't even get jquery to pull the input value. The JS file is here:

    If you look at it you'll note that commented out in the first (document).ready statement is the code I'm trying to use just to get the value. It fails every time. And this is just the latest iteration of what I've tried. By the looks of it it *should* work.

    The alert(a) is just for debugging. Haven't gotten to actual calculations.

    If the add to cart lumping takes place as you state, then getting the JS to work would solve my entire issue.

    Any help would be appreciated. Yes, I know these are not JS forums, but it's unique to a cart experience. The rest of my JS is pretty good. This one, though, is stumping me.
  • dasharddashard Member
    One more clarification (after re-reading your original reply): no radio button. Product X is sold in yards, Product Y is sold in inches. The same code could be re-used for both. FYI. We ONLY need to capture a text input.
  • dasharddashard Member
    I wouldn't dream of being pushy when it comes to expert help. ;)
    As soon as you can is perfect. And thanks!
  • brettbrett FoxyCart Team
    Two things:
    1) Can you create a copy of that page without your own javascript?
    2) Can you easily add unique IDs to all of your add-to-cart links?

    I have some javascript ready but I'm having trouble testing it as is.
  • brettbrett FoxyCart Team
    This is actually a little trickier than I'd anticipated. If you were to do it over again I'd suggest adding hidden inputs for the price_per_unit and unit_type (inches/yards), but this should work:
    Give that some testing and let me know if you have any luck with it.
  • That works great! Only problem is it will allow me to add an item of the default '0' length. Want to keep the link 'unbound' while the length unit == zero. Help would be great, but I'm looking to see if I can work my way out of that bag.
  • dasharddashard Member
    edited June 2010
    OK. Thrashed around a bit and realized that I'm going to have to test and retest for the blur value of each 'length' cell, and that's a bit beyond my skills, at least as far as integrating it with your code. Basically would like to disable the submit while length input == '0'.

    Not sure where to insert it or by what means. Perhaps it should be grafted on to your code, or perhaps it should run as its own function. Any suggestions? Please and thanks in advance.
  • lukeluke FoxyCart Team
    The fc_PreProcess is probably want you want. That fires off before the add to cart happens and if you return false from that method, the item won't be added. It's a way to validate date before it makes into the cart. If you run into trouble, let us know and we can recommend a developer who might be able to help.
  • Hey Luke, is there any documentation on that?
  • lukeluke FoxyCart Team
    Here's some info that might help: You may want to try searching the forums as well.
  • brettbrett FoxyCart Team
    How about this?
    Just a quick if test.
  • dasharddashard Member
    edited June 2010
    Brett -- thanks for not giving up on me.

    It throws up the alert when "add(ing) to cart" a Zero length item, but then after dismissing the alert the thickbox comes up and the item is added anyway.
    I tried adding a "return false" to the first 'if' conditional but it doesn't stop it. I have to thing it's something deeper inside the foxycart js that's watching for the click that I can't clip.

    So close. Again, any help is immensely appreciated.

    EDIT: Oh, and I also tried moving the 'fc_tb_init' statement to within the 'else' clause. No luck. The zero length item gets added to the cart, but the cart for some reason is a separate page load instead of a thickbox/js version. That make sense?
  • I have another page that's leveraging the code you provided. It's visible here. The javascript is right in the page; not in a separate file, so you can view source to see.

    I've extended your code to have the correct pricing applied based on user input. You'll see there are 4 tiers of pricing based on how many items you purchase, but different prices for each SKU. Additionally I've added to the URL that's passed to the cart the quantity entered. That all works fine. The js grabs the proper price tier based on how many units are entered in the text input. The problem is that the thickbox presents the "Each Price" as the total.

    For example, I purchase 4 items that cost $1 each. The total would read $4 and then underneath it says ($4 each). The "Quantity" input reads '1'. Ideally the "Each…" price should display the unit price. The "quantity" should either represent the actual quantity purchased (instead of '1' as it now displays) and, perhaps, be disabled. Messing with the quantity in the cart could afford someone the lesser pricing by simply adding a large amount to "get" the cheaper pricing discount and then reducing the number of items in the cart. Of course, having the item appear as a quantity of '1' negates that. Right now it's basically showing '1' purchase of 'X' items, with 'X' being the passed in quantity. I can live with that, but the 'Each' price is a problem.

    Any ideas? This is probably gobbledeygook. Much easier to just visit the page and see. You'll get the idea immediately.
  • dasharddashard Member
    edited June 2010
    OK. having another issue that seems to be related to initializing the cart in more than one script (though that's a novice guess). Here's an image that tells the tale:


    Any ideas?
    Thanks in advance.

    EDIT: Hrm. Image doesn't seem to be showing. Here's the URL:
  • fc_adamfc_adam FoxyCart Team
    @dashard, just wanted to quickly post to let you know I'll get back to you today on this.
  • Well, first thanks for recommending developers, but my most recent round of questions were regarding a) multiple instances of messages in the cart and b) customizing the presentation of the cart, both of which I believe should probably be considered support requests. I have no problem self-helping, but wouldn't know what to search for, and could really spend inordinate amounts of time reading through all the dead-end threads. If you have some threads you would like to point me to, that's fine, but I don't appreciate the bum's rush.

    Brett's been more than helpful. I appreciate that. He provided a quick script that did the trick mostly. I've customized his work to add functionality further.

    My only additional request was (if possible) some input on why this or that or the other might be happening/displaying, and if customizations to the cart presentation (100% your realm) are possible.

    I'd still appreciate those answers. If I need a developer I will be sure to consider your recommendations.
    What I need now, though, is product support. For that I come to you guys.

    Please advise.
  • brettbrett FoxyCart Team
    It feels like we're chasing a moving target here, tbh. Last I looked at this I don't recall the 4 separate pricing tiers or the packs of 6, right? The page you linked to above has no IDs on the a.foxycart elements and has them in a td.addtocart-cell-screen-item instead of td.addtocart-cell. I see that you changed the javascript to match, but it seems like we should perhaps take a step back and make sure we're all on the same page.

    Re: the multiple thickbox headers: That happens if you re-bind the click event with the fc_tb_init() without first unbinding the click event, as it'll then fire off multiple thickbox calls on a single cart add. So do an unbind("click") before you re-bind them with the fc_tb_init().

    So... I'm going to go back to your original example, which I _think_ was working when I tested last, but perhaps not, since it doesn't have a return false, and it should. Perhaps I goofed on the paste into pastie and left you with the wrong code. Anyway, let's try this for your _original_ page, not the new page with the tiers and such (which it seems like you can handle):

    That works on this page.

    Can you take it from there?
  • brett -- thanks for your thoughtful reply. I guess I wasn't clear: I don't need help with anything right now except for:

    1) Customizing the number shown as the price for "each" in the lightbox
    2) Multiple instances of code in the lightbox.

    That's it! Perhaps I over-explained, but since we're all geeks I figured more info was better.

    If I could get help with these two issues, the second of which you may have already addressed in your reply (haven't yet looked), I would be a happy camper.

  • brettbrett FoxyCart Team
    (Response to whisper and previous non-whisper.)
    Being the wisest and fairest man you will ever meet (trust me) ...
    I don't usually say lol, but I lol'd.
    1) Customizing the number shown as the price for "each" in the lightbox
    2) Multiple instances of code in the lightbox.
    I'm pretty sure the #2 was addressed previously. You have to unbind the click event before re-binding it with the fc_tb_init(). If that doesn't get you what you want, let me know.

    As to your #1, isn't what you're describing the result of applying the first fix (in which we _do_ want to take the "length", multiply it by the unit price, and use that as the "each" price) to a page in which you _don't_ want to do that? I might be confused, but in the first example it's definitely not the same as the second.

    As an aside, if you're doing quantity discounts you may want to do them with the "real" quantity discounting functionality:
    instead of doing it with javascript.

    So with that said, the issue on your second page with the tiers is that you have a price input but an add-to-cart link (as opposed to a submit element in a form that contains the price input).

    The _easiest_ thing to do, which wouldn't require any js at all, would be to combine the two <td> elements (the one with the qty input and the add-to-cart link) into one, stick a form around both elements, and just make it a form not a link. If there's a compelling reason not to do that, then it'll have to be js, but given the appearance of a db-driven page/template anyway that would likely be the easiest.
  • Brett,

    Yes, you addressed the multiple bindings, and sent modified code. I will continue to muck around with it until I can get it to work. fc_PreProcess refuses to work. Don't know why. Will keep trying.

    As for #1, we're missing each other. Take a look at the following (brilliantly designed, by me) infographic:


    THAT's what I'm trying to customize.

    As always, any help would be appreciated.
    There's no rush. No pressure. No hard feelings. No developers. No extra costs. Please.


  • …OR…

    Are you stating that if this were a form submit as described this would be handled properly?
    You are, aren't you.

    Hmmm…feeling dumb. Will look at that.
    (Should read your replies more closely.)
  • lukeluke FoxyCart Team
    Do you want
    ? qty is coming through to FoxyCart as a custom product attribute (which is why it's below the product name) which may be what you want if they are bundled like that, but if not you should use quantity instead since that's a standard FoxyCart product attribute
  • After Brett brought about the realization that the inputs + hidden inputs + form submit-vs-add to cart link might yield what I need, I'm re-thinking the arrangement on the code end.
    Will holler back when I've got a different model working.

  • dasharddashard Member
    edited September 2010
    OK. It's been a while, so to recap I was originally having a problem with my client's heavy products causing the UPS live rate feature to error out on 150lb+ shopping carts (which are easy to achieve considering that one item may weigh upwards of 60lb.)

    I posed the problem to UPS for their input, and here's the exchange. The question is: is this a change I can make myself, or is this something that you guys would have to do to the core code?

    Customer (UPS E-mail Communications) 09/08/2010 04:10 PM
    Support Category: Technical Support
    Support Topic: Developer Resources
    Stage of Development: Integration
    Developer Resource: Web Service[ Shipping - Ground Freight ]

    What is your question or comment?
    I have integrated FoxyCart ( into a client site. The client sells heavy paint and paint supplies. 5 gal of paint can weigh between 40-60lb. As such, a shopping cart with several items in it can easily surpass the UPS 150lb "per package" limit.

    The only problem is that the client has no intention of sending all items in one package, yet assumptions are being made in the 'live rate' retrieval and UPS is returning an error (exceeded the 150lb limit) rather than a price.

    Do you have any protocols in place or recommendations for online shippers of heavyweight/overweight products? Could you please offer som insight into how to possibly work around this arbitrary limitation?

    Thanks in advance,



    Dear Anthony,

    Thank you for your inquiry. I apologize for the confusion with this issue. The UPS Rating APIs and the UPS Shipping APIs will process multi-piece shipments up to two hundred packages. To submit a multiple-piece shipment request, you will need to include multiple entries of the ***/Shipment/Package element. Each entry for "Package" must contain the elements for the packages for which you are requesting rates. You will then receive a rate for each package, and a shipment rate or you will receive multiple shipping labels if you are using the XML Shipping APIs.

    There is a limitation in the Rating API. If you use the Request Option of “Shop” you are limited to requesting a multi-piece shipment of 50 packages.

    Here is a code snippet of the <Package> container:

    <Description>UPS 25KG Box</Description>
    <Description>UPS 25KG Box</Description>
    (continue this pattern for up to 50 packages)

    You may need to work with the shopping cart software provider for this change if you are not able to program the changes yourself.

    Please contact us if you need any additional assistance.

    Brent R.
    UPS Technical Support


    So…devs…any ideas? Input? Would love to stay with FC, and this has stopped my client's project cold.

    Thanks in advance.
  • lukeluke FoxyCart Team
    edited September 2010
    Hello Anthony. We don't currently support splitting the shopping cart into multiple shipments based on weight because we don't yet have an algorithm for how each store might want to split up their packages. Every product will be different so it's not a simple solution. This issue was addressed here along with a work around which may or may not work for you:

    One other option I just thought of was to use our multiship feature. It's designed for shipping to multiple addresses but might actually be used to split up your orders. If you have some JavaScript knowledge you could potentially inspect the cart contents on each cart add and create a new shipto as needed based on the cart weight to ensure the shipments are split out correctly. That would get a bit tricky if someone tried to modify the quantity in the cart though so you may need to hide that option with some CSS or bypass the cart completely with cart=checkout.

    Hope that gives you some options.

    If you haven't already, please vote for this feature and include some comments on how you'd suggest we solve this particular issue:
  • brettbrett FoxyCart Team
    Also worth noting is that we're very very aware of this limitation, and we know that it's a major issue for some merchants. We do have shipping as a VERY high item on our priority list and expect to focus on shipping improvements in a not-too-distant version.
  • dasharddashard Member
    edited September 2010
    Understood. But the remaining tidbit that went unanswered was if there was anything that *I* could do in the codebase to effect such a change?
    (Please say yes.)
  • brettbrett FoxyCart Team
    Kind of. Unfortunately, there's nothing you could do to make FoxyCart split the order into multiple packages. You could hijack the entire shipping functionality (perhaps only optionally if the weight is too much) and return your own shipping rates. That's a bit more work, depending on what you end up doing, but ultimately that's going to be the only "real" solution to this issue at this point.

    Sorry that's not better news.
  • lukeluke FoxyCart Team
    @dashard: Does the multiship idea not work for you?
Sign In or Register to comment.