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.
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?
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: http://seriscreen.com/indexdev.php/products/screens-details/screen-mesh-fabric/
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: http://seriscreen.com/indexdev.php/includes/seriscreen-js/
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.
As soon as you can is perfect. And thanks!
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.
http://pastie.org/994599
Give that some testing and let me know if you have any luck with it.
Thanks!
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.
http://pastie.org/1000125
Just a quick if test.
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'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.
Any ideas?
Thanks in advance.
EDIT: Hrm. Image doesn't seem to be showing. Here's the URL: http://www.flickr.com/photos/anthonyd/4704708083/
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.
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):
http://pastie.org/1008081
That works on this page.
Can you take it from there?
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.
Thanks!
I don't usually say lol, but I lol'd.
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:
http://wiki.foxycart.com/getting_started:adding_links_and_forms#discounts
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.
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.
--AD
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.)
Will holler back when I've got a different model working.
Thanks!
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?
QUESTION:
================================
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 (foxycart.com) 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,
AD.
UPS REPLY:
================================
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:
<Package>
<PackagingType>
<Code>04</Code>
<Description>UPS 25KG Box</Description>
</PackagingType>
<Description>Rate</Description>
<PackageWeight>
<UnitOfMeasurement>
<Code>KGS</Code>
</UnitOfMeasurement>
<Weight>23</Weight>
</PackageWeight>
<PackagingType>
<Code>04</Code>
<Description>UPS 25KG Box</Description>
</PackagingType>
<Description>Rate</Description>
<PackageWeight>
<UnitOfMeasurement>
<Code>KGS</Code>
</UnitOfMeasurement>
<Weight>23</Weight>
</PackageWeight>
(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
</communications>
So devs any ideas? Input? Would love to stay with FC, and this has stopped my client's project cold.
Thanks in advance.
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: http://requests.foxycart.com/forums/4162-general-requests/suggestions/33314-super-ship?ref=title
(Please say yes.)
Sorry that's not better news.