项目作者: Banoulka

项目描述 :
UX-Cart is a cart tracking application that is for a research project answering a research question.
高级语言: JavaScript
项目地址: git://github.com/Banoulka/ux-cart.git
创建时间: 2020-11-28T16:28:02Z
项目社区:https://github.com/Banoulka/ux-cart

开源协议:MIT License

下载


ux-cart

GitHub license
@banoulka/ux-cart?color=blue" alt="npm (scoped)">
GitHub repo size

UX-Cart is a cart tracking application that is for a research project answering the question:

\

Contents


Installation

Using npm:

```shell script
$ npm install @banoulka/ux-cart

  1. <!-- Using personal CDN:
  2. ```html
  3. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  4. ``` -->
  5. Once package is installed a link should be placed in the `<head>`tag of the html page. Copy and paste the link below:
  6. ```html
  7. <script src="<SOURCE>" defer />

Bootstrap is optional but increases styles and viewing across all pages, follow
bootstrap for their setup.

  1. <link
  2. rel="stylesheet"
  3. href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
  4. integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
  5. crossorigin="anonymous"
  6. />


Requirements

To use this product cart application tracker, you need to have
a full cart system to provide with. Provide your own buttons out of a possibility
of 3.

  • Paypal checkout
  • Apple pay checkout
  • Credit / Debit card system

To set, see options.


Usage

To use the application it should be initialized by the following code.

In javascript a new object can be created and initialised with

  1. const ux = UX.init();


Options

Options can be added by passing an object with the different keys setup. A list of options
can be seen below.

Options with * can be optional.

To see storageType modes, check modes.

  1. UX.init({
  2. total, // The total amount for the cart
  3. cart, // The list of products as an array
  4. parentId: '', // The page container to render different pages
  5. storageType, // * The storage type for the results.
  6. // Required if using 'api'
  7. endpoint, // * The endpoint for the 'api' storage option.
  8. payCardId: '', // * The paypal button id to use
  9. payAppleId: '', // * The apple pay button id to find
  10. payPaypalId: '', // * The paypal button id to find
  11. });


Modes

UX Cart comes with a couple of different options for storage results.
See endpoint for what data is sent.

API:

storageType: UX.storeOptions.api

Your own endpoint can be provided that will handle and store the
results.

Your api must be able to recieve requests and store them

Local Storage:

storageType: UX.storeOptions.local

The ux cart application can store the results as a json
results object in local storage.

File Download:

The results can be downloaded as a text file

storageType: UX.storeOptions.textFile

or an Excel spreadsheet

storageType: UX.storeOptions.excelFile

Console Log:

The results can be logged to the console for future use

storageType: UX.storeOptions.console

No option:

No option can be selected or the option can be optional

storageType: UX.storeOptions.none

Other:

If you want any other results a function can be called to
collect the data as object

  1. const results = UX.collect();
  2. // Collecting the different types of results, JS Destruct
  3. const { error, timeSeconds, modeSelected } = results;


Endpoint:

The UX Cart application can process the results in different modes,
for each of those a list of what data is sent to the endpoint, localstorage,
and as a txt / excel file.

  • timeSeconds - The amount of time the process took
  • modeSelected - The selected payment mode
  • errors - The amount of times the user went back

Examples

A couple of different example options for the config setup can be
seen below.

The first is using the paypal and credit buttons with an api endpoint

  1. UX.init({
  2. total, // The total amount for the cart
  3. cart, // The list of products as an array
  4. storageType: UX.storeOptions.api,
  5. parentId: 'page-container',
  6. payCardId: 'card-btn',
  7. payPaypalId: 'paypal-btn',
  8. });

The second is using text download and all 3 buttons

  1. UX.init({
  2. total, // The total amount for the cart
  3. cart, // The list of products as an array
  4. storageType: UX.storeOptions.textFile,
  5. parentId: 'checkout-page',
  6. payCardId: 'buy-debit',
  7. payPaypalId: 'buy-paypal',
  8. payAppleId: 'buy-apple',
  9. });

Demo

This cart comes with a demo php server to test the functionality.
To start the website navigate to the downloaded folder and run
```shell script
$ npm run demo

  1. to start the webserver and navigate to
  2. ```http request
  3. localhost:8000/demo

To edit the demo configuration navigate to the demo/checkout.js
and edit the UX configuration on line 33

  1. // Initialize the UX class
  2. UX.init({
  3. cart,
  4. total,
  5. storageType: UX.options.console,
  6. endpoint: '/storeResult.php',
  7. payCardId: 'pay-card',
  8. payAppleId: 'pay-apple',
  9. payPaypalId: 'pay-paypal',
  10. parentId: 'page-container'
  11. });