【问题标题】:Add a button to the Product page Spree将按钮添加到产品页面 Spree
【发布时间】:2014-08-13 18:42:14
【问题描述】:

我正在使用 SpreeCommerce 系统构建一个商务网站。我想在添加到购物车按钮旁边的产品页面上添加一个按钮,该按钮将链接到每个产品页面的不同页面。我搜索了他们的文档,但我什至无法弄清楚他们在哪里添加了购物车按钮。

编辑:如果不清楚,我不知道要编辑的代码在哪里。我知道如何编辑它以及应该放什么,但我不知道该放哪里。如果它与 spree 的其他编辑不同(您只需复制一个文件并进行更改),那么我需要更多帮助,但我不知道要复制哪个文件。

【问题讨论】:

    标签: ruby-on-rails spree


    【解决方案1】:

    1) 运行 bundle open spree ,导航到 core/app/spree/product/show.html.erb n 2)检查浏览器上的元素并找到按钮所在的位置。 3) 使用 deface 覆盖它。

    这是一个例子:

    我在div#cart-form 之前放了一个按钮(未经测试的相应修改)

    Deface::Override.new(:virtual_path  => "spree/product/show",
                             :insert_before => "div#cart-form",
                             :text          => "<button name="button">Click me</button>",
                             :name          => "button_product_show")
    

    假设文件名为 button_product_show.rb

    我会把这个文件放在app/overrides/spree/button_product_show.rb

    spree/product/show.html.erb 如下所示(至少在我使用的版本上):

    <div data-hook="product_show" itemscope itemtype="http://schema.org/Product">
      <% @body_id = 'product-details' %>
    
      <div class="columns six alpha" data-hook="product_left_part">
        <div class="row" data-hook="product_left_part_wrap">
    
          <div id="product-images" data-hook="product_images">
            <div id="main-image" data-hook>
              <%= render :partial => 'image' %>
            </div>
            <div id="thumbnails" data-hook>
              <%= render :partial => 'thumbnails' %>
            </div>
          </div>
    
          <div data-hook="product_properties">
            <%= render :partial => 'properties' %>
          </div>
    
        </div>
      </div>
    
      <div class="columns ten omega" data-hook="product_right_part">
        <div class="row" data-hook="product_right_part_wrap">
    
          <div id="product-description" data-hook="product_description">
    
            <h1 class="product-title" itemprop="name"><%= accurate_title %></h1>
    
            <div itemprop="description" data-hook="description">
              <%= product_description(@product) rescue t(:product_has_no_description) %>
            </div>
    
            <div id="cart-form" data-hook="cart_form">
              <%= render :partial => 'cart_form' %>
            </div>
    
          </div>
    
          <%= render :partial => 'taxons' %>
    
        </div>
      </div>
    
    </div>
    

    更多信息可以在这里找到:http://guides.spreecommerce.com/developer/view.html

    【讨论】:

      猜你喜欢
      • 2018-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-08
      相关资源
      最近更新 更多