Skip to content

Instantly share code, notes, and snippets.

@stefanolaru
Last active December 10, 2020 06:42
Show Gist options
  • Save stefanolaru/ea4d3d8e5e13235360bcfae7709dd8f1 to your computer and use it in GitHub Desktop.
Save stefanolaru/ea4d3d8e5e13235360bcfae7709dd8f1 to your computer and use it in GitHub Desktop.
GumCart code samples
// A simple product with maximum available quantity.
GumCart.addItem({
id: "HEADPHONES", // optional
name: "Wireless Headphones", // required
price: 89, // required
max_quantity: 2,
image:
"https://gumcart.com/images/products/product-1.jpg",
});
// open the cart
GumCart.open();
// A simple product with in-cart product variation select.
GumCart.addItem({
id: "KEYBOARD", // optional
name: "Mechanical Keyboard", // required
price: 119, // required
image: "https://gumcart.com/images/products/product-2.jpg",
select: {
options: [
{
name: "Layout",
legend: "Keyboard Language",
values: [
"US English",
"Arabic",
"Chinese",
"French",
"German",
"Russian",
],
},
],
},
});
// will open the cart to pick the options
// A configurable product with multiple in-cart options and addons.
GumCart.addItem({
id: "LAPTOP", // optional
name: "Super Light Laptop", // required
price: 1299, // required
max_quantity: 1,
image:
"https://gumcart.com/images/products/product-3.jpg",
select: {
options: [
{
name: "Size",
legend: "Select Size",
values: [
{
name: "13-inch",
price: 1299,
},
{
name: "16-inch",
price: 2399,
},
],
},
],
addons: [
{
name: "Processor",
required: true,
values: [
{
name:
"2.6GHz 6‑core i7 processor",
},
{
name:
"2.4GHz 8‑core i9 processor",
price: 300,
},
],
},
{
name: "Accessories",
multiple: true,
values: [
{
name: "Elevator Stand",
price: 119,
},
{
name: "Mouse",
price: 69,
},
],
},
],
},
});
// will open the cart to pick the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment