Sha256: 15b7eb8e0d58607ddd8370282727080977684a78219bf909a53fd2e3588a859a

Contents?: true

Size: 1004 Bytes

Versions: 5

Compression:

Stored size: 1004 Bytes

Contents

# include this to gain helpers for shopping trolley
module GetsTrolliedHelper
  include HasTrolleyControllerHelpers::UrlFor

  # wrapped in a div to allow for styling the form to be inline
  def button_to_place_in_trolley(purchasable_item)
    "<div class=\"add-to-trolley\">" +
      button_to(t('gets_trollied_helper.add_to_trolley'),
                :controller => :line_items,
                :action => :create,
                purchasable_item.class.as_foreign_key_sym => purchasable_item) +
      "</div>"
  end

  # TODO: trolley link

  def in_trolley_status_or_button_to_place_in_trolley(purchasable_item)
    html = String.new
    if current_user && current_user != false &&
        current_user.respond_to?(:trolley) &&
        current_user.trolley.has_active_order_for?(purchasable_item)
      html = "<div class=\"in-trolley\">" +
        t('gets_trollied_helper.in_trolley') +
        "</div>"
    else
      html = button_to_place_in_trolley(purchasable_item)
    end
    html
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trollied-0.1.4 app/helpers/gets_trollied_helper.rb
trollied-0.1.3 app/helpers/gets_trollied_helper.rb
trollied-0.1.2 app/helpers/gets_trollied_helper.rb
trollied-0.1.1 app/helpers/gets_trollied_helper.rb
trollied-0.1.0 app/helpers/gets_trollied_helper.rb