npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spree-ember-checkouts

v0.0.1-beta.1

Published

Checkout functionality for a Spree Ember Application.

Downloads

5

Readme

Spree Ember Checkouts

Build Status Join the chat at https://gitter.im/hhff/spree-ember

Spree Ember Checkouts uses Ember FSM to define a Stateful Checkouts abstraction as a service for writing reactive single page checkout flows. It exclusively uses the Spree Checkouts API with an Order Serializer to transiton an order to completion, and populate the order's DS.Errors attribute when server validation fails.

This addon also adds currentOrder session support to the central spree service.

Note: This Package is included with spree-ember-storefront. If you're using that, there's no need to install this seperately.

It uses:

Installation

ember install spree-ember-checkouts

For full Spree Ember documentation, visit http://www.spree-ember.com/.

For more information on using ember-cli, visit http://www.ember-cli.com/.

Order Management

The addToCart function will create an order if one doesn't currently exist, and then add a variant to cart. You can optionally pass in a quantity, too!

this.spree.get('currentOrder');
// => null

var _this = this;
this.spree.addToCart(variantModel).then(function() {
  _this.spree.get('currentOrder.state');
  // => "cart"

  _this.spree.clearCurrentOrder();
  _this.spree.get('currentOrder');
  // => null
});

Advancing an Order through the Checkout

All order state manipulation is done exclusively through the transition function. Under the hood, it triggers state transitions on the checkouts Finite State Machine, to ensure the frontend state stays in sync with Spree's Order State Machine.

The Checkouts service is designed to allow a reactive style of programming for the checkout flow, allowing the developer to focus on the User experience, and trust that the internals of the State Machine will clear up and reconsolidate user edge cases.

var checkouts = this.spree.get('checkouts');

checkouts.transition().then(
  function() {
    checkouts.get('currentState');
    // => "delivery"
    checkouts.get('currentOrder.state');
    // => "delivery"
    
    checkouts.transition("address").finally(function() {
      checkouts.get('currentState');
      // => "address"
      checkouts.get('currentOrder.state');
      // => "delivery"
    });
  }
);

In the above example, the Checkouts currentState diverges from the currentOrder state when moving backward. This is expected behaviour - the states will reconsolidate when the order advances forward again.

Note: This is an example of why it's important to use the Checkouts service as the canoncial state to represent in the UI, and not the currentOrder directly.

Subscribing to Checkout Events

The Spree Checkouts package also supports a event bus / callback style architecture. This is useful for binding events to Google Analytics, and such.

this.spree.on('didAddToCart', function(lineItem) {
  alert(lineItem.get('variant.name') + " added to cart!");
});

For more information, please see the spree-ember-checkouts API Documentation.