Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(function() {
  3.  
  4. $("#cartform").validate({
  5. rules: {
  6. "order_products::quantity[]": {
  7. required: true,
  8. min: 1
  9. }
  10. },
  11. errorPlacement: function($label, $element) {
  12. $("<tr />").append(
  13. $("<td />").attr({colspan: 2}).html($label.css({ margin: 0}))
  14. ).insertAfter($element.closest("tr"));
  15. },
  16. submitHandler: function(form) {
  17. $form = $(form);
  18. var product_id = $form.find("input[name='order_products::product_id[]']").val();
  19. if (product_id) {
  20. var values = $.map($form.find("select[name='order_product_values::value_id[]']"), >function(elem) { return elem.value; });
  21. var quantity = >$form.find("input[name='order_products::quantity[]']").val();
  22. $.cart(product_id, values, quantity);
  23. $(".cart_count").html($.cart().length);
  24.  
  25. //when the item was successfully added to the cart, the user is >redirected to their shopping cart summary
  26. window.location.href("order.php");
  27. }
  28. return false;
  29. }
  30. });
  31. });
  32. </script>
  33.  
  34. function writeCookie() {
  35. var crumbs = [];
  36. for (var i in cart) {
  37. crumbs.push(
  38. '{"product_id":' + cart[i].product_id + ',"quantity":' + >cart[i].quantity + ',"values":[' + cart[i].values.toString() + ']}'
  39. );
  40. }
  41. $.cookie('omani_cart', "[" + crumbs.join(",") + "]", { expires: 7, >domain: location.hostname , path:'/'}); // setCookie('omani_cart',"[" + >crumbs.join(",") + "]","/",location.hostname,false,true);*/
  42.  
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement