Fix the form for the Product. It was returning variants with no quantity.
This commit is contained in:
parent
1bcae0d3bc
commit
df51a0d99f
3 changed files with 28 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
|||
7.7.14
|
||||
- fixed #10606: shelf selector
|
||||
|
||||
7.7.13
|
||||
- fixed #10574: Creating Calendar Entry
|
||||
|
|
|
|||
|
|
@ -255,7 +255,8 @@ sub getAddToCartForm {
|
|||
my $i18n = WebGUI::International->new($session, 'Asset_Product');
|
||||
my %variants = ();
|
||||
tie %variants, 'Tie::IxHash';
|
||||
foreach my $collateral ( @{ $self->getAllCollateral('variantsJSON')} ) {
|
||||
COLLATERAL: foreach my $collateral ( @{ $self->getAllCollateral('variantsJSON')} ) {
|
||||
next COLLATERAL unless $collateral->{quantity} > 0;
|
||||
$variants{$collateral->{variantId}} = join ", ", $collateral->{shortdesc}, sprintf('%.2f',$collateral->{price});
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ use lib "$FindBin::Bin/../../lib";
|
|||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
use HTML::Form;
|
||||
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
|
|
@ -34,7 +36,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 8; # Increment this number for each test you create
|
||||
plan tests => 10; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -51,6 +53,8 @@ my $image = WebGUI::Storage->create($session);
|
|||
WebGUI::Test->storagesToDelete($image);
|
||||
$image->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg'));
|
||||
|
||||
WebGUI::Test->tagsToRollback(WebGUI::VersionTag->getWorking($session));
|
||||
|
||||
my $imagedProduct = $node->addChild({
|
||||
className => "WebGUI::Asset::Sku::Product",
|
||||
title => "Bible",
|
||||
|
|
@ -81,16 +85,27 @@ my $englishVarId = $imagedProduct->setCollateral('variantsJSON', 'variantId', 'n
|
|||
}
|
||||
);
|
||||
|
||||
use Data::Dumper;
|
||||
my $otherVarId = $imagedProduct->setCollateral('variantsJSON', 'variantId', 'new',
|
||||
{
|
||||
shortdesc => 'Elbonian',
|
||||
varSku => 'Elbonian-bible',
|
||||
price => 11,
|
||||
weight => 7,
|
||||
quantity => 0,
|
||||
}
|
||||
);
|
||||
|
||||
$imagedProduct->applyOptions($imagedProduct->getCollateral('variantsJSON', 'variantId', $englishVarId));
|
||||
|
||||
is($imagedProduct->getConfiguredTitle, 'Bible - English', 'getConfiguredTitle is overridden and concatenates the Product Title and the variant shortdesc');
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$product->purge;
|
||||
$imagedProduct->purge;
|
||||
}
|
||||
|
||||
1;
|
||||
my $addToCartForm = $imagedProduct->getAddToCartForm();
|
||||
diag $addToCartForm;
|
||||
my @forms = HTML::Form->parse($addToCartForm, 'http://www.webgui.org');
|
||||
is(scalar @forms, 1, 'getAddToCartForm: returns only 1 form');
|
||||
my $form_variants = $forms[0]->find_input('vid');
|
||||
cmp_deeply(
|
||||
[ $englishVarId ],
|
||||
[ $form_variants->possible_values ],
|
||||
'... form only has 1 variant, since the other one has 0 quantity'
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue