Sha256: 7771fa060eda4d2a46cedafd9e74bd1df3386065ea833def03045caeceec0024

Contents?: true

Size: 868 Bytes

Versions: 9

Compression:

Stored size: 868 Bytes

Contents

module ShopDiscounts
  module Tags
    module Item
      include Radiant::Taggable
      [:value, :discount].each do |symbol|
        desc %{ outputs the #{symbol} of the current cart item }
        tag "shop:cart:item:#{symbol}" do |tag|
          attr = tag.attr.symbolize_keys
          item = tag.locals.shop_line_item
          
          Shop::Tags::Helpers.currency(item.send(symbol),attr)
        end
      end
      
      desc %{ expands if the item has a discount}
      tag "shop:cart:item:if_discounted" do |tag|
        item = tag.locals.shop_line_item
        
        tag.expand if item.price != item.value
      end
      
      desc %{ expands if the item has a discount}
      tag "shop:cart:item:unless_discounted" do |tag|
        item = tag.locals.shop_line_item
        
        tag.expand if item.price == item.value
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
radiant-shop_discounts-extension-0.0.11 lib/shop_discounts/tags/item.rb
radiant-shop_discounts-extension-0.0.10 lib/shop_discounts/tags/item.rb
radiant-shop_discounts-extension-0.0.9 lib/shop_discounts/tags/item.rb
radiant-shop_discounts-extension-0.0.8 lib/shop_discounts/tags/item.rb
radiant-shop_discounts-extension-0.0.7 lib/shop_discounts/tags/item.rb
radiant-shop_discounts-extension-0.0.6 lib/shop_discounts/tags/item.rb
radiant-shop_discounts-extension-0.0.4 lib/shop_discounts/tags/item.rb
radiant-shop_discounts-extension-0.0.3 lib/shop_discounts/tags/item.rb
radiant-shop_discounts-extension-0.0.1 lib/shop_discounts/tags/item.rb