Remove old form JS. Display shipping information, but not the address. Do not format currency unless it exists. Template support.
This commit is contained in:
parent
7826e3aea3
commit
fa48f2eca9
2 changed files with 47 additions and 59 deletions
Binary file not shown.
|
|
@ -846,18 +846,6 @@ sub www_view {
|
||||||
if($url->forceSecureConnection()){
|
if($url->forceSecureConnection()){
|
||||||
return "redirect";
|
return "redirect";
|
||||||
}
|
}
|
||||||
# set up html header
|
|
||||||
$session->style->setRawHeadTags(q|
|
|
||||||
<script type="text/javascript">
|
|
||||||
function setCallbackForAddressChooser (form, itemId) {
|
|
||||||
form.shop.value='address';
|
|
||||||
form.method.value='view';
|
|
||||||
itemId = (itemId == undefined) ? 'null' : "'" + itemId + "'";
|
|
||||||
form.callback.value='{"url":"|.$url->page.q|","params":[{"name":"shop","value":"cart"},{"name":"method","value":"setShippingAddress"},{"name":"itemId","value":'+itemId+'}]}';
|
|
||||||
form.submit();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|);
|
|
||||||
|
|
||||||
my @cartItems = @{$self->getItems};
|
my @cartItems = @{$self->getItems};
|
||||||
if(scalar(@cartItems) < 1) {
|
if(scalar(@cartItems) < 1) {
|
||||||
|
|
@ -886,7 +874,7 @@ sub www_view {
|
||||||
my %properties = (
|
my %properties = (
|
||||||
%{$item->get},
|
%{$item->get},
|
||||||
url => $sku->getUrl("shop=cart;method=viewItem;itemId=".$item->getId),
|
url => $sku->getUrl("shop=cart;method=viewItem;itemId=".$item->getId),
|
||||||
quantityField => WebGUI::Form::integer($session, {name=>"quantity-".$item->getId, value=>$item->get("quantity")}),
|
quantityField => WebGUI::Form::integer($session, {name=>"quantity-".$item->getId, value=>$item->get("quantity"), size=>5,}),
|
||||||
isUnique => ($sku->getMaxAllowedInCart == 1),
|
isUnique => ($sku->getMaxAllowedInCart == 1),
|
||||||
isShippable => $sku->isShippingRequired,
|
isShippable => $sku->isShippingRequired,
|
||||||
extendedPrice => $self->formatCurrency($sku->getPrice * $item->get("quantity")),
|
extendedPrice => $self->formatCurrency($sku->getPrice * $item->get("quantity")),
|
||||||
|
|
@ -912,18 +900,14 @@ sub www_view {
|
||||||
%{$self->get},
|
%{$self->get},
|
||||||
items => \@items,
|
items => \@items,
|
||||||
formHeader => WebGUI::Form::formHeader($session)
|
formHeader => WebGUI::Form::formHeader($session)
|
||||||
. WebGUI::Form::hidden($session, {name=>"shop", value=>"cart"})
|
. WebGUI::Form::hidden($session, {name=>"shop", value=>"cart"})
|
||||||
. WebGUI::Form::hidden($session, {name=>"method", value=>"update"})
|
. WebGUI::Form::hidden($session, {name=>"method", value=>"update"})
|
||||||
. WebGUI::Form::hidden($session, {name=>"itemId", value=>""})
|
. WebGUI::Form::hidden($session, {name=>"itemId", value=>""})
|
||||||
. WebGUI::Form::hidden($session, {name=>"callback", value=>""}),
|
,
|
||||||
formFooter => WebGUI::Form::formFooter($session),
|
formFooter => WebGUI::Form::formFooter($session),
|
||||||
updateButton => WebGUI::Form::submit($session, {value=>$i18n->get("update cart button"), extras=>q|id="updateCartButton"|}),
|
updateButton => WebGUI::Form::submit($session, {value=>$i18n->get("update cart button"), extras=>q|id="updateCartButton"|}),
|
||||||
continueShoppingButton => WebGUI::Form::submit($session, {value=>$i18n->get("continue shopping button"),
|
continueShoppingButton => WebGUI::Form::submit($session, {value=>$i18n->get("continue shopping button"),
|
||||||
extras=>q|onclick="this.form.method.value='continueShopping';this.form.submit;" id="continueShoppingButton"|}),
|
extras=>q|onclick="this.form.method.value='continueShopping';this.form.submit;" id="continueShoppingButton"|}),
|
||||||
# chooseShippingButton => WebGUI::Form::submit($session, {value=>$i18n->get("choose shipping button"),
|
|
||||||
# extras=>q|onclick="setCallbackForAddressChooser(this.form);" id="chooseAddressButton"|}),
|
|
||||||
# shipToButton => WebGUI::Form::submit($session, {value=>$i18n->get("ship to button"),
|
|
||||||
# extras=>q|onclick="setCallbackForAddressChooser(this.form);"|}),
|
|
||||||
subtotalPrice => $self->formatCurrency($self->calculateSubtotal()),
|
subtotalPrice => $self->formatCurrency($self->calculateSubtotal()),
|
||||||
minimumCartAmount => $session->setting->get( 'shopCartCheckoutMinimum' ) > 0
|
minimumCartAmount => $session->setting->get( 'shopCartCheckoutMinimum' ) > 0
|
||||||
? sprintf( '%.2f', $session->setting->get( 'shopCartCheckoutMinimum' ) )
|
? sprintf( '%.2f', $session->setting->get( 'shopCartCheckoutMinimum' ) )
|
||||||
|
|
@ -931,50 +915,54 @@ sub www_view {
|
||||||
,
|
,
|
||||||
shippableItemsInCart => $shippableItemsInCart,
|
shippableItemsInCart => $shippableItemsInCart,
|
||||||
);
|
);
|
||||||
|
$session->log->warn('after item loop');
|
||||||
|
|
||||||
# if there is no shipping address we can't check out
|
# if there is no shipping address we can't check out
|
||||||
# if (WebGUI::Error->caught) {
|
# if (WebGUI::Error->caught) {
|
||||||
# $var{shippingPrice} = $var{tax} = $self->formatCurrency(0);
|
# $var{shippingPrice} = $var{tax} = $self->formatCurrency(0);
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# # if there is a shipping address calculate tax and shipping options
|
# if there is a shipping address calculate tax and shipping options
|
||||||
# if ($address) {
|
if ($address) {
|
||||||
# $var{hasShippingAddress} = 1;
|
$session->log->warn('has address');
|
||||||
# $var{shippingAddress} = $address->getHtmlFormatted;
|
my $ship = WebGUI::Shop::Ship->new($self->session);
|
||||||
# my $ship = WebGUI::Shop::Ship->new($self->session);
|
my $options = $ship->getOptions($self);
|
||||||
# my $options = $ship->getOptions($self);
|
my $numberOfOptions = scalar keys %{ $options };
|
||||||
# my $numberOfOptions = scalar keys %{ $options };
|
if ($numberOfOptions < 1) {
|
||||||
# if ($numberOfOptions < 1) {
|
$session->log->warn('no shipping plugins');
|
||||||
# $var{shippingOptions} = '';
|
$var{shippingOptions} = '';
|
||||||
# $var{shippingPrice} = 0;
|
$var{shippingPrice} = 0;
|
||||||
# $error{id $self} = $i18n->get("No shipping plugins configured");
|
$error{id $self} = $i18n->get("No shipping plugins configured");
|
||||||
# }
|
}
|
||||||
# elsif ($numberOfOptions == 1) {
|
elsif ($numberOfOptions == 1) {
|
||||||
# my ($option) = keys %{ $options };
|
$session->log->warn('only 1 shipping plugin');
|
||||||
# $self->update({ shipperId => $option });
|
my ($option) = keys %{ $options };
|
||||||
# $var{shippingPrice} = $options->{$self->get("shipperId")}->{price};
|
$self->update({ shipperId => $option });
|
||||||
# $var{shippingPrice} = $self->formatCurrency($var{shippingPrice});
|
$session->log->warn('shipping price: '. $options->{$options}->{price});
|
||||||
# }
|
$var{shippingPrice} = $options->{$option}->{hasPrice} ? $self->formatCurrency($options->{$option}->{price}) : '';
|
||||||
# else {
|
$var{shippingOptions} = $options->{$option}->{label};
|
||||||
# tie my %formOptions, 'Tie::IxHash';
|
}
|
||||||
# $formOptions{''} = $i18n->get('Choose a shipping method');
|
else {
|
||||||
# foreach my $option (keys %{$options}) {
|
$session->log->warn('building dropdown');
|
||||||
# $formOptions{$option} = $options->{$option}{label}." (".$self->formatCurrency($options->{$option}{price}).")";
|
tie my %formOptions, 'Tie::IxHash';
|
||||||
# }
|
$formOptions{''} = $i18n->get('Choose a shipping method');
|
||||||
# $var{shippingOptions} = WebGUI::Form::selectBox($session, {name=>"shipperId", options=>\%formOptions, value=>$self->get("shipperId")});
|
foreach my $option (keys %{$options}) {
|
||||||
# if (!exists $options->{$self->get('shipperId')}) {
|
$formOptions{$option} = $options->{$option}{label}." (".$self->formatCurrency($options->{$option}{price} || 0).")";
|
||||||
# $self->update({shipperId => ''});
|
}
|
||||||
# }
|
$var{shippingOptions} = WebGUI::Form::selectBox($session, {name=>"shipperId", options=>\%formOptions, value=>$self->get("shipperId") || ''});
|
||||||
# if (my $shipperId = $self->get('shipperId')) {
|
if (!exists $options->{$self->get('shipperId')}) {
|
||||||
# $var{shippingPrice} = $options->{$shipperId}->{price};
|
$self->update({shipperId => ''});
|
||||||
# }
|
}
|
||||||
# else {
|
if (my $shipperId = $self->get('shipperId')) {
|
||||||
# $var{shippingPrice} = 0;
|
$var{shippingPrice} = $options->{$shipperId}->{price};
|
||||||
# $error{id $self} = ($i18n->get('Choose a shipping method and update the cart to checkout'));
|
}
|
||||||
# }
|
else {
|
||||||
# $var{shippingPrice} = $self->formatCurrency($var{shippingPrice});
|
$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}) : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
#
|
#
|
||||||
# # Tax variables
|
# # Tax variables
|
||||||
# $var{tax} = $self->calculateTaxes;
|
# $var{tax} = $self->calculateTaxes;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue