getting rid of old commerce code. bye bye!
This commit is contained in:
parent
f3b14a227c
commit
be8ce29f57
36 changed files with 13 additions and 10753 deletions
|
|
@ -1,82 +0,0 @@
|
|||
package WebGUI::Macro::Product;
|
||||
|
||||
use strict;
|
||||
use WebGUI::Product;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::Product
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This macro looks up a Product in the Product Manager
|
||||
|
||||
=head2 process ( ID/SKU [,templateId] )
|
||||
|
||||
=head3 productId or SKU
|
||||
|
||||
The productId or SKU of the project to look up.
|
||||
|
||||
=head3 templateId
|
||||
|
||||
An alternate template to use for formatting the link, referenced by templateId. If this
|
||||
is left blank, a default template from the Macro/Product namespace will be used.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my (@param, $productId, $variantId, $product, $variant, $output, $templateId, @variantLoop, %var);
|
||||
|
||||
@param = @_;
|
||||
|
||||
my $i18n = WebGUI::International->new($session,'Macro_Product');
|
||||
return $i18n->get('no sku or id') unless ($_[0]);
|
||||
|
||||
($productId, $variantId) = $session->db->quickArray("select productId, variantId from productVariants where sku=".$session->db->quote($_[0]));
|
||||
($productId) = $session->db->quickArray("select productId from products where sku=".$session->db->quote($_[0])) unless ($productId);
|
||||
($productId) = $session->db->quickArray("select productId from products where productId=".$session->db->quote($_[0])) unless ($productId);
|
||||
|
||||
return $i18n->get('cannot find product') unless ($productId);
|
||||
|
||||
$product = WebGUI::Product->new($session,$productId);
|
||||
|
||||
if ($variantId) {
|
||||
$variant = [ $product->getVariant($variantId) ];
|
||||
} else {
|
||||
$variant = $product->getVariant;
|
||||
};
|
||||
|
||||
foreach (@$variant) {
|
||||
my @compositionLoop;
|
||||
foreach (split(/,/,$_->{composition})) {
|
||||
my ($parameterId, $optionId) = split(/\./, $_);
|
||||
push(@compositionLoop, {
|
||||
parameter => $product->getParameter($parameterId)->{name},
|
||||
value => $product->getOption($optionId)->{value}
|
||||
});
|
||||
}
|
||||
|
||||
push (@variantLoop, {
|
||||
'variant.variantId' => $_->{variantId},
|
||||
'variant.price' => $_->{price},
|
||||
'variant.weight' => $_->{weight},
|
||||
'variant.sku' => $_->{sku},
|
||||
'variant.compositionLoop' => \@compositionLoop,
|
||||
'variant.addToCart.url' => $session->url->page('op=addToCart;itemType=Product;itemId='.$_->{variantId}),
|
||||
'variant.addToCart.label' => $i18n->get('add to cart'),
|
||||
}) if ($_->{available});
|
||||
}
|
||||
|
||||
%var = %{$product->get};
|
||||
$var{variantLoop} = \@variantLoop;
|
||||
$var{'variants.message'} = $i18n->get('available product configurations');
|
||||
$templateId = $_[1] || $product->get('templateId');
|
||||
|
||||
return WebGUI::Asset::Template->new($session,$templateId)->process(\%var);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
package WebGUI::Macro::SubscriptionItem;
|
||||
|
||||
use strict;
|
||||
use WebGUI::Asset::Template;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::SubscriptionItem;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Macro for displaying information about subscription items.
|
||||
|
||||
=head2 process ( subscriptionId [,templateId ] )
|
||||
|
||||
process takes two optional parameters for customizing the content and layout
|
||||
of the account link.
|
||||
|
||||
=head3 subscriptionId
|
||||
|
||||
The text of the link. If no text is displayed an internationalized default will be used.
|
||||
|
||||
=head3 templateId
|
||||
|
||||
A templateId to use for formatting the link. If this is empty, a default template will
|
||||
be used from the Macro/SubscriptionItem namespace.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $subscriptionId = shift;
|
||||
my $templateId = shift || 'PBtmpl0000000000000046';
|
||||
|
||||
# Fetch subscription asset
|
||||
my $subscription = WebGUI::Asset->newByDynamicClass( $session, $subscriptionId );
|
||||
return "Could not find subscription with id: [$subscriptionId]" unless $subscription;
|
||||
return "Only Subscription assets can be used with this macro."
|
||||
unless $subscription->get('className') =~ m{^WebGUI::Asset::Sku::Subscription};
|
||||
|
||||
# Setup template vars
|
||||
my $var;
|
||||
$var->{ subscriptionId } = $subscription->getId;
|
||||
$var->{ name } = $subscription->get('title');
|
||||
$var->{ price } = $subscription->getPrice;
|
||||
$var->{ description } = $subscription->get('description');
|
||||
$var->{ subscriptionGroup } = $subscription->get('subscriptionGroup');
|
||||
$var->{ duration } = $subscription->get('duration');
|
||||
$var->{ karma } = $subscription->get('karma');
|
||||
$var->{ useSalesTax } = $subscription->get('useSalesTax');
|
||||
$var->{ url } = $subscription->getUrl('func=purchaseSubscription');
|
||||
|
||||
# Fetch template
|
||||
my $template = WebGUI::Asset::Template->new( $session, $templateId );
|
||||
return "Could not instantiate template with id:[$templateId]" unless $template;
|
||||
|
||||
return $template->process( $var );
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
package WebGUI::Macro::SubscriptionItemPurchaseUrl;
|
||||
|
||||
use strict;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::SubscriptionItemPurchaseUrl
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Macro that returns a URL to purchase a subscription item.
|
||||
|
||||
=head2 process ( subscriptionId )
|
||||
|
||||
process returns a URL that is the current page with an operation appended
|
||||
to purchase the requested subscription item.
|
||||
|
||||
=head3 subscriptionId
|
||||
|
||||
The ID of the subscription item to purchase.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $subscriptionId = shift;
|
||||
|
||||
# Fetch subscription asset
|
||||
my $subscription = WebGUI::Asset->newByDynamicClass( $session, $subscriptionId );
|
||||
return "Could not find subscription with id: [$subscriptionId]" unless $subscription;
|
||||
return "Only Subscription assets can be used with this macro."
|
||||
unless $subscription->get('className') =~ m{^WebGUI::Asset::Sku::Subscription};
|
||||
|
||||
# Construct and output the purchase url for this subscription
|
||||
return $subscription->getUrl('func=purchaseSubscription');
|
||||
}
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue