Add to cart link not working in IE

fc_joshfc_josh FoxyCart Team
in Bugs & Feature Requests edited August 2010
I am using javascript to connect a link to form fields. Below is the javascript:
<script type="text/javascript" charset="utf-8">

    function form_fake(link) {
    	parent = jQuery(link).closest('div.foxycart_form');
    	if (parent.length < 1) return false;
     
    	// console.info(link);
    	// console.info(parent);
    	href = 'https://' + FoxyDomain + '/cart?' + jQuery(parent).find('*').serialize() + fc_AddSession();
     
    	jQuery(link).attr('href', href);
    	// console.info(jQuery(link).attr('href'));
    }
     
    jQuery(document).ready(function($){
    	form_fake($('div.foxycart_form a.foxycart_submit'));
     
    	$('div.foxycart_form a.foxycart_submit').click(function(){
    		form_fake($(this));
    	});
    	$('div.foxycart_form *').change(function(){
    		form_fake($(this).closest('div.foxycart_form').find('a.foxycart_submit'));
    	});
    });

</script>

Below is the HTML:
<div class="foxycart_form">
<!-- HIDDEN FIELDS -->
<input type="hidden" name="name" value="You Make The Call Vol. 1" />
<input type="hidden" name="format" value="DVD" />
<input type="hidden" name="price" value="9.99" />
<!-- QUANTITY -->
<div class="label">QTY</div>

<div class="quantity"><input type="text" value="1" name="quantity" /></div>
<!-- LINK -->
<a class="add_to_cart foxycart foxycart_submit" href="https://knowyourstuff.foxycart.com/cart"></a>;
</div>

For some reason, the link doesn't add products to the cart. It launches the cart though. It works perfect in Firefox though. Thanks for the help!
Comments
  • lukeluke FoxyCart Team
    Hey pixel. Any chance you could just use a link to submit the form and fire it off that way using all of the default, built in FoxyCart functionality? When things start getting customized to this level it's a little difficult for us to get involved because there's no telling what side affects could come up.
  • brettbrett FoxyCart Team
    Josh, can you link me? Whisper it if it's private. I know that that code was tested in IE, but ...
    It looks like there's a javascript error:
    window.onload = alertSubmitted();
    
    That's causing IE6-8 to blow up. Not sure what that code's doing but it's the ElementFusion code ... You're including foxycart_includes.js and jquery.js, which you shouldn't be. jQuery only should be included once, and that can definitely cause problems. I'd address that first by moving the FoxyCart include block to after the jQuery.js call and replacing the foxycart_includes.js with this:
    <script src="https://cdn.foxycart.com/YOUR FOXYCART DOMAIN/foxybox.js" type="text/javascript" charset="utf-8"></script>
    <script src="http://cdn.foxycart.com/YOUR FOXYCART DOMAIN/foxycart.js" type="text/javascript" charset="utf-8"></script>
    
    Replacing the "YOUR FOXYCART DOMAIN" with your store's subdomain.
  • brettbrett FoxyCart Team
    Hi Josh.
    Can you set up a separate page to test on, perhaps? So long as there are two jQuery calls in there I don't want to move beyond that, since that often is the cause of problems. Again, we want to not include jQuery twice, so we either want to not load foxycart_includes.js (as above) or we want to remove the jQuery call in the other place on your site.

    (IE6 has some major nav formatting issues too, fyi, if you didn't know. And some alpha transparency issues too.)
  • fc_joshfc_josh FoxyCart Team
    edited August 2010
    Brett,
    The jQuery call is something from LightCMS. I am not using any special elements (like Photo Gallery) that would need jQuery, so I don't know how to rid of the call. I know this isn't the LightCMS forum, but I would like to make this work. In fact, I have to. lol. I have done as suggested above, but cart is not loaded in Thickbox and product is not added in FF or IE.
  • brettbrett FoxyCart Team
    Ok, well that was weird. The issue was with the variable being named "parent". I've updated the script here:
    http://wiki.foxycart.com/integration/asp.net/forms#installation
    Use that instead. Just tested it and it seems to work swimmingly.
  • fc_joshfc_josh FoxyCart Team
    Brett,
    That worked perfect. Thank you so much!
Sign In or Register to comment.