• # March 25, 2013 at 4:50 pm

    On taxons#show I am displaying products pulled from the database with

    < % products.each do |product| %>

    When you click a product instead of taking you to the products#show page I have a lightbox popup on taxons#show with more info/images of the product. I’m trying to render _cart_form.html.erb on this lightbox so that the user can add to cart from the lightbox. But bc _cart_form.html.erb uses @product instead of ‘product’, i have to do

    < % @product = product %>
    < %= render 'spree/shared/cart_form' %>

    But what this does is change all the product images on taxons#show to the same image b/c the link to large_image tag is using ‘product’ to pull in the image. Also the _cart_form contents are all based on the same product as well. And if i try and change _cart_form to use ‘product’ instead of @product I get a NoMethod error for nilClass.

    Here is the code for _products.html.erb on taxons#show: I’m setting the product variable, then hardcoding the lightbox div so its outside of the main container and display: none until clicked, then I’m trying to render the cart at the end of the lightbox, and then after the lightbox I have the product grid which displays all the products, but each one is taking the image of the first one.

      < % products.each do |product| %>
      < % if product.on_display? %>
      < %# ******LIGHTBOX******* %>


      < % @product = product %>
      < %= render 'spree/shared/cart_form' %>

      < %# ******END LIGHTBOX******* %>

    • “classes”) %>” data-hook=”products_list_item” itemscope itemtype=””>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.