Free shipping when paymentGateway is set to instore

master
Mark Moffat 2020-01-03 22:47:04 +10:30
parent 445c4f62ff
commit ede44c856b
2 changed files with 6 additions and 2 deletions

View File

@ -132,7 +132,7 @@ const updateTotalCart = (req, res) => {
req.session.totalCartItems = Object.keys(req.session.cart).length;
// Calculate shipping using the loaded module
const shippingCost = config.modules.loaded.shipping.calculateShipping(req.session.totalCartAmount);
const shippingCost = config.modules.loaded.shipping.calculateShipping(req.session.totalCartAmount, config);
if(shippingCost > 0){
req.session.totalCartShipping = parseInt(shippingCost);
req.session.totalCartAmount = req.session.totalCartAmount + parseInt(shippingCost);

View File

@ -1,7 +1,11 @@
const shippingAmount = 10;
const freeThreshold = 100;
const calculateShipping = (amount) => {
const calculateShipping = (amount, config) => {
// When set to instore shipping is not applicable.
if(config.paymentGateway === 'instore'){
return 0;
}
if(amount >= freeThreshold){
return 0;
}