Free shipping when paymentGateway is set to instore
parent
445c4f62ff
commit
ede44c856b
|
@ -132,7 +132,7 @@ const updateTotalCart = (req, res) => {
|
||||||
req.session.totalCartItems = Object.keys(req.session.cart).length;
|
req.session.totalCartItems = Object.keys(req.session.cart).length;
|
||||||
|
|
||||||
// Calculate shipping using the loaded module
|
// 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){
|
if(shippingCost > 0){
|
||||||
req.session.totalCartShipping = parseInt(shippingCost);
|
req.session.totalCartShipping = parseInt(shippingCost);
|
||||||
req.session.totalCartAmount = req.session.totalCartAmount + parseInt(shippingCost);
|
req.session.totalCartAmount = req.session.totalCartAmount + parseInt(shippingCost);
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
const shippingAmount = 10;
|
const shippingAmount = 10;
|
||||||
const freeThreshold = 100;
|
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){
|
if(amount >= freeThreshold){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue