Shop.js

由 El.js 和 Hanzo 提供支持的电子商务 UI 组件和框架。(Ecommerce UI components and framework powered by El.js and Hanzo.)

Github stars Tracking Chart

Shop.js

由 Hanzo 提供支持的电子商务 UI 组件和框架。

Shop.js 是由 El.js 提供支持的一整套被动电子商务组件。使用 Hanzo,它可以轻松集成到任何网站,无需后端。

Shop.js 提供无数组件,可以混合搭配,完全定制独特的品牌购物体验。从 <cart> 到 <checkout>,Shop.js 为您提供服务。

您可以在 getshopjs.com 以及网络上看到 Shop.js。

特性

  • 轻巧,完整的购物体验,大小约为120kb
  • 核心和所有依赖项都是 ES 模块,可以自由混合和匹配
  • 借助 El.js,可以使用纯 HTML/CSS 嵌套和自定义组件
  • 由于 Hanzo,不需要后端
  • 先进的分析支持,支持上下文分析
  • Angular、React 和 Vue 的绑定即将推出!

安装

$ npm install shop.js --save

组件

Shop.js 提供从用户注册和登录到客户门户以及复杂的结账流程等各个方面的组件。

  • <cart>
  • <checkout>
  • <card-cvc>
  • <card-expiry>
  • <card-name>
  • <card-number>
  • <checkbox>
  • <control>
  • <country-select>
  • <gift-email>
  • <gift-message>
  • <gift-toggle>
  • <gift-type>
  • <lineitem>
  • <promocode>
  • <quantity-select>
  • <select>
  • <shippingaddress-city>
  • <shippingaddress-country>
  • <shippingaddress-line1>
  • <shippingaddress-line2>
  • <shippingaddress-name>
  • <shippingaddress-postalcode>
  • <shippingaddress-state>
  • <state-select>
  • <terms>
  • <text>
  • <textarea>
  • <user-current-password>
  • <user-email>
  • <user-name>
  • <user-password-confirm>
  • <user-password>

Overview

Name With Ownershopjs/shop.js
Primary LanguageHTML
Program languageHTML (Language Count: 3)
PlatformWeb browsers
License:Other
Release Count290
Last Release Namev3.0.29 (Posted on 2020-10-01 14:40:38)
First Release Namev0.0.2 (Posted on )
Created At2015-12-07 21:50:25
Pushed At2023-01-06 08:34:09
Last Commit At2020-10-01 14:52:38
Stargazers Count458
Watchers Count57
Fork Count66
Commits Count1.1k
Has Issues Enabled
Issues Count29
Issue Open Count12
Pull Requests Count27
Pull Requests Open Count23
Pull Requests Close Count196
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Shop.js

npm
build
dependencies
downloads
license
chat

Ecommerce UI components and framework powered by Hanzo

Shop.js is a complete set of reactive Ecommerce components powered
by El.js. With Hanzo, it can be easily integrated into any
website, no backend required.

Shop.js provides countless components which can be mix-and-matched to completely
customize a unique and branded shopping experience. From <cart> to
<checkout>, Shop.js has you covered.

You can see Shop.js in action on getshopjs.com as well as
around the web.

Features

  • Lightweight, complete shopping experience weighs in at 120kb gzipped
  • Core and all dependencies are ES modules, and can be mixed and matched freely
  • Components can be nested and customized with plain HTML/CSS thanks to
    El.js
  • No backend needed, thanks to Hanzo
  • Sophisticated analytics support, with support for contextual analytics
  • Bindings for Angular, React, and Vue coming soon!

Install

$ npm install shop.js --save

Components

Shop.js provides components for everything from user signup and login to
customer portals and sophisticated checkout flows.

  • <cart>
  • <checkout>
  • <card-cvc>
  • <card-expiry>
  • <card-name>
  • <card-number>
  • <checkbox>
  • <control>
  • <country-select>
  • <gift-email>
  • <gift-message>
  • <gift-toggle>
  • <gift-type>
  • <lineitem>
  • <promocode>
  • <quantity-select>
  • <select>
  • <shippingaddress-city>
  • <shippingaddress-country>
  • <shippingaddress-line1>
  • <shippingaddress-line2>
  • <shippingaddress-name>
  • <shippingaddress-postalcode>
  • <shippingaddress-state>
  • <state-select>
  • <terms>
  • <text>
  • <textarea>
  • <user-current-password>
  • <user-email>
  • <user-name>
  • <user-password-confirm>
  • <user-password>

Containers and Controls

Containers are Custom HTML tags that define a section of embeddable dynamic content.
Controls are very simple composeable widgets that provide ui inputs and outputs
for users. Containers can contain other containers or controls.

Containers also expose data fields from the global data
referrential tree passed into
Shop.start and services. Data fields are accessed using the 'data' special
variable (see below) and services which are accessed by their name. Services
are either functions or read-only fields.

For example a submit() service can be invoked by calling 'submit()' directly or
binding an event 'onclick="submit"' for invokation by user when they interact
with an element on the page.

Special Variables

data

A reference to the global data referrential tree.
that's passed into the Shop.start function can be referenced from most
containers by using the 'data' variable.

The exceptions to this rule are lineitem and order which are used internally by
the looping containers lineitems and orders respectively. The 'data' in these containers refer
to the specific item that's currently being looped over. For example a lineitems container loops over order.items, a lineitem container's
'data' variable refers to the specific item being looped over.

parent-data

Both lineitem and order both have a 'parent-data' variable that refer to their
immediate parents's for composeability reasons, namely to get fields like
'currency' relatively from the parent order or user.

parent

The 'parent' variable references the parent container of the current container.
It is useful for using data fields or invoking services of a parent container.
Be aware that the root container has no parent set.

Services Available to All Containers, Name, Type, Description, ---, ---, ---, renderCurrency, (code string, cents number) ‑> string, code is a currency's ISO 4217 code (typically set to data.get('order.currency')), cents is the currency in cents (or lowest unit in the case of zero decimal currencies like JPY), returns a localized value with currency symbol, renderDate, (date time, format string) ‑> string, refer to moment(...).format(...) documentation here

Containers

cart

The cart container renders cart items and handles the processing of promotional codes.

Data Fields, Name, Type, Description, ---, ---, ---, order.promoCode, string, promotional code (coupon), ###### Services, Name, Type, Description, ---, ---, ---, applying, string, true when applyPromoCode is processing, false otherwise, applyPromoCode, () ‑> , submits promo code for discount adjustment, issues ApplyPromoCode, ApplyPromoCodeSuccessful, and ApplyPromoCodeFailed, isEmpty, () ‑> bool, returns if order.items.length == 0, promoMessage, string, current status of the promotional code, ###### Events, Name, Description, ---, ---, ApplyPromoCode, fired when applyPromoCode() is called, ApplyPromoCodeFailed, fired when applyPromoCode() gets a failed result, promoMessage is set to the error in this case, ApplyPromoCodeSuccess, fired when applyPromoCode() gets a successful result, ### checkout

The checkout container validates the customers shipping and billing information and handles
submitting the customer's card to complete the checkout step.

Data Fields, Name, Type, Description, ---, ---, ---, user.email, string, required, must be an email, user.name, string, required, splits on first space to populate user.firstName and user.lastName, user.firstName, string, derived from user.name, user.lastName, string, derived from user.name, order.shippingAddress.line1, string, required, street address, order.shippingAddress.line2, string, apartment number, suit number, PO box etc., order.shippingAddress.city, string, required, city, order.shippingAddress.isPostalRequired, string, required only if postal codes are required for the user's country, order.shippingAddress.country, string, required, ISO 3166-1 alpha-2 country codes, payment.account.number, string, required, valid credit card number, payment.account.expiry, string, required, valid expiration number in either MM/YYYY or MM/YY, payment.account.cvc, string, required, valid card security code number, terms, bool, required, whether or not the user agrees to the terms, ###### Services, Name, Type, Description, ---, ---, ---, checkedOut, bool, true when checkout submit is successful, errorMessage, string, error from the last attempted checkout submit if there was one, loading, bool, true when checkout submit is processing, false otherwise, submit, () ‑> , submit a charge request with the customer's information, ###### Events, Name, Description, ---, ---, Submit, fired when submit() is called, SuccessFailed, fired when submit() gets a failed result, errorMessage is setto the error-category in this case, SubmitSuccess, fired when submit() gets a successful result, ### checkout-shippingaddress

The checkout-shippingaddress container handles just the parts of checkout related to the
customer's shipping address. This is useful when doing a multi-page checkout
flow with checkout-shipping on the first page and checkout on the second page.
Shipping data will propagate from checkout-shipping to checkout.

Data Fields, Name, Type, Description, ---, ---, ---, user.email, string, required, must be an email, user.name, string, required, splits on first space to populate user.firstName and user.lastName, user.firstName, string, derived from user.name, user.lastName, string, derived from user.name, order.shippingAddress.line1, string, required, street address, order.shippingAddress.line2, string, apartment number, suit number, PO box etc., order.shippingAddress.city, string, required, city, order.shippingAddress.isPostalRequired, string, required only if postal codes are required for the user's country, order.shippingAddress.country, string, required, ISO 3166-1 alpha-2 country codes, ###### Services, Name, Type, Description, ---, ---, ---, submit, () ‑> , submit a user's shipping information information, ###### Events

n/a

lineitems

The lineitems container loops over and displays an order's or cart's line items (usually the order.items field).
The lineitems must be used inside of either a cart or orders container.
Internally, a lineitems container simply wraps a lineitem container in a loop.

Template data inside of a lineitems container's HTML tags are passed onto
each lineitem container and will be transcluded in lineitem.

It is best to use this container inside another container instead of at the top
level so it can be rendered along side other order information.

Data Fields

n/a

Services

n/a

lineitem

The lineitem container exposes an item and records quantity data. It is not used
directly in most cases. It should be used implicitly as part of the lineitems
container instead. When using lineitem containers directly, parentData (via parent-data
attribute, e.g. ) must be set to the order data.

Data Fields, Name, Type, Description, ---, ---, ---, quantity, integer, required, number of a particular item, ###### Services

n/a

Events

n/a

Controls

checkbox-control

The checkbox control creates and binds a checkbox.

Attributes, Name, Description, ---, ---, lookup, data field to bind to e.g. , ###### Variants, Name, Description, ---, ---, terms, lookup = terms, ### select-control

The select control creates and binds a platform-agnostic select based on
selectize.js. It is simplist to base custom styling
on the skins available here.

Attributes, Name, Description, ---, ---, lookup, data field to bind to e.g. , placeholder, input's placeholder text, read-only, set to anything to make the select readOnly, selectOptions, a map of values to names to render as the select options, ###### Variants, Name, Description, ---, ---, quantity, lookup = quantity, options are a list of numbers from 0 to 99, use in lineitem, shippingaddress-country, lookup = order.shippingaddress-country, options are a list of countries, ### text-control

The text control creates and binds a text-input.

Attributes ######, Name, Description, ---, ---, auto-complete, on to enable input auto-complete or off to disable it, lookup, data field to bind to e.g. , placeholder, input's placeholder text, type, input's type, ###### Variants ######, Name, Description, ---, ---, card-number, lookup = payment.account.number, formats as card number, card-expiry, lookup = payment.account.expiry, formats as a date, card-cvc, lookup = payment.account.cvc, formats as a CVC, promocode, lookup = order.promoCode, shippingaddress-line1, lookup = order.shippingAddress.line1, shippingaddress-line2, lookup = order.shippingAddress.line2, shippingaddress-city, lookup = order.shippingAddress.city, shippingaddress-postalcode, lookup = order.shippingAddress.postalCode, shippingaddress-state, lookup = order.shippingAddress.state, user-name, lookup = user.email, ## Event Reference

These constants can be accessed via Shop.Events. or the string value can be used instead, Name, String Value, Payload, Description, ---, ---, ---, ---, ApplyPromoCode, apply-promocode, string, fired when a cart container submits its promo code, ApplyPromoCodeFailed, apply-promocode-failed, Error, fired when a promo code is not applicable, ApplyPromoCodeSuccess, apply-promocode-success, string, fired when a promo code is applicable, Change, change, string, any, fired when any data field changes with the string name and original value, ChangeFailed, change-failed, string, any, fired when any data field change fails with the string name and original value, ChangeSuccess, change-success, string, any, fired when any data field change finishes with the string name and new value, Login, login, n/a, fired when a login container submits login credentials, LoginFailed, login-failed, Error, fired when login is unsuccessful, LoginSuccess, login-success, AccessToken, fired when login is successful with accessToken, ProfileLoad, profile-load, n/a, fired when profile is initialized, ProfileLoadFailed, profile-load-failed, Error, fired when profile is unsuccessfully loaded, ProfileLoadSuccess, profile-load-success, User, fired when profile is successfully loaded, ProfileUpdate, profile-update, n/a, fired when profile is submitted, ProfileUpdateFailed, profile-update-failed, Error, fired on unsuccessful profile update, ProfileUpdateSuccess, profile-update-success, User, fired on successful profile update, Ready, ready, n/a, fired when containers are done initializing, Register, register, n/a, fired when a register container submits registration data, RegisterFailed, register-failed, Error, fired when a registration is unsuccessful, RegisterSuccess, register-success, RegistrationResponse, fired when a registration is successful, SetData, set-data, ReferrentialTree, fired when data is loaded into containers, ShippingAddressUpdateFailed, shipping-address-update-failed, Error, fired on unsuccessful order shipping address update, ShippingAddressUpdate, shipping-address-update, n/a, fired when an order container's shipping address is updated, ShippingAddressUpdateSuccess, shipping-address-update-success, Order, fired on successful order shipping address update, Submit, submit, n/a, fired when a checkout container issues a checkout command to the backend, SubmitFailed, submit-failed, Error, fired on an unsuccessful checkout, SubmitShippingAddress, submit-shipping-address, n/a, fired when a checkout-shippingaddress container submits, SubmitSuccess, submit-success, n/a, fired on a successful checkout, TryUpdateItem, try-update-item, string, fired when setItem is called with the id specified, UpdateItem, update-item, Item, fired when setItem is complete, UpdateItems, update-items, Item[], fired when setItem is complete with all items, ## License
BSD

To the top