Skip to content

Instantly share code, notes, and snippets.

@gje4
gje4 / MoltinManager
Last active July 5, 2018 14:06
A manager class to be used with the moltin commerce SDK
README : To install moltin https://moltin.com/quick-start/swift/
import moltin
class MoltinManager : NSObject {
let moltin: Moltin = Moltin(withClientID: AppDelegate.moltinId)
var categories: [moltin.Category] = []
var products: [Product] = []
var product: Product?
// moltin SDK setup
const moltin = require('@moltin/sdk');
const MoltinSite = moltin.gateway({
client_id: process.env.CLIENT_ID_SITE,
client_secret: process.env.CLIENT_SECRET_SITE
});
exports.formatOrders = function(orders, items) {
@gje4
gje4 / Moltin Android
Created July 20, 2018 18:53
This is the class that takes care of Authorizing your Moltin API and gives you basic get/update/delete functions to interact with the API. The data ret returned from Moltin will be JSON objects
package com.example.omgandroid;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import org.json.JSONException;
import org.json.JSONObject;
@gje4
gje4 / moltincustomcart.html
Last active November 14, 2018 22:15
Examples of working with Moltin custom cart
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="cart.css">
<!-- <script src="cart.js"> -->
</script>
<script src="https://unpkg.com/@moltin/sdk"></script>
<!--
quick install https://developers.moltin.com/your-first-api-request
import _ from 'lodash'
import React, { Component } from 'react'
import { Search, Grid, Header, Segment } from 'semantic-ui-react'
import { getProducts } from '../lib/moltin'
export default class SearchExampleStandard extends Component {
constructor(props) {
super()
this.state = {
import Link from 'next/link'
import Head from 'next/head'
import Router from 'next/router'
import NProgress from 'nprogress'
import { Menu, Container, Image, Icon } from 'semantic-ui-react'
import Search from './Search'
Router.onRouteChangeStart = url => NProgress.start()
Router.onRouteChangeComplete = () => NProgress.done()
Router.onRouteChangeError = () => NProgress.done()
{
"data":[
{
"type":"product",
"id":"6fe08392-f483-4763-98d8-bb37e42b6356",
"name":"Flight Deposit",
"slug":"flight-deposit",
"sku":"fdp",
"manage_stock":false,
"description":"Flight Deposit",
import React, { Component } from "react";
import PropTypes from "prop-types";
import Link from "next/link";
import Title from "./styles/Title";
import ItemStyles from "./styles/ItemStyles";
import PriceTag from "./styles/PriceTag";
import formatMoney from "../lib/formatMoney";
import AddToCart from "./AddToCart";
import styled from "styled-components";
{
"breadcrumbs": [
{
"url": "https://headless.mybigcommerce.com/",
"name": "Home"
}
],
"blog": {
"name": "Blog",
"url": "/blog/",