Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. /*
  2. PHP
  3. */
  4. function cart_add_team_member(){
  5. global $translation_name, $current_user, $woocommerce;
  6. wp_verify_nonce( 'woocommerce-cart');
  7. session_start();
  8.  
  9. if (empty($_POST["new_person"])) {
  10. wc_add_notice( sprintf(_x('The name of participant #%1$s for "%2$s" can\'t be empty.', "WooCommerce", $translation_name), $i, get_the_title($elem["product_id"])) , 'error' , 'error' );
  11. $code = 'error';
  12. // die();
  13. // echo ABSPATH;
  14. }
  15.  
  16. echo '{"code": "'.$code.'", "referer": "'.(wp_get_referer()).'"}';
  17. // echo json_encode($_POST);
  18.  
  19. die();
  20. }
  21.  
  22.  
  23. /*
  24. COFFEE
  25. */
  26. (($) ->
  27.  
  28. $('.add_person .acf-form-submit .button-primary').click (e) ->
  29. e.preventDefault();
  30. # console.log $(this).parents('.add_person').find('input, textarea, select').serializeArray()
  31.  
  32. formdata = $(this).parents('.add_person').find('input, textarea, select').serialize()
  33. send_data =
  34. action: 'cart_add_member'
  35. lang: wp_variables.lang
  36.  
  37. # console.log send_data.serializeArray()
  38.  
  39. request = $.ajax
  40. url: wp_variables.ajaxurl
  41. type: 'POST'
  42. dataType: 'json'
  43. data: formdata + '&' +$.param(send_data)
  44.  
  45. request.done (data,txtstatus,jq) ->
  46. console.log data
  47. console.log txtstatus
  48. # console.log jq
  49. if data.code is 'error' then window.location.replace data.referer
  50.  
  51.  
  52. return
  53. ) jQuery
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement