Sha256: 8a519099445148f93642f717b9427459ea54ae5689f20cb211baebadac6b26dc

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

module Shop
  module Tags
    module Address
      include Radiant::Taggable
      
      # Expand if the address has been assigned to the order
      desc %{
        Expand if an address has been assigned to the order
      
        @type@ = (billing)|(shipping)
      }
      tag 'shop:cart:address' do |tag|
        Forms::Tags::Helpers.require!(tag,'shop:cart:address','type')
        
        tag.locals.address = Shop::Tags::Helpers.current_address(tag)
        
        tag.expand
      end
      
      # Expand if an address has been assigned to the order
      desc %{ Expand if an address has been assigned to the order }
      tag 'shop:cart:address:if_address' do |tag|
        tag.expand if tag.locals.address.present?
      end
      
      # Expand if an address has not been assigned to the order
      desc %{ Expand if an address has not been assigned to the order }
      tag 'shop:cart:address:unless_address' do |tag|
        tag.expand unless tag.locals.address.present?
      end
      
      [:id, :name, :email, :unit, :street, :city, :state, :country, :postcode].each do |method|
        tag "shop:cart:address:#{method}" do |tag|
          tag.locals.address.send(method) rescue nil
        end
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-shop-extension-0.9.3 lib/shop/tags/address.rb
radiant-shop-extension-0.9.2 lib/shop/tags/address.rb