Adds SFRA 6.0
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
'use strict';
|
||||
|
||||
var productInventoryMgr = {
|
||||
getInventoryList: function (inventoryListId) {
|
||||
var inventoryListId0001 = {
|
||||
getRecord: function (productID) {
|
||||
var product000001 = {
|
||||
ATS: { value: 10 }
|
||||
};
|
||||
|
||||
var product000002 = {
|
||||
ATS: { value: 3 }
|
||||
};
|
||||
|
||||
var product000003 = {
|
||||
ATS: { value: 5 }
|
||||
};
|
||||
|
||||
if (productID === '000001') {
|
||||
return product000001;
|
||||
} else if (productID === '000002') {
|
||||
return product000002;
|
||||
} else if (productID === '000003') {
|
||||
return product000003;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
var inventoryListId0002 = {
|
||||
getRecord: function (productID) {
|
||||
var product000001 = {
|
||||
ATS: { value: 0 }
|
||||
};
|
||||
|
||||
var product000002 = {
|
||||
ATS: { value: 8 }
|
||||
};
|
||||
|
||||
var product000003 = {
|
||||
ATS: { value: 10 }
|
||||
};
|
||||
|
||||
if (productID === '000001') {
|
||||
return product000001;
|
||||
} else if (productID === '000002') {
|
||||
return product000002;
|
||||
} else if (productID === '000003') {
|
||||
return product000003;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
var inventoryListId0003 = {
|
||||
getRecord: function (productID) {
|
||||
var product000001 = {
|
||||
ATS: { value: 10 }
|
||||
};
|
||||
|
||||
var product000002 = {
|
||||
ATS: { value: 15 }
|
||||
};
|
||||
|
||||
var product000003 = {
|
||||
ATS: { value: 8 }
|
||||
};
|
||||
|
||||
if (productID === '000001') {
|
||||
return product000001;
|
||||
} else if (productID === '000002') {
|
||||
return product000002;
|
||||
} else if (productID === '000003') {
|
||||
return product000003;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
if (inventoryListId === 'inventoryListId0001') {
|
||||
return inventoryListId0001;
|
||||
} else if (inventoryListId === 'inventoryListId0002') {
|
||||
return inventoryListId0002;
|
||||
} else if (inventoryListId === 'inventoryListId0003') {
|
||||
return inventoryListId0003;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
getInventoryList: productInventoryMgr.getInventoryList
|
||||
};
|
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
var storeMgr = {
|
||||
searchStoresByPostalCode: function () {
|
||||
return {
|
||||
keySet: function () {
|
||||
return [{
|
||||
ID: 'Any ID',
|
||||
name: 'Downtown TV Shop',
|
||||
address1: '333 Washington St',
|
||||
address2: '',
|
||||
city: 'Boston',
|
||||
postalCode: '01803',
|
||||
phone: '333-333-3333',
|
||||
stateCode: 'MA',
|
||||
countryCode: {
|
||||
value: 'us'
|
||||
},
|
||||
latitude: 42.5273334,
|
||||
longitude: -71.13758250000001,
|
||||
storeHours: {
|
||||
markup: 'Mon - Sat: 10am - 9pm'
|
||||
}
|
||||
}];
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
searchStoresByCoordinates: function () {
|
||||
return {
|
||||
keySet: function () {
|
||||
return [{
|
||||
ID: 'Any ID',
|
||||
name: 'Downtown TV Shop',
|
||||
address1: '333 Washington St',
|
||||
address2: '',
|
||||
city: 'Boston',
|
||||
postalCode: '01803',
|
||||
phone: '333-333-3333',
|
||||
stateCode: 'MA',
|
||||
countryCode: {
|
||||
value: 'us'
|
||||
},
|
||||
latitude: 42.5273334,
|
||||
longitude: -71.13758250000001,
|
||||
storeHours: {
|
||||
markup: 'Mon - Sat: 10am - 9pm'
|
||||
}
|
||||
}];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
searchStoresByPostalCode: storeMgr.searchStoresByPostalCode,
|
||||
searchStoresByCoordinates: storeMgr.searchStoresByCoordinates
|
||||
};
|
@@ -0,0 +1,35 @@
|
||||
|
||||
function getCurrentBasket() {
|
||||
return {
|
||||
defaultShipment: {
|
||||
shippingAddress: {
|
||||
firstName: 'Amanda',
|
||||
lastName: 'Jones',
|
||||
address1: '65 May Lane',
|
||||
address2: '',
|
||||
city: 'Allston',
|
||||
postalCode: '02135',
|
||||
countryCode: { value: 'us' },
|
||||
phone: '617-555-1234',
|
||||
stateCode: 'MA',
|
||||
|
||||
setFirstName: function (firstNameInput) { this.firstName = firstNameInput; },
|
||||
setLastName: function (lastNameInput) { this.lastName = lastNameInput; },
|
||||
setAddress1: function (address1Input) { this.address1 = address1Input; },
|
||||
setAddress2: function (address2Input) { this.address2 = address2Input; },
|
||||
setCity: function (cityInput) { this.city = cityInput; },
|
||||
setPostalCode: function (postalCodeInput) { this.postalCode = postalCodeInput; },
|
||||
setStateCode: function (stateCodeInput) { this.stateCode = stateCodeInput; },
|
||||
setCountryCode: function (countryCodeInput) { this.countryCode.value = countryCodeInput; },
|
||||
setPhone: function (phoneInput) { this.phone = phoneInput; }
|
||||
}
|
||||
},
|
||||
totalGrossPrice: {
|
||||
value: 250.00
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getCurrentBasket: getCurrentBasket
|
||||
};
|
@@ -0,0 +1,73 @@
|
||||
|
||||
var ArrayList = require('../../../mocks/dw.util.Collection');
|
||||
|
||||
var defaultShippingMethod =
|
||||
{
|
||||
description: 'Order received within 7-10 business days',
|
||||
displayName: 'Ground',
|
||||
ID: '001',
|
||||
custom: {
|
||||
estimatedArrivalTime: '7-10 Business Days'
|
||||
}
|
||||
};
|
||||
|
||||
function createShipmentShippingModel() {
|
||||
return {
|
||||
applicableShippingMethods: new ArrayList([
|
||||
{
|
||||
description: 'Order received within 7-10 business days',
|
||||
displayName: 'Ground',
|
||||
ID: '001',
|
||||
custom: {
|
||||
estimatedArrivalTime: '7-10 Business Days'
|
||||
}
|
||||
},
|
||||
{
|
||||
description: 'Order received in 2 business days',
|
||||
displayName: '2-Day Express',
|
||||
ID: '002',
|
||||
shippingCost: '$0.00',
|
||||
custom: {
|
||||
estimatedArrivalTime: '2 Business Days'
|
||||
}
|
||||
}
|
||||
]),
|
||||
getApplicableShippingMethods: function () {
|
||||
return new ArrayList([
|
||||
{
|
||||
description: 'Order received within 7-10 business days',
|
||||
displayName: 'Ground',
|
||||
ID: '001',
|
||||
custom: {
|
||||
estimatedArrivalTime: '7-10 Business Days'
|
||||
}
|
||||
},
|
||||
{
|
||||
description: 'Order received in 2 business days',
|
||||
displayName: '2-Day Express',
|
||||
ID: '002',
|
||||
shippingCost: '$0.00',
|
||||
custom: {
|
||||
estimatedArrivalTime: '2 Business Days'
|
||||
}
|
||||
}
|
||||
]);
|
||||
},
|
||||
getShippingCost: function () {
|
||||
return {
|
||||
amount: {
|
||||
valueOrNull: 7.99
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getDefaultShippingMethod: function () {
|
||||
return defaultShippingMethod;
|
||||
},
|
||||
getShipmentShippingModel: function (shipment) {
|
||||
return createShipmentShippingModel(shipment);
|
||||
}
|
||||
};
|
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var properties = require('properties-parser');
|
||||
const locale = 'x_default';
|
||||
|
||||
function msg(key, bundleName, defaultValue) {
|
||||
let bundlePath;
|
||||
let props;
|
||||
const resourceDirPath = './cartridges/app_storefront_base/cartridge/templates/resources/';
|
||||
if (!key) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (bundleName) {
|
||||
if (locale !== 'x_default') {
|
||||
bundlePath = path.resolve(resourceDirPath + bundleName + '_' + locale + '.properties');
|
||||
try {
|
||||
props = properties.read(bundlePath);
|
||||
if (props[key]) {
|
||||
return props[key];
|
||||
}
|
||||
} catch (e) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
bundlePath = path.resolve(resourceDirPath + bundleName + '.properties');
|
||||
try {
|
||||
props = properties.read(bundlePath);
|
||||
if (props[key]) {
|
||||
return props[key];
|
||||
}
|
||||
} catch (e) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
return defaultValue || key;
|
||||
}
|
||||
|
||||
function msgf() {
|
||||
// pass through to msg if there are no extra format arguments
|
||||
if (arguments.length < 4) {
|
||||
return msg.apply(null, arguments);
|
||||
}
|
||||
let args = Array.prototype.slice.call(arguments);
|
||||
let value = msg.apply(null, args.slice(0, 3));
|
||||
return value.replace(/{(\d)}/g, function (match, p) {
|
||||
let position = Number(p);
|
||||
if (args[position + 3]) {
|
||||
return args[position + 3];
|
||||
// if no arguments found, return the original placeholder
|
||||
}
|
||||
return match;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
msg: msg,
|
||||
msgf: msgf,
|
||||
locale: locale
|
||||
};
|
Reference in New Issue
Block a user