Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 49cf139ecb
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (40 sloc) 1.191 kb
-module (product).
-compile (export_all).
-include_lib ("nitrogen/include/wf.inc").
-include("records.hrl").
-define(PRODUCT,wf:state(product)).
%load(Product) ->
load(ProductId) when is_record(ProductId,prodId)->
ProdId = ProductId#prodId.product,
CatId = ProductId#prodId.category,
wf:state(product,db:get_product(CatId,ProdId)),
CatStr = integer_to_list(CatId),
ProdStr = integer_to_list(ProdId),
Path = "./tpl/" ++ CatStr ++ "_" ++ ProdStr ++ ".tpl",
case file:read_file_info(Path) of
{ok,_} ->
#template { file=Path };
{error,_} ->
#template{ file="./tpl/CC_product.tpl" }
end;
load(Prod) ->
wf:state(product,Prod).
id() ->
(?PRODUCT)#product.id.
name() ->
(?PRODUCT)#product.name.
url() ->
(?PRODUCT)#product.url.
img() ->
image:load((?PRODUCT)#product.img).
description() ->
(?PRODUCT)#product.description.
price() ->
price:toString((?PRODUCT)#product.price).
buyLink() ->
Delegate = #event{type=click, delegate=product, postback={buy,id(),1}},
#link{text="add to cart", actions=Delegate}.
event({buy,ProdId,Qty}) ->
cart:add(Qty,ProdId);
event(Event) ->
?PRINT(Event).
Jump to Line
Something went wrong with that request. Please try again.