Guest User

Untitled

a guest
Jul 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. <% form_for :order, :url => orders_url do |f| %>
  2.  
  3. <% if product_price(@product) %>
  4. <p class="prices">
  5. <%= t("price") %>
  6. <br />
  7. <span class="price selling"><%= product_price(@product) %></span>
  8. </p>
  9. <% end %>
  10.  
  11. <% if @product.has_variants? %>
  12. <div id="product-variants">
  13. <h2><%= t('variants') %></h2>
  14. <ul>
  15. <% has_checked = false
  16. <<<<<<< HEAD
  17. @product.variants.active.each_with_index do |v,index|
  18. =======
  19. @variants.each do |v|
  20. >>>>>>> Added some indexes and reduced count of SQL-queries.
  21. next if v.option_values.empty? || (!Spree::Config[:show_zero_stock_products] && !v.in_stock?)
  22. checked = !has_checked && (Spree::Config[:allow_backorders] || v.in_stock?)
  23. has_checked = true if checked %>
  24. <li>
  25. <label>
  26. <%= radio_button_tag "products[#{@product.id}]", v.id, checked, :disabled => !Spree::Config[:allow_backorders] && !v.in_stock? %>
  27. <%= variant_options v %>
  28. <% if variant_price_diff v %>
  29. <span class="price diff"><%= variant_price_diff v %></span>
  30. <% end %>
  31. </label>
  32. </li>
  33.  
  34. <% content_for :head do %>
  35. <script type="text/javascript">
  36. jQuery(document).ready(function(){
  37.  
  38. jQuery("#products_<%= @product.id %>_<%= v.id %>").click(function (event) {
  39. jQuery("#variant-thumbnails").empty();
  40.  
  41. jQuery("#variant-images").html('<%= t('images_for') %>: <%= v.options_text %>')
  42.  
  43. if(images[<%= v.id %>].length > 0){
  44. <% v.images.each do |i| %>
  45. jQuery("#variant-thumbnails").append('<li><%= link_to(image_tag(i.attachment.url(:mini)), i.attachment.url(:product)) %></li>');
  46. <% end %>
  47.  
  48. jQuery("#variant-images").show();
  49. }else{
  50. jQuery("#variant-images").hide();
  51. }
  52.  
  53. add_image_handlers();
  54.  
  55. var link = jQuery("#variant-thumbnails a")[0];
  56.  
  57. jQuery("#main-image img").attr({src: jQuery(link).attr('href')});
  58. jQuery('ul.thumbnails li').removeClass('selected');
  59. jQuery(link).parent('li').addClass('selected');
  60. });
  61.  
  62. });
  63. </script>
  64. <% end %>
  65. <% end%>
  66. </ul>
  67. </div>
  68. <% end%>
  69. <% if Spree::Config[:allow_backorders] || @product.has_stock? %>
  70. <%= text_field_tag (@product.has_variants? ? :quantity : "variants[#{@product.master.id}]"),
  71. 1, :class => "title", :size => 3 %>
  72. &nbsp;
  73. <button type='submit' class='large primary'>
  74. <%= image_tag('/images/add-to-cart.png') + t('add_to_cart') %>
  75. </button>
  76. <% else %>
  77. <%= content_tag('strong', t('out_of_stock')) %>
  78. <% end %>
  79. <% end %>
Add Comment
Please, Sign In to add comment