Last active
December 28, 2015 19:49
-
-
Save iacutone/7553248 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery.get('/organizations/' + org_id + '/free_quantities', function(data) { | |
| $('.span2').on('change', function(){ | |
| var input_value = $('input.span2').val(); | |
| var total_quant_in_stock_diff = data.total_in_stock - input_value; | |
| var total_available_free_for_user = data.free_available - input_value; | |
| $('.show_quantity_left').append('<p class="quantity_left">('+ (total_quant_in_stock_diff) +' in stock)</p>'); | |
| if ((total_available_free_for_user + 1) > 0){ | |
| $('span.show_quantity_for_free').append('<p class="quantity_free">(' + (data.free_available - data.total_quantity_ordered_from_org - input_value) + ' free)</p>'); | |
| $('span.show_submit_button').append('<%= submit_tag("Create Order", class: "btn primary", id: "order_submit_button") %>'); | |
| } | |
| else{ | |
| $('span.show_quantity_for_free').append('<p class="quantity_free">(None Free)</p>'); | |
| $('span.show_buy_button').append('<%= image_submit_tag("paypal_buy.gif", class: "buy_button", id: "order_submit_button") %>'); | |
| } | |
| var input_value = $('input.span2').val(); | |
| if (input_value == 0){ | |
| $('input#order_submit_tag').remove(); | |
| $('input#order_submit_button').remove(); | |
| } | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment