Skip to content

Instantly share code, notes, and snippets.

View allenmichael's full-sized avatar

Allen-Michael Grobelny allenmichael

  • Amazon Web Services
  • Austin, TX
  • X @amsxbg
View GitHub Profile
module.exports = function(context, callback) {
var rates = context.response.body.rates;
for(var i = 0; i < rates.length; i++) {
console.info(rates[i]);
for(var j = 0; j < rates[i].shippingRates.length; j++) {
console.info("\t\t" + rates[i].shippingRates[j].content.name);
console.info("\t\t" + rates[i].shippingRates[j].amount);
}
}
callback();
module.exports = function(context, callback) {
console.info(context.response.body.rates[0]);
console.info(context.response.body.rates[0].shippingRates[0]);
console.info(context.response.body.rates[0].shippingRates[0].amount);
callback();
};
module.exports = function(context, callback) {
var rates = context.response.body.rates;
var shippingRate;
try{
for(var i = 0; i < rates.length; i++) {
for(var j = 0; j < rates[i].shippingRates.length; j++) {
shippingRate = context.response.body.rates[i].shippingRates[j].amount;
context.response.body.rates[i].shippingRates[j].amount = Math.floor((shippingRate + (context.response.body.rates[i].shippingRates[j].amount * 0.25)));
}
}
module.exports = function(context, callback) {
try {
var firstShippingRatePrice = context.response.body.rates[0].shippingRates[0].amount;
context.response.body.rates[0].shippingRates[0].amount = Math.floor(firstShippingRatePrice + (firstShippingRatePrice * 0.25));
} catch(err) {
console.error(err);
}
callback();
};
@allenmichael
allenmichael / actionManagement.json
Last active December 23, 2015 19:45
Action Management JSON for Arc.js BED Class
{
"actions": [
{
"actionId": "http.commerce.catalog.storefront.shipping.requestRates.after",
"contexts": [
{
"customFunctions": [
{
"applicationKey": "Grobelny.CleanSlateArcApp.1.0.0.Release",
"functionId": "http.commerce.catalog.storefront.shipping.requestRates.after",
@allenmichael
allenmichael / gruntTaskArcjs.js
Created December 23, 2015 19:23
A Grunt task to add to your Gruntfile.js
grunt.registerTask('delActionDomain', 'Deleting the specified action domain...', function(actionDomainName) {
//Load the Yeoman file as a variable
var yoFile = grunt.file.readJSON('./.yo-rc.json');
//Always delete dist folder and functions.json -- grunt build will recreate these files using manifests
grunt.file.delete('./assets/dist');
grunt.file.delete('./assets/functions.json');
if(actionDomainName) {
//Delete domain folder
grunt.file.delete('./assets/src/domains/' + actionDomainName);
//Retrieve each action listed in the Yeoman file
@allenmichael
allenmichael / arcjsUnitTestExample.js
Created December 23, 2015 19:23
An example of creating a unit test for an Arc.js action
/**
* This is a scaffold for unit tests for the custom function for
* `embedded.commerce.carts.addItem.before`.
* Modify the test conditions below. You may:
* - add special assertions for code actions from Simulator.assert
* - create a mock context with Simulator.context() and modify it
* - use and modify mock Mozu business objects from Simulator.fixtures
*/
'use strict';
@allenmichael
allenmichael / DigitalPackage.cs
Created December 10, 2015 21:42
Create a digital package
var order = orderResource.GetOrderAsync(orderId).Result;
var digitalPackageResource = new Mozu.Api.Resources.Commerce.Orders.DigitalPackageResource(_apiContext);
var digitalPackageItem = new Mozu.Api.Contracts.CommerceRuntime.Fulfillment.DigitalPackageItem()
{
ProductCode = order.Items[0].Product.ProductCode,
Quantity = order.Items[0].Quantity
};
var digitalPackage = new Mozu.Api.Contracts.CommerceRuntime.Fulfillment.DigitalPackage()
@allenmichael
allenmichael / deleteSubnavlinks.cs
Created December 10, 2015 21:32
Delete all entities from subnavlinks
@allenmichael
allenmichael / catalogSubnav.cs
Last active December 10, 2015 21:53
Add subnavlink to catalog parent page
public class SubnavLink
{
public string parentId { get; set; }
public string[] path { get; set; }
public string href { get; set; }
public string appId { get; set; }
public string windowTitle { get; set; }
}
[TestMethod]