package WebGUI::Macro::Specials; # edit this line to match your own macro name #------------------------------------------------------------------- # WebGUI is Copyright 2001-2009 Plain Black Corporation. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using # this software. #------------------------------------------------------------------- # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- use strict; =head1 NAME Package WebGUI::Macro::Specials =head1 DESCRIPTION Handy example code for starting a new Macro when you have to start from scratch. =head2 process( $session, $productUrl, $specialsTemplateId ) The main macro class, Macro.pm, will call this subroutine and pass it =over 4 =item * A session variable =item * Any other options that were sent to the macro by the user. It is up to you to set defaults and to validate user input. =back =cut use WebGUI::Asset::Sku::Product; use WebGUI::Asset::Template; use WebGUI::Asset; #------------------------------------------------------------------- sub process { my $session = shift; my $productUrl = shift; my $specialsTemplateId = shift; my $product = WebGUI::Asset->newByUrl($session,$productUrl); my $vars; my $productImage = $product->getThumbnailUrl(); my $productPrice = $product->getPrice; my $template = WebGUI::Asset::Template->new($session, $specialsTemplateId); return "Could not instanciate template with id [$specialsTemplateId]" unless $template; $vars->{ price } = $productPrice; $vars->{ thumbnail } = $productImage; $vars->{ url } = $productUrl; return $template->process($vars); } 1; #vim:ft=perl