1

I have this shopping cart with a drop down menu with a list of products (titles are zip codes). When a user selects one, my JQuery replaces all subtotals with "Loading..." and then submits the update_cart_form. This is all well and good.

Problem: Upon submission, I want to add a line in JQuery to add the product selected in the drop-down to the cart. Since the form is being submitted, I don't think I need an AJAX call, but I could be wrong? I basically want to just add the item to the cart on submission and when the page reloads it will be showing the new addition.

I would also need to have a similar line to remove any products that are currently in the cart that are assigned to the EE category="delivery_rates."

Note: One may ask why I am handling delivery rates in the update_cart_form rather than the checkout_form. This is because there is a minimum price that a customer needs to have in their cart prior to having delivery options available to them. Additionally, there are only a handful of zip codes where my client will be delivering and it's important to establish this immediately to prevent delivery errors.

I have tried the options listed here: http://cartthrob.com/docs/tags_detail/add_to_cart/index.html, but to no avail.

Link to cart: http://dandelionflowershop.com/index.php/website/cart. Note: You will need to add at least $40 to the cart to view the delivery options that I'm working on here.

Here's the JQuery code that I have going on right now. Everything works here. I just would like to know what I should be looking to alter for this functionality:

 $("#zip").change(function() {
            $("#total").toggleClass("gray").html("Loading...").show().fadeOut( 1000 );
            $(".line_subtotal").toggleClass("gray").html("Loading...").show().fadeOut( 1000 );
/* Add function: Remove all products from cart with category="delivery_rates" */
/* Add function: Add product (if possible by {title="{custom_data:zipcode"}, not {entry_id}) */
            $('#cartform').submit();
        });

I hope I'm at least going down the right path here.

Thank you guys and gals!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.