Handle cases of no shipping plugin, and optional price formatting for shipping.

This commit is contained in:
Colin Kuskie 2010-04-26 15:20:04 -07:00
parent ce26a84e87
commit a26f85c8c0

View file

@ -947,20 +947,25 @@ sub www_view {
tie my %formOptions, 'Tie::IxHash';
$formOptions{''} = $i18n->get('Choose a shipping method');
foreach my $option (keys %{$options}) {
$formOptions{$option} = $options->{$option}{label}." (".$self->formatCurrency($options->{$option}{price} || 0).")";
$formOptions{$option} = $options->{$option}{label};
if ($options->{$options}->{hasPrice}) {
$formOptions{$option} .= ' ('.$self->formatCurrency($options->{$option}{price}).')';
}
}
$var{shippingOptions} = WebGUI::Form::selectBox($session, {name=>"shipperId", options=>\%formOptions, value=>$self->get("shipperId") || ''});
if (!exists $options->{$self->get('shipperId')}) {
my $shipperId = $self->get('shipperId');
if (!exists $options->{$shipperId}) {
$self->update({shipperId => ''});
$shipperId = '';
}
if (my $shipperId = $self->get('shipperId')) {
if ($shipperId) {
$var{shippingPrice} = $options->{$shipperId}->{price};
}
else {
$var{shippingPrice} = 0;
$error{id $self} = ($i18n->get('Choose a shipping method and update the cart to checkout'));
}
$var{shippingPrice} = $options->{$shipperId}->{hasPrice} ? $self->formatCurrency($var{shippingPrice}) : '';
$var{shippingPrice} = $shipperId && $options->{$shipperId}->{hasPrice} ? $self->formatCurrency($var{shippingPrice}) : '';
}
}
#