I'm very new to Rails, but am comfortable with static front-end design and
haven't had much trouble customizing the spree app for clean integration
into the site's interface, but there are a few little finicky details that
have me stumped. I'd really appreciate the help, even if these questions
sound basic, as I just can't seem to correctly modify the code.


Under orders>edit.html.erb<https://github.com/spree/spree/blob/master/frontend/app/views/spree/orders/edit.html.erb>,
I need to make the following button code work as a text link (instead of a
button):

<%= button_tag :class => 'primary', :id => 'update-button' do %>
<%= t(:update) %>
<% end %>


To help visualize, let's say this is the HTML I'm trying to use:
<a href="#">Update</a>

--

I need this code to become a text link, along with an accompanying image/icon:
<%= button_tag :class => 'button checkout primary', :id => 'checkout-link', :name => 'checkout' do %>
<%= t(:checkout) %>
<% end %>


This is an example of the markup:
<a href="link">Checkout <img src="image.png" /></a>

--

Under orders>_line_item.html.erb <https://github.com/spree/spree/blob/master/frontend/app/views/spree/orders/_line_item.html.erb>, I need a link_to image to become a button:
<%= link_to image_tag('icons/delete.png'), '#', :class => 'delete', :id => "delete_#{dom_id(line_item)}" %>


Another markup sample, in case I didn't explain well:
<button>Remove from Cart</button>

--

And finally, another button to become a text link+image on the products>_cart_form.html.erb <https://github.com/spree/spree/blob/master/frontend/app/views/spree/products/_cart_form.html.erb>.
<%= button_tag :class => 'large primary', :id => 'add-to-cart-button', :type => :submit do %>
<%= t(:add_to_cart) %>
<% end %>


Markup:
<a href="link">Add to Cart <img src="image.png" /></a>



By seeing the way these convert, you guys can really help me understand Rails syntax
and aid me in accomplishing some pretty monumental tasks in Spree. Thanks!

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • C Reign at Mar 6, 2013 at 7:21 am
    I found this post<https://groups.google.com/forum/?fromgroups=#!topic/spree-user/kX5JHWMnluI>and used image_submit_tag to attempt to make the image in my last example
    work as the ADD TO CART button, but was unsuccessful.

    For reference, this is the code I tried.

    <%= image_submit_tag('/images/arrow.png', :alt => "Add to Cart", :class => 'large
    primary', :id => 'add-to-cart-button') %>


    --
    You received this message because you are subscribed to the Google Groups "Spree" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Erwin at Mar 7, 2013 at 1:27 pm
    OK.. this is a good exemaple of doing it step by step ..

    1- you copy the spree/products/_cart_form.html.erb as it
    into your app : app/views/spree/products/_cart_form.html.erb (
    creating the subfolders exactly as it)
    - you run your app , and should see the standard play display

    2- you modify the partial app/views/spree/products/_cart_form.html.erb in
    your app , replacing the button_tag block by your own block , and you test
    it .... this is pure Rails .. nothing related to Spree

    <div class="add-to-cart">
    <% if @product.on_sale? %>

    <%= number_field_tag (@product.has_variants? ? :quantity :
    "variants[#{@product.master.id}]"),
    1, :class => 'title', :in => 1..@product.on_hand, :min => 1 %>

    <%= button_tag :class => 'large primary', :id =>
    'add-to-cart-button', :type => :submit do %>
    <%= t(:add_to_cart) %>
    <% end %>

    <% else %>
    <%= content_tag('strong', t(:out_of_stock)) %>
    <% end %>
    </div>

    3- once running like you want , you create the override ( using text or
    partial to replace the block, and you remove the
    app/views/spree/products/_cart_form.html.erb

    et voilà !

    Le mardi 5 mars 2013 00:55:07 UTC+1, C Reign a écrit :
    I'm very new to Rails, but am comfortable with static front-end design and
    haven't had much trouble customizing the spree app for clean integration
    into the site's interface, but there are a few little finicky details that
    have me stumped. I'd really appreciate the help, even if these questions
    sound basic, as I just can't seem to correctly modify the code.


    Under orders>edit.html.erb<https://github.com/spree/spree/blob/master/frontend/app/views/spree/orders/edit.html.erb>,
    I need to make the following button code work as a text link (instead of a
    button):

    <%= button_tag :class => 'primary', :id => 'update-button' do %>
    <%= t(:update) %>
    <% end %>


    To help visualize, let's say this is the HTML I'm trying to use:
    <a href="#">Update</a>

    --

    I need this code to become a text link, along with an accompanying image/icon:
    <%= button_tag :class => 'button checkout primary', :id => 'checkout-link', :name => 'checkout' do %>
    <%= t(:checkout) %>
    <% end %>


    This is an example of the markup:
    <a href="link">Checkout <img src="image.png" /></a>

    --

    Under orders>_line_item.html.erb <https://github.com/spree/spree/blob/master/frontend/app/views/spree/orders/_line_item.html.erb>, I need a link_to image to become a button:
    <%= link_to image_tag('icons/delete.png'), '#', :class => 'delete', :id => "delete_#{dom_id(line_item)}" %>


    Another markup sample, in case I didn't explain well:
    <button>Remove from Cart</button>

    --

    And finally, another button to become a text link+image on the products>_cart_form.html.erb <https://github.com/spree/spree/blob/master/frontend/app/views/spree/products/_cart_form.html.erb>.
    <%= button_tag :class => 'large primary', :id => 'add-to-cart-button', :type => :submit do %>
    <%= t(:add_to_cart) %>
    <% end %>


    Markup:
    <a href="link">Add to Cart <img src="image.png" /></a>



    By seeing the way these convert, you guys can really help me understand Rails syntax
    and aid me in accomplishing some pretty monumental tasks in Spree. Thanks!
    --
    You received this message because you are subscribed to the Google Groups "Spree" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedMar 5, '13 at 9:57a
activeMar 7, '13 at 1:27p
posts3
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

C Reign: 2 posts Erwin: 1 post

People

Translate

site design / logo © 2022 Grokbase