Skip to content

Instantly share code, notes, and snippets.

View Mozu-CS's full-sized avatar

Mozu CS Mozu-CS

  • Volusion Inc.
  • 1835 Kramer Ln #100, Austin, TX 78758
View GitHub Profile
@Mozu-CS
Mozu-CS / Bootstrapper.cs
Last active April 1, 2016 18:26
Basic C# Mozu example
using Mozu.Api.ToolKit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AMSXBGCONSOLE
{
class Bootstrapper : AbstractBootstrapper
@Mozu-CS
Mozu-CS / arcjs_configuration_demo.json
Created March 2, 2016 15:15
An example using configuration variables within Arc.js
{
"actions": [
{
"actionId": "http.commerce.catalog.storefront.shipping.requestRates.after",
"contexts": [
{
"customFunctions": [
{
"applicationKey": "DevTrain.AMSXBG_Arc.1.0.0.Release",
"functionId": "http.commerce.catalog.storefront.shipping.requestRates.after",
<select name="cc-static" id="cc-static">
<option>---</option>
<option {% if model.expireYear == "2014" %}selected="selected"{% endif %} value="2014">2014</option>
<option {% if model.expireYear == "2015" %}selected="selected"{% endif %} value="2015">2015</option>
<option {% if model.expireYear == "2016" %}selected="selected"{% endif %} value="2016">2016</option>
<option {% if model.expireYear == "2017" %}selected="selected"{% endif %} value="2017">2017</option>
<option {% if model.expireYear == "2018" %}selected="selected"{% endif %} value="2018">2018</option>
<option {% if model.expireYear == "2019" %}selected="selected"{% endif %} value="2019">2019</option>
<option {% if model.expireYear == "2020" %}selected="selected"{% endif %} value="2020">2020</option>
<option {% if model.expireYear == "2021" %}selected="selected"{% endif %} value="2021">2021</option>
{% with pageContext.now|date('Y') as currentYear %}
{% with themeSettings.ccYears|default('0,1,2,3')|split(',') as ccYears %}
{% partial_cache currentYear, ccYears %}
<label for="cc-year-dynamic">CC Year: </label>
<select name="cc-year-dynamic" id="cc-year-dynamic" required>
<option>{{ themeSetting.blankOptionText|default('') }}</option>
{% for year in ccYears %}
<option value="{{ currentYear|add(year) }}"{% if model.expireYear == currentYear|add(year) %} selected="selected"{% endif %}>{{ currentYear|add(year) }}</option>
{% endfor %}
</select>
@Mozu-CS
Mozu-CS / UpdatePropertyValue.cs
Created February 22, 2016 23:56
A snippet for updating an existing property on a Product Type.
public void Update_Property_Value()
{
var propertyResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.Producttypes.ProductTypePropertyResource(_apiContext);
var attributeResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.AttributeResource(_apiContext);
var productTypeResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.ProductTypeResource(_apiContext);
var attribute = attributeResource.GetAttributeAsync("tenant~color").Result;
var existingProperty = propertyResource.GetPropertyAsync(17, "tenant~color").Result;
existingProperty.VocabularyValues.Add(new AttributeVocabularyValueInProductType()
{
Order = 0,
var serviceCall = require('../../util/needleRequest').makeSampleCall;
module.exports = function (context, callback) {
var sampleData = "<value>" + context.request.url + "</value>";
serviceCall(sampleData)
.then(function (responseFromCall) {
console.log(responseFromCall);
callback();
})
.catch(function(err) {
console.error(err);
@Mozu-CS
Mozu-CS / Add_Customer_To_Segment.cs
Created February 15, 2016 17:08
An example on how to add a customer to a customer segment
var customerSegmentResouce = new Mozu.Api.Resources.Commerce.Customer.CustomerSegmentResource(_apiContext);
var customerAccountResource = new Mozu.Api.Resources.Commerce.Customer.CustomerAccountResource(_apiContext);
var customerSegment = (customerSegmentResouce.GetSegmentsAsync(filter:"Name eq 'High Volume Customer'").Result).Items[0];
var customerAccountIds = new List<int>();
var customerAccount = (customerAccountResource.GetAccountsAsync(filter:"FirstName eq 'Malcolm'").Result).Items[0];
customerAccountIds.Add(customerAccount.Id);
if(!(customerAccount.Segments.Exists(x => x.Id == customerSegment.Id)))
@Mozu-CS
Mozu-CS / CreateOrder.cs
Last active February 13, 2019 01:20
Example demonstrating how to create a single order using the Mozu API
[TestMethod]
public void ImportOrder()
{
//create an instance of the order resource
var orderResource = new Mozu.Api.Resources.Commerce.OrderResource(_apiContext);
//map the order
var order = MapOrder();
//call create order method
@Mozu-CS
Mozu-CS / addLocation.js
Created February 11, 2016 01:06
A gist for adding locations through the API
var FiddlerProxy = require('mozu-node-sdk/plugins/fiddler-proxy');
var apiContext = require('mozu-node-sdk/clients/platform/application')();
apiContext.plugins = [FiddlerProxy];
var locationResource = require('mozu-node-sdk/clients/commerce/admin/location')(apiContext);
var location =
{
"code": "retailops1",
"locationTypes": [{ "code": "warehouse", "name": "Warehouse" }],
"fulfillmentTypes": [{ "code": "DS", "name": "Direct Ship", "shippingRequired": true }],
@Mozu-CS
Mozu-CS / context.request.body.json
Created February 5, 2016 19:38
Arc Action -- http.commerce.catalog.storefront.shipping.requestRates.before -- context.request.body contents example
{
"ISOCurrencyCode": "USD",
"OriginAddress": {
"Address1": "1835 Kramer Ln",
"Address2": "",
"Address3": "",
"Address4": "",
"CityOrTown": "Austin",
"StateOrProvince": "TX",
"PostalOrZipCode": "78758",