No commit activity in last 3 years
No release in over 3 years
FoxyCart helpers for Middleman static sites
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

middleman-foxycart

A Middleman extension for use with FoxyCart.

Features

Setup and Configuration

In config.rb

activate :foxycart do |foxycart|
  foxycart.api_key = 'your foxycart api key' # also as `ENV['FOXYCART_API_KEY']`
  foxycart.url = 'https://mystoreurl.foxycart.com' # also as `ENV['FOXYCART_URL']`
  foxycart.auto_encode_hrefs = true # (default) Use HMAC Product Verification when generating links
end

Helper and Usage

Examples for ERB templates:

# JS helper, e.g. use in layout.erb
<%= foxycart_loader_js %>
# => "<script src=\"https://cdn.foxycart.com/example/loader.js\" async defer></script>"

# URL Helper
<%= foxycart_url_for('Cool Example', '10', 'sku123') %>
# => "https://example.foxycart.com/cart?name=Cool+Example&price=10&color=red"
<%= link_to 'Click the Link', foxycart_url_for('Cool Example', '10', 'sku123') %>
# => "<a href=\"https://example.foxycart.com/cart?name=Cool+Example&price=10&color=red\">Click the Link</a>"

# Product Verification link payloads
<%= foxycart_encode 'sku123', 'name', 'Cool Example' %>
# => "54a534ba0afef1b4589c2f77f9011e27089c0030a8876ec8f06fca281fedeb89"
<%= foxycart_encoded_name 'sku123', 'name', 'Cool Example' %>
# => "name||54a534ba0afef1b4589c2f77f9011e27089c0030a8876ec8f06fca281fedeb89"

foxycart_url_for and the Product Verification helpers arguments are:

  • code = Product code (sku123)
  • name = Value of name field in the HTML (name)
  • value = Value (or initial value) of the input etc (Cool Example)

See the FoxyCart docs for more information on code, name and value.

Contributing

Under the hood uses the gem foxycart_helpers (Foxycart helpers for plain Ruby and Rails)- this is just a thin wrapper for Middleman.

Bug reports and pull requests are welcome on GitHub on this repo if approparte or at https://github.com/rjocoleman/foxycart_helpers.

License

The gem is available as open source under the terms of the MIT License.