Adding minimum checkout amount.
This commit is contained in:
parent
5176e17522
commit
0a12c20691
6 changed files with 61 additions and 6 deletions
|
|
@ -19,6 +19,7 @@
|
|||
- added Survey now has a loading mask on Survey edit ajax calls.
|
||||
- fixed: Sliders fixed. Improved algorithm for determining pixel step size.
|
||||
- rfe #9355: Password Recovery email subject (SDH Consulting Group)
|
||||
- added: Users can now set a minimum cart amount required for checkout. (Martin Kamerbeek / Oqapi )
|
||||
|
||||
7.6.14
|
||||
- fixed: IE6 shows Admin Bar over Asset Manager
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -39,6 +39,7 @@ surveyDoAfterTimeLimit($session);
|
|||
surveyRemoveResponseTemplate($session);
|
||||
surveyEndWorkflow($session);
|
||||
installAssetHistory($session);
|
||||
addMinimumCartCheckoutSetting( $session );
|
||||
|
||||
# Passive Analytics
|
||||
pa_installLoggingTables($session);
|
||||
|
|
@ -303,13 +304,23 @@ sub addTransactionItemFlags {
|
|||
#----------------------------------------------------------------------------
|
||||
sub createShopAcccountPluginSettings {
|
||||
my $session = shift;
|
||||
print "Creating default settings for the account plugin..." unless $quiet;
|
||||
print "\tCreating default settings for the account plugin..." unless $quiet;
|
||||
|
||||
$session->setting->add('shopMySalesTemplateId', '-zxyB-O50W8YnL39Ouoc4Q');
|
||||
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub addMinimumCartCheckoutSetting {
|
||||
my $session = shift;
|
||||
print "\tAdding setting for minimum cart checkout..." unless $quiet;
|
||||
|
||||
$session->setting->add( 'shopCartCheckoutMinimum', '0.00' );
|
||||
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
#sub exampleFunction {
|
||||
|
|
|
|||
|
|
@ -152,6 +152,13 @@ sub www_editSettings {
|
|||
label => $i18n->get('who is a cashier'),
|
||||
hoverHelp => $i18n->get('who is a cashier help'),
|
||||
);
|
||||
$form->float(
|
||||
name => 'shopCartCheckoutMinimum',
|
||||
value => $setting->get('shopCartCheckoutMinimum'),
|
||||
defaultValue=> '0.00',
|
||||
label => $i18n->get('cart checkout minimum'),
|
||||
hoverHelp => $i18n->get('cart checkout minimum help'),
|
||||
);
|
||||
$form->template(
|
||||
name => "shopCartTemplateId",
|
||||
value => $setting->get("shopCartTemplateId"),
|
||||
|
|
@ -203,13 +210,21 @@ sub www_editSettingsSave {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->adminOnly() unless ($self->session->user->isAdmin);
|
||||
my ($setting, $form) = $self->session->quick(qw(setting form));
|
||||
|
||||
# Save shop templates
|
||||
foreach my $template (qw(shopMyPurchasesDetailTemplateId shopMyPurchasesTemplateId
|
||||
shopCartTemplateId shopAddressBookTemplateId shopAddressTemplateId)) {
|
||||
$setting->set($template, $form->get($template, "template"));
|
||||
}
|
||||
|
||||
# Save group settings
|
||||
foreach my $group (qw(groupIdCashier groupIdAdminCommerce)) {
|
||||
$setting->set($group, $form->get($group, "group"));
|
||||
}
|
||||
|
||||
# Save mininmum cart checkout
|
||||
$setting->set( 'shopCartCheckoutMinimum', $form->get( 'shopCartCheckoutMinimum', 'float' ) );
|
||||
|
||||
return $self->www_editSettings();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ Returns whether all the required properties of the the cart are set.
|
|||
|
||||
sub readyForCheckout {
|
||||
my $self = shift;
|
||||
|
||||
|
||||
# Check if the shipping address is set and correct
|
||||
my $address = eval{$self->getShippingAddress};
|
||||
return 0 if WebGUI::Error->caught;
|
||||
|
|
@ -513,6 +513,12 @@ sub readyForCheckout {
|
|||
# fail if there are multiple recurring items or if
|
||||
return 0 if ($self->hasMixedItems);
|
||||
|
||||
# Check minimum cart checkout requirement
|
||||
my $requiredAmount = $self->session->setting->get( 'shopCartCheckoutMinimum' );
|
||||
if ( $requiredAmount > 0 ) {
|
||||
return 0 if $self->calculateTotal < $requiredAmount;
|
||||
}
|
||||
|
||||
# All checks passed so return true
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -801,6 +807,10 @@ sub www_view {
|
|||
shipToButton => WebGUI::Form::submit($session, {value=>$i18n->get("ship to button"),
|
||||
extras=>q|onclick="setCallbackForAddressChooser(this.form);"|}),
|
||||
subtotalPrice => $self->formatCurrency($self->calculateSubtotal()),
|
||||
minimumCartAmount => $session->setting->get( 'shopCartCheckoutMinimum' ) > 0
|
||||
? sprintf( '%.2f', $session->setting->get( 'shopCartCheckoutMinimum' ) )
|
||||
: 0
|
||||
,
|
||||
);
|
||||
|
||||
# get the shipping address
|
||||
|
|
@ -846,10 +856,11 @@ sub www_view {
|
|||
# calculate price adjusted for in-store credit
|
||||
$var{totalPrice} = $var{subtotalPrice} + $var{shippingPrice} + $var{tax};
|
||||
my $credit = WebGUI::Shop::Credit->new($session, $posUser->userId);
|
||||
$var{inShopCreditAvailable} = $credit->getSum;
|
||||
$var{inShopCreditDeduction} = $credit->calculateDeduction($var{totalPrice});
|
||||
$var{totalPrice} = $self->formatCurrency($var{totalPrice} + $var{inShopCreditDeduction});
|
||||
|
||||
$var{ inShopCreditAvailable } = $credit->getSum;
|
||||
$var{ inShopCreditDeduction } = $credit->calculateDeduction($var{totalPrice});
|
||||
$var{ totalPrice } = $self->formatCurrency($var{totalPrice} + $var{inShopCreditDeduction});
|
||||
$var{ readyForCheckout } = $self->readyForCheckout;
|
||||
|
||||
# render the cart
|
||||
my $template = WebGUI::Asset::Template->new($session, $session->setting->get("shopCartTemplateId"));
|
||||
return $session->style->userStyle($template->process(\%var));
|
||||
|
|
|
|||
|
|
@ -1528,6 +1528,23 @@ our $I18N = {
|
|||
context => q|template variable for Cart template|,
|
||||
},
|
||||
|
||||
'cart checkout minimum' => {
|
||||
message => q|Minimum checkout amount|,
|
||||
lastUpdated => 0,
|
||||
context => q|shop setting label|,
|
||||
},
|
||||
|
||||
'cart checkout minimum help' => {
|
||||
message => q|Use this setting to require a minimum cart value to allow users to check out.|,
|
||||
lastUpdated => 0,
|
||||
context => q|shop setting hover help|,
|
||||
},
|
||||
|
||||
'required minimum order amount' => {
|
||||
message => q|Minimum order:|,
|
||||
lastUpdated => 0,
|
||||
context => q|message that is displayed in the cart view screen|,
|
||||
},
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue