如何从购物车中删除产品?

时间:2019-02-18 10:02:25

标签: ruby-on-rails ruby spree

我在Spree应用中从购物车按钮删除产品时遇到问题。

这是_line.html.erb

<% variant = line_item.variant %>

<%= order_form.fields_for :line_items, line_item do |item_form| %>
  <tr class="first odd">
    <td class="image"><a class="product-image" title="Sample Product" href="#/women-s-crepe-printed-black/">
      <% if variant.images.length == 0 %>
        <%= link_to small_image(variant.product), variant.product %>
      <% else %>
        <%= link_to image_tag(variant.images.first.attachment.url(:small)), variant.product %>
      <% end %>
    </td>
    <td><h2 class="product-name">
      <%= link_to line_item.name, product_path(variant.product) %>
       </h2>
    </td>
    <td class="a-center"><a title="Edit item parameters" class="edit-bnt" href="#configure/id/15945/"></a></td>
    <td class="a-right"><span class="cart-price"> <span class="price">
      <%= line_item.single_money.to_html %></span> </span>
    </td>
    <td class="a-center movewishlist">
      <%= item_form.number_field :quantity, min: 0, class: "form-control line_item_quantity", size: 5 %>
    </td>
    <td class="a-right movewishlist"><span class="cart-price"> <span class="price">
      <%= line_item.display_amount.to_html unless line_item.quantity.nil? %></span> </span>
    </td>
    <td class="a-center last">
      <%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-minus-sign'), '#', class: 'delete', id: "delete_#{dom_id(line_item)}" %>
    </td>
  </tr>

<% end %>

我发现这是删除产品按钮:

<%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-minus-sign'), '#', class: 'delete', id: "delete_#{dom_id(line_item)}" %>

但是单击该按钮时,什么都没有发生。

我也查看了订单控制器,没有销毁方法。 有人可以指示我哪种方法最适合仅在Spree应用程序中和在Rails中从购物车中删除产品?

0 个答案:

没有答案