Skip to content

Instantly share code, notes, and snippets.

@erin-at-work
Last active July 26, 2019 15:31
Show Gist options
  • Save erin-at-work/e67acc2e87c42fbed67710f4c8b0a55c to your computer and use it in GitHub Desktop.
Save erin-at-work/e67acc2e87c42fbed67710f4c8b0a55c to your computer and use it in GitHub Desktop.
Product Constants

Product Constants

Constants

lib/constants.js

Individual Product Constants

Constants are prefixed with the product category + name + field in all caps snakecase format. ie: WHITENING + _PEN + _NAME

Field Constant Description Example
name NAME Human readable name Whitening Pen
label LABEL Snakecase of the display name used for events and keys to objects whitening_pen
price PRICE Dollar amount of the product 30
sku SKU product unique identifier WHITEPEN01
product_id PRODUCT_ID product id is only used for the impression kit 11436401551

Possible future fields: category, variant, etc.

All Products Data Constants

The above individual constants are used for the PRODUCT_DATA constants which reads as the following:

const PRODUCT_DATA = {
	impression_kit: {
		name: 'Modeling Kit',
		event: 'modeling_kit`,
		price: 95,
		product_id: '11436401551',
		sku: 'IKFINISHED00002'
	},
	whitening_pen: {
		name: 'Whitening Pen',
		event: 'whitening_pen',
		price: 30,
		product_id: null,
		sku: 'WHITEPEN01'
	},
	straightening_retainers: {
		name: 'Straightening Retainers',
		event: 'straightening_retainers',
		price: 999,
		product_id: null,
		sku: 'RETAINERS01'
	}
};

Product URL's

lib/build-constants.js

PRODUCT_URLS: {
	whitening_pen: {
		category: 'whitening',
		item: 'pen',
	},
	straightening_retainers: {
		category: 'straightening',
		item: 'retainers`
	}
}

used in lib/routes.js:

  • Whitening Pen: /teeth/whitening/pen
  • Straightening Retainers: /teeth/straightening/retainers

*Note: The Starter Kit (aka Modeling Kit aka Impression Kit) uses a separate path: /checkout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment