SlideShare a Scribd company logo
1 of 80
Download to read offline
Centarro: Commerce with Confidence
Delivering Headless
Commerce
Matt Glaman (mglaman)
matt@centarro.io
@nmdmatt
• Drupal Commerce 2.x co-maintainer
• Drupal 8 Development Cookbook author
• drupal-check
Matt Glaman
Product Lead
Our core team created and
leads Drupal Commerce.
https://www.drupal.org/centarro
What is…
Headless Commerce
Centarro: Commerce with Confidence
Headless Commerce… 
Separates the customer
experience layer from the
core business application.
Centarro: Commerce with Confidence
Headless Commerce… 
Supports any number of
front end sites or apps

from a single back end.
Centarro: Commerce with Confidence
Headless Commerce… 
Evolves and scales your
platform without impacting
other components.
For example…
React front end interacting 
with a Drupal Commerce 
API backend
And… Panopoly?!?!
DRUPAL 7 ?!?$#@
Challenges
! Structured data model
! Relationships layers
! Data vs Presentation layer couplings
Centarro: Commerce with Confidence
Available API integration options
! JSON:API
! GraphQL (v3, not v4)
! RESTful Web Services*
* RESTful Web Services module does not provide any default schema, filtering, or collections but does allow building your own.
Centarro: Commerce with Confidence
JSON:API
! JSON:API is a RESTful API specification, implemented in Drupal
! Supports includes that fetch linked resources automatically
! Allows limiting fields returned, otherwise all fields
! Automatically exposes all entities as resources
! Uses entity UUIDs over normal identifiers
Centarro: Commerce with Confidence
GraphQL
! Query-like language API, not a RESTful API
! Fragments represent sets of fields (base fields, bundle fields)
! Must specify fields to be returned in a query
! Use GraphiQL IDE to build the query
! Uses normal identifiers, not UUIDs
! Manipulate data (Create, Update, Delete) via mutations
Centarro: Commerce with Confidence
RESTful Web Services
! Original API module in Drupal core, since 8.0.0
! Plugins define resource endpoints
! Endpoints must be configured to turn them on, but there’s no UI
! Uses normal identifiers, not UUIDs
! No schema or opinions on the request or response
Delivering
! Catalogs
! Product Display Pages
! Add to Cart Forms
! Shopping Carts
! Checkout
Catalogs
Standard Drupal: Views + Search API + Facets
Centarro: Commerce with Confidence
Catalog areas of concern
! Highly customized queries for products across product types
! Powered by search indexes
! Utilize facets for fine tuned browsing
! Variable pricing based on customer context
! Product availability
Centarro: Commerce with Confidence
JSON:API
! Does not support mixed-bundle
collections out of the box.
(#2956414)
! Custom controller or support in
JSON API Extras.
! Could integrate JSON API into
Search API with some effort.
GET

/jsonapi/commerce_product/simple
GET 

/jsonapi/commerce_product/clothing
GET

/jsonapi/commerce_product/
Centarro: Commerce with Confidence
GraphQL
! Queries can become very large
and complex.
! Reusable queries, as Query Maps
are possible and allows reusing
predefined queries.
Centarro: Commerce with Confidence
GraphQL & Search API
! GraphQL has Search API integration
through a contributed module
! Query support using full text search
! Faceted search support
! Only returns data in the index; more
like directly querying the search
index with Drupal as a proxy
Product Display Pages
Standard Drupal: Entity view display and Twig
Centarro: Commerce with Confidence
Product display page areas of concern
! Made up of a mix of marketing content and product data
! Representation of product variations and their field values
! Add to cart forms
Centarro: Commerce with Confidence
JSON:API
! Retrieve products by bundle and UUID







! Include variations, variation attributes, taxonomy terms, etc.
using the include parameter

! Need additional strategies for image styles, such as the
Consumer Image Styles module
GET /jsonapi/commerce_product/simple/1630-42cd-af47
GET /jsonapi/commerce_product/clothing/1630-42cd-af47
Sample JSON API request for a product and its variations (8.1kb, without fields 38kb)
Centarro: Commerce with Confidence
GraphQL
! Retrieve products by their ID and then request fields as needed
! Supports fetching images and specifying the proper image style
Sample GraphQL request for a product and its variations
Add to Cart Forms
Centarro: Commerce with Confidence
Add to cart form areas of concern
! Attribute select lists vs. fancy formatting (e.g. color swatches)
! Identifying the currently selected product variation
! Custom order item fields
Standard Drupal: Form API with AJAX
Cart API + Cart Flyout (drupalSettings, Underscore, Backbone, jQuery)
JSON:API + React
GatsbyJS: JSON:API to internal GraphQL with React
jQuery + JSON:API
The challenge as maintainers:

Provide abstract, reusable
solutions for very purpose-built
front ends.
Barton’s Home
Progressive Decoupling Example
Progressively decoupled add to cart using Backbone + Underscore + Cart API
Client side add to cart confirmation with related products
Client side store selection for inventory, location aware Search API query over A
Shopping Carts
Centarro: Commerce with Confidence
Cart management areas of concern
! Anonymous and authenticated user owned carts
! Users can modify their carts, without fully managing the order
! Users shouldn’t be able to edit another user’s cart
! Constraints on product availability
Centarro: Commerce with Confidence
Cart API: Cart Operations
! Cart API hides internals knowledge and
provides a friendly interface.
! RESTful Web Services endpoint plugins
! GET for collection of active carts or
individual cart
! POST that creates the order item from a
product and adds it to the proper cart.
! PATCH to update quantities
POST /cart/add?_format=json

[

  { "purchased_entity_type":
"commerce_product_variation",

    "purchased_entity_id": "6", 

    "quantity": "1"

  }

]

PATCH /cart/{order}/items?_format=json

{

  3: {"quantity": 1},

  9: {"quantity": 2},

}
Centarro: Commerce with Confidence
Cart API: Cart Tokens
! PHP Sessions persist via cookies
! Cookies are opt-in when making
CORS enabled AJAX requests
! Cookies are blocked on cross-origin
CORS enabled AJAX requests
! Solution: a passable token as a
query parameter or header.
GET /cart?_format=json

Accept: application/json

Commerce-Cart-Token: 123ABC
GET /cart?_format=json&cartToken=123ABC

Accept: application/json
Centarro: Commerce with Confidence
JSON:API
! Not out of the box without cross-
bundle collection resources
! JSON:API is now stable and in Drupal
core, easier to integrate and extend!
! Cart API 2.x will use JSON:API over
RESTful Web Services plugins.
! Provides a cart collection endpoint
and Cart Manager integration
Centarro: Commerce with Confidence
GraphQL
! GraphQL supports cross-bundle
querying for cart item collections
! Carts are restricted by query
access, so only the requesting
user’s carts are returned
! Mutations are part of GraphQL
Mutations module
! Requires writing GraphQL
Mutation plugins
Patrick Roger
Fully decoupled Drupal Commerce
https://snipcart.com/blog/case-study-patrick-roger-drupal-angular
Centarro: Commerce with Confidence
Headless Drupal Commerce & Angular with Snipcart
Drupal Commerce is used for product
and inventory management, shipping
and tax calculations, and order
fulfillment management
Snipcart provides cart management
and checkout, orders are synchronized
through webhooks.
Integrating Bots with Drupal Commerce
Conversational Commerce
https://2018.decoupleddays.com/session/conversational-commerce-integrating-bots-drupal-commerce
Coupons
Centarro: Commerce with Confidence
Cart API: Coupons
! RESTful Web Services endpoint
plugin
! Redemption via coupon code
! Limited to single coupon to avoid
abuse
! Coupon reference constraint to
validate coupons when attached,
better API level handling
Centarro: Commerce with Confidence
JSON:API
! Requires querying for the coupon without exposing all

currently available coupons
! Take the coupon identifier and PATCH a relationship
! Need custom relationship endpoint to accept coupon code
! Validation constraint will reject the coupon if invalid
Centarro: Commerce with Confidence
GraphQL
! Requires a custom mutation
! Accept the coupon code directly, like the RESTful Web Services endpoint
Checkout
Centarro: Commerce with Confidence
Checkout over the API
! Experimented with a bespoke
Checkout API for a GatsbyJS.
! Completing checkout is really just
running the place order transition
! Problem is most of our validations
are in the Checkout Form, not in
data level constraints
Centarro: Commerce with Confidence
Checkout over the API
! In evaluation and discovery
! With JSON API or GraphQL Entity Mutation, direct entity access is not
allowed for modifying an order
! Need to review entity access control to allow modifying order fields
! Entity and field constraints for checkout validation
Centarro: Commerce with Confidence
Third party checkouts
Concern Worldwide
Fully decoupled Drupal Commerce
https://www.drupal.org/case-study/concern-worldwide-mobilisation-usability
Custom add to cart for direct checkout
Decoupled checkout using a custom built Checkout API module
What’s on the horizon?
Centarro: Commerce with Confidence
What’s next?
! Improving query access and entity access

https://www.drupal.org/project/commerce/issues/3041758
! Coupon validation constraint in Drupal Commerce

https://www.drupal.org/project/commerce/issues/3041856
! Computed base order total field (subtotal, adjustments, total)

https://www.drupal.org/project/commerce_cart_api/issues/3048704
Centarro: Commerce with Confidence
What’s next?
! Convert variations and order_item fields from Field Config to base fields

https://www.drupal.org/project/commerce/issues/3002939
! Resolved pricing (price list support, promotions support)
! Improved product availability handling (entity reference constraint)
Centarro: Commerce with Confidence
HIGH_VOLUME_DRUPAL7_HEADLESS_STORE
migrates to headless Commerce 2.x
! High volume online convenience store
! Multiple stores, multiple currencies, and
shipping integrations
! Drupal 7 API backend & multiple React
frontend
! Tested to support well over 4,000 concurrent
shopping sessions
! Third-party checkout
Ready to get started?
Available modules
Centarro: Commerce with Confidence
Cart API
commerce_cart_api


Provides a RESTful interface to
interact with carts in Drupal
Commerce via a lightweight public
API.
JSON API integration still sandboxed
Centarro: Commerce with Confidence
Cart Flyout
commerce_cart_flyout
The Cart Flyout is a drop-in
progressively decoupled replacement
of the cart block.
Provides a decoupled add to cart form.
Centarro: Commerce with Confidence
JSON API
Generates an API server that implements
the JSON:API specification.
JSON:API is now part of Drupal core! 🎉
Centarro: Commerce with Confidence
GraphQL
graphql & graphql_search_api
Lets you craft and expose a
GraphQL schema for Drupal 8.
Centarro Support
Guaranteed answers to the questions you have
as you go headless with Drupal Commerce.
• Private Q&A forum moderated by core maintainers
• Each seat includes access to Centarro Toolbox:
• Update Assistant
• Quality Monitor
• Partner products
Professional
Support
from $99 / mo
Prioritized support on a per-site basis to solve
your blockers and bugs as fast as possible.
• On-boarding site audit / project review
• Private tickets for project-specific support
• Guaranteed 1 day response time
• Opened issues influence core roadmap
• Semi-annual consultation
Priority
Support
from $499 / mo
Thank you for coming!
Questions? Give it a spin!
https://commerce-decoupled-days-2019.web.app/

(JSON:API + React)
https://react.demo.centarro.io/ 

(GraphQL + React)
https://gatsbyjs.demo.centarro.io/ 

(GatsbyJS)
https://demo.commercekickstart.com/ 

(Progressively decoupled)
matt@centarro.io
@nmdmatt

More Related Content

What's hot

Front-end development for headless cms
Front-end development for headless cms Front-end development for headless cms
Front-end development for headless cms Frosmo
 
Introduction To WordPress
Introduction To WordPressIntroduction To WordPress
Introduction To WordPressCraig Bailey
 
Microservices Design Patterns | Edureka
Microservices Design Patterns | EdurekaMicroservices Design Patterns | Edureka
Microservices Design Patterns | EdurekaEdureka!
 
Introduction to WordPress
Introduction to WordPressIntroduction to WordPress
Introduction to WordPressEunus Hosen
 
How we Webflow at Webflow - No Code Conf 2019 Demo Theater
How we Webflow at Webflow - No Code Conf 2019 Demo TheaterHow we Webflow at Webflow - No Code Conf 2019 Demo Theater
How we Webflow at Webflow - No Code Conf 2019 Demo TheaterWebflow
 
HandyMan(SRS Final Presentation)
HandyMan(SRS Final Presentation)HandyMan(SRS Final Presentation)
HandyMan(SRS Final Presentation)FazleRabbi80
 
Build a Serverless Web Application
Build a Serverless Web ApplicationBuild a Serverless Web Application
Build a Serverless Web ApplicationAmazon Web Services
 
Magento CMS Presentation
Magento CMS PresentationMagento CMS Presentation
Magento CMS PresentationRAJU MAKWANA
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | IntroductionJohnTaieb
 
Composale DXP with MACH architecture.pptx
Composale DXP with MACH architecture.pptxComposale DXP with MACH architecture.pptx
Composale DXP with MACH architecture.pptxPieter Brinkman
 
Introduction to WordPress
Introduction to WordPressIntroduction to WordPress
Introduction to WordPressHarshad Mane
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAraf Karsh Hamid
 
Microservices
MicroservicesMicroservices
MicroservicesSmartBear
 
Web Development In 2018
Web Development In 2018Web Development In 2018
Web Development In 2018Traversy Media
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST APIAniruddh Bhilvare
 
Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Oleksii Prohonnyi
 
Web Development Presentation
Web Development PresentationWeb Development Presentation
Web Development PresentationTurnToTech
 

What's hot (20)

Front-end development for headless cms
Front-end development for headless cms Front-end development for headless cms
Front-end development for headless cms
 
Introduction To WordPress
Introduction To WordPressIntroduction To WordPress
Introduction To WordPress
 
Microservices Design Patterns | Edureka
Microservices Design Patterns | EdurekaMicroservices Design Patterns | Edureka
Microservices Design Patterns | Edureka
 
Introduction to WordPress
Introduction to WordPressIntroduction to WordPress
Introduction to WordPress
 
How we Webflow at Webflow - No Code Conf 2019 Demo Theater
How we Webflow at Webflow - No Code Conf 2019 Demo TheaterHow we Webflow at Webflow - No Code Conf 2019 Demo Theater
How we Webflow at Webflow - No Code Conf 2019 Demo Theater
 
HandyMan(SRS Final Presentation)
HandyMan(SRS Final Presentation)HandyMan(SRS Final Presentation)
HandyMan(SRS Final Presentation)
 
Build a Serverless Web Application
Build a Serverless Web ApplicationBuild a Serverless Web Application
Build a Serverless Web Application
 
Magento CMS Presentation
Magento CMS PresentationMagento CMS Presentation
Magento CMS Presentation
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
 
Composale DXP with MACH architecture.pptx
Composale DXP with MACH architecture.pptxComposale DXP with MACH architecture.pptx
Composale DXP with MACH architecture.pptx
 
Web api
Web apiWeb api
Web api
 
Introduction to WordPress
Introduction to WordPressIntroduction to WordPress
Introduction to WordPress
 
WordPress Complete Tutorial
WordPress Complete TutorialWordPress Complete Tutorial
WordPress Complete Tutorial
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
Microservices
MicroservicesMicroservices
Microservices
 
Web Development In 2018
Web Development In 2018Web Development In 2018
Web Development In 2018
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
ReactJS
ReactJSReactJS
ReactJS
 
Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1
 
Web Development Presentation
Web Development PresentationWeb Development Presentation
Web Development Presentation
 

Similar to Decoupled Days 2019: Delivering Headless Commerce

Magento's Imagine eCommerce Conference 2011 - Mash-up of Magento and Salesfor...
Magento's Imagine eCommerce Conference 2011 - Mash-up of Magento and Salesfor...Magento's Imagine eCommerce Conference 2011 - Mash-up of Magento and Salesfor...
Magento's Imagine eCommerce Conference 2011 - Mash-up of Magento and Salesfor...MagentoImagine
 
Deliver the Perfect Omnichannel Commerce Experience
Deliver the Perfect Omnichannel Commerce ExperienceDeliver the Perfect Omnichannel Commerce Experience
Deliver the Perfect Omnichannel Commerce ExperienceSAP Customer Experience
 
Developing enterprise ecommerce solutions using hybris by Drazen Nikolic
Developing enterprise ecommerce solutions using hybris by Drazen NikolicDeveloping enterprise ecommerce solutions using hybris by Drazen Nikolic
Developing enterprise ecommerce solutions using hybris by Drazen Nikolicyoungculture
 
Prepare for Peak Holiday Season with MongoDB
Prepare for Peak Holiday Season with MongoDBPrepare for Peak Holiday Season with MongoDB
Prepare for Peak Holiday Season with MongoDBMongoDB
 
Designing APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignDesigning APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignLaunchAny
 
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices  - Austin API MeetupApplying Domain-Driven Design to APIs and Microservices  - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices - Austin API MeetupLaunchAny
 
Developing enterprise ecommerce solutions using hybris by Drazen Nikolic - Be...
Developing enterprise ecommerce solutions using hybris by Drazen Nikolic - Be...Developing enterprise ecommerce solutions using hybris by Drazen Nikolic - Be...
Developing enterprise ecommerce solutions using hybris by Drazen Nikolic - Be...youngculture
 
IBM Feature Pack 8 Webinar
IBM Feature Pack 8 WebinarIBM Feature Pack 8 Webinar
IBM Feature Pack 8 WebinarCrossView
 
INRDealsAPIDocumentation.pdf
INRDealsAPIDocumentation.pdfINRDealsAPIDocumentation.pdf
INRDealsAPIDocumentation.pdfVinitPal11
 
Evolve13 cq-commerce-framework
Evolve13 cq-commerce-frameworkEvolve13 cq-commerce-framework
Evolve13 cq-commerce-frameworkPaolo Mottadelli
 
AEM & eCommerce integration
AEM & eCommerce integrationAEM & eCommerce integration
AEM & eCommerce integrationLokesh BS
 
E commerce
E commerceE commerce
E commerceArman Ahmed
 
Evolve 2014 experience driven commerce
Evolve 2014 experience driven commerceEvolve 2014 experience driven commerce
Evolve 2014 experience driven commerceElastic Path
 
ContentsPhase 1 Design Concepts2Project Description2Use.docx
ContentsPhase 1 Design Concepts2Project Description2Use.docxContentsPhase 1 Design Concepts2Project Description2Use.docx
ContentsPhase 1 Design Concepts2Project Description2Use.docxmaxinesmith73660
 
Shopify Theme Building Workshop
Shopify Theme Building WorkshopShopify Theme Building Workshop
Shopify Theme Building WorkshopKeir Whitaker
 
Write Your iOS App in Swift with a Graph Database
Write Your iOS App in Swift with a Graph DatabaseWrite Your iOS App in Swift with a Graph Database
Write Your iOS App in Swift with a Graph DatabaseAnthony Blatner
 
API Product Management and Strategy
API Product Management and StrategyAPI Product Management and Strategy
API Product Management and Strategyadritab
 

Similar to Decoupled Days 2019: Delivering Headless Commerce (20)

Magento's Imagine eCommerce Conference 2011 - Mash-up of Magento and Salesfor...
Magento's Imagine eCommerce Conference 2011 - Mash-up of Magento and Salesfor...Magento's Imagine eCommerce Conference 2011 - Mash-up of Magento and Salesfor...
Magento's Imagine eCommerce Conference 2011 - Mash-up of Magento and Salesfor...
 
Deliver the Perfect Omnichannel Commerce Experience
Deliver the Perfect Omnichannel Commerce ExperienceDeliver the Perfect Omnichannel Commerce Experience
Deliver the Perfect Omnichannel Commerce Experience
 
Commerce Cloud B2C
Commerce Cloud B2CCommerce Cloud B2C
Commerce Cloud B2C
 
Developing enterprise ecommerce solutions using hybris by Drazen Nikolic
Developing enterprise ecommerce solutions using hybris by Drazen NikolicDeveloping enterprise ecommerce solutions using hybris by Drazen Nikolic
Developing enterprise ecommerce solutions using hybris by Drazen Nikolic
 
Prepare for Peak Holiday Season with MongoDB
Prepare for Peak Holiday Season with MongoDBPrepare for Peak Holiday Season with MongoDB
Prepare for Peak Holiday Season with MongoDB
 
Designing APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignDesigning APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven Design
 
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices  - Austin API MeetupApplying Domain-Driven Design to APIs and Microservices  - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
 
Developing enterprise ecommerce solutions using hybris by Drazen Nikolic - Be...
Developing enterprise ecommerce solutions using hybris by Drazen Nikolic - Be...Developing enterprise ecommerce solutions using hybris by Drazen Nikolic - Be...
Developing enterprise ecommerce solutions using hybris by Drazen Nikolic - Be...
 
IBM Feature Pack 8 Webinar
IBM Feature Pack 8 WebinarIBM Feature Pack 8 Webinar
IBM Feature Pack 8 Webinar
 
INRDealsAPIDocumentation.pdf
INRDealsAPIDocumentation.pdfINRDealsAPIDocumentation.pdf
INRDealsAPIDocumentation.pdf
 
EVOLVE'13 | Enhance | Ecommerce Framework | Paolo Mottadelli
EVOLVE'13 | Enhance | Ecommerce Framework | Paolo MottadelliEVOLVE'13 | Enhance | Ecommerce Framework | Paolo Mottadelli
EVOLVE'13 | Enhance | Ecommerce Framework | Paolo Mottadelli
 
Evolve13 cq-commerce-framework
Evolve13 cq-commerce-frameworkEvolve13 cq-commerce-framework
Evolve13 cq-commerce-framework
 
AEM & eCommerce integration
AEM & eCommerce integrationAEM & eCommerce integration
AEM & eCommerce integration
 
Magento jsr
Magento jsrMagento jsr
Magento jsr
 
E commerce
E commerceE commerce
E commerce
 
Evolve 2014 experience driven commerce
Evolve 2014 experience driven commerceEvolve 2014 experience driven commerce
Evolve 2014 experience driven commerce
 
ContentsPhase 1 Design Concepts2Project Description2Use.docx
ContentsPhase 1 Design Concepts2Project Description2Use.docxContentsPhase 1 Design Concepts2Project Description2Use.docx
ContentsPhase 1 Design Concepts2Project Description2Use.docx
 
Shopify Theme Building Workshop
Shopify Theme Building WorkshopShopify Theme Building Workshop
Shopify Theme Building Workshop
 
Write Your iOS App in Swift with a Graph Database
Write Your iOS App in Swift with a Graph DatabaseWrite Your iOS App in Swift with a Graph Database
Write Your iOS App in Swift with a Graph Database
 
API Product Management and Strategy
API Product Management and StrategyAPI Product Management and Strategy
API Product Management and Strategy
 

More from Matt Glaman

Managing your Drupal project with Composer
Managing your Drupal project with ComposerManaging your Drupal project with Composer
Managing your Drupal project with ComposerMatt Glaman
 
Drupal 414: Meet Commerce 2.0
Drupal 414: Meet Commerce 2.0Drupal 414: Meet Commerce 2.0
Drupal 414: Meet Commerce 2.0Matt Glaman
 
Rockin' Search Engine Optimization in Drupal
Rockin' Search Engine Optimization in DrupalRockin' Search Engine Optimization in Drupal
Rockin' Search Engine Optimization in DrupalMatt Glaman
 
Rockin Responsive Content with Panels Layouts
Rockin Responsive Content with Panels LayoutsRockin Responsive Content with Panels Layouts
Rockin Responsive Content with Panels LayoutsMatt Glaman
 
Gettin responsive: Using Omega 3 and Omega 4.
Gettin responsive: Using Omega 3 and Omega 4.Gettin responsive: Using Omega 3 and Omega 4.
Gettin responsive: Using Omega 3 and Omega 4.Matt Glaman
 
Breaking down Drupal
Breaking down DrupalBreaking down Drupal
Breaking down DrupalMatt Glaman
 
Welcome to Drupal 262
Welcome to Drupal 262Welcome to Drupal 262
Welcome to Drupal 262Matt Glaman
 

More from Matt Glaman (7)

Managing your Drupal project with Composer
Managing your Drupal project with ComposerManaging your Drupal project with Composer
Managing your Drupal project with Composer
 
Drupal 414: Meet Commerce 2.0
Drupal 414: Meet Commerce 2.0Drupal 414: Meet Commerce 2.0
Drupal 414: Meet Commerce 2.0
 
Rockin' Search Engine Optimization in Drupal
Rockin' Search Engine Optimization in DrupalRockin' Search Engine Optimization in Drupal
Rockin' Search Engine Optimization in Drupal
 
Rockin Responsive Content with Panels Layouts
Rockin Responsive Content with Panels LayoutsRockin Responsive Content with Panels Layouts
Rockin Responsive Content with Panels Layouts
 
Gettin responsive: Using Omega 3 and Omega 4.
Gettin responsive: Using Omega 3 and Omega 4.Gettin responsive: Using Omega 3 and Omega 4.
Gettin responsive: Using Omega 3 and Omega 4.
 
Breaking down Drupal
Breaking down DrupalBreaking down Drupal
Breaking down Drupal
 
Welcome to Drupal 262
Welcome to Drupal 262Welcome to Drupal 262
Welcome to Drupal 262
 

Recently uploaded

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĂşjo
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Recently uploaded (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Decoupled Days 2019: Delivering Headless Commerce

  • 1. Centarro: Commerce with Confidence Delivering Headless Commerce Matt Glaman (mglaman) matt@centarro.io @nmdmatt
  • 2. • Drupal Commerce 2.x co-maintainer • Drupal 8 Development Cookbook author • drupal-check Matt Glaman Product Lead Our core team created and leads Drupal Commerce. https://www.drupal.org/centarro
  • 4. Centarro: Commerce with Confidence Headless Commerce…  Separates the customer experience layer from the core business application.
  • 5. Centarro: Commerce with Confidence Headless Commerce…  Supports any number of front end sites or apps
 from a single back end.
  • 6. Centarro: Commerce with Confidence Headless Commerce…  Evolves and scales your platform without impacting other components.
  • 8. React front end interacting  with a Drupal Commerce  API backend
  • 9.
  • 11.
  • 12.
  • 13. Challenges ! Structured data model ! Relationships layers ! Data vs Presentation layer couplings
  • 14. Centarro: Commerce with Confidence Available API integration options ! JSON:API ! GraphQL (v3, not v4) ! RESTful Web Services* * RESTful Web Services module does not provide any default schema, filtering, or collections but does allow building your own.
  • 15. Centarro: Commerce with Confidence JSON:API ! JSON:API is a RESTful API specification, implemented in Drupal ! Supports includes that fetch linked resources automatically ! Allows limiting fields returned, otherwise all fields ! Automatically exposes all entities as resources ! Uses entity UUIDs over normal identifiers
  • 16. Centarro: Commerce with Confidence GraphQL ! Query-like language API, not a RESTful API ! Fragments represent sets of fields (base fields, bundle fields) ! Must specify fields to be returned in a query ! Use GraphiQL IDE to build the query ! Uses normal identifiers, not UUIDs ! Manipulate data (Create, Update, Delete) via mutations
  • 17. Centarro: Commerce with Confidence RESTful Web Services ! Original API module in Drupal core, since 8.0.0 ! Plugins define resource endpoints ! Endpoints must be configured to turn them on, but there’s no UI ! Uses normal identifiers, not UUIDs ! No schema or opinions on the request or response
  • 18. Delivering ! Catalogs ! Product Display Pages ! Add to Cart Forms ! Shopping Carts ! Checkout
  • 20. Standard Drupal: Views + Search API + Facets
  • 21. Centarro: Commerce with Confidence Catalog areas of concern ! Highly customized queries for products across product types ! Powered by search indexes ! Utilize facets for fine tuned browsing ! Variable pricing based on customer context ! Product availability
  • 22. Centarro: Commerce with Confidence JSON:API ! Does not support mixed-bundle collections out of the box. (#2956414) ! Custom controller or support in JSON API Extras. ! Could integrate JSON API into Search API with some effort. GET
 /jsonapi/commerce_product/simple GET 
 /jsonapi/commerce_product/clothing GET
 /jsonapi/commerce_product/
  • 23. Centarro: Commerce with Confidence GraphQL ! Queries can become very large and complex. ! Reusable queries, as Query Maps are possible and allows reusing predefined queries.
  • 24. Centarro: Commerce with Confidence GraphQL & Search API ! GraphQL has Search API integration through a contributed module ! Query support using full text search ! Faceted search support ! Only returns data in the index; more like directly querying the search index with Drupal as a proxy
  • 26. Standard Drupal: Entity view display and Twig
  • 27. Centarro: Commerce with Confidence Product display page areas of concern ! Made up of a mix of marketing content and product data ! Representation of product variations and their field values ! Add to cart forms
  • 28. Centarro: Commerce with Confidence JSON:API ! Retrieve products by bundle and UUID
 
 
 
 ! Include variations, variation attributes, taxonomy terms, etc. using the include parameter
 ! Need additional strategies for image styles, such as the Consumer Image Styles module GET /jsonapi/commerce_product/simple/1630-42cd-af47 GET /jsonapi/commerce_product/clothing/1630-42cd-af47
  • 29. Sample JSON API request for a product and its variations (8.1kb, without fields 38kb)
  • 30. Centarro: Commerce with Confidence GraphQL ! Retrieve products by their ID and then request fields as needed ! Supports fetching images and specifying the proper image style
  • 31. Sample GraphQL request for a product and its variations
  • 32. Add to Cart Forms
  • 33. Centarro: Commerce with Confidence Add to cart form areas of concern ! Attribute select lists vs. fancy formatting (e.g. color swatches) ! Identifying the currently selected product variation ! Custom order item fields
  • 34. Standard Drupal: Form API with AJAX
  • 35. Cart API + Cart Flyout (drupalSettings, Underscore, Backbone, jQuery)
  • 37. GatsbyJS: JSON:API to internal GraphQL with React
  • 39. The challenge as maintainers:
 Provide abstract, reusable solutions for very purpose-built front ends.
  • 41. Progressively decoupled add to cart using Backbone + Underscore + Cart API
  • 42. Client side add to cart confirmation with related products
  • 43. Client side store selection for inventory, location aware Search API query over A
  • 45. Centarro: Commerce with Confidence Cart management areas of concern ! Anonymous and authenticated user owned carts ! Users can modify their carts, without fully managing the order ! Users shouldn’t be able to edit another user’s cart ! Constraints on product availability
  • 46. Centarro: Commerce with Confidence Cart API: Cart Operations ! Cart API hides internals knowledge and provides a friendly interface. ! RESTful Web Services endpoint plugins ! GET for collection of active carts or individual cart ! POST that creates the order item from a product and adds it to the proper cart. ! PATCH to update quantities POST /cart/add?_format=json
 [
   { "purchased_entity_type": "commerce_product_variation",
     "purchased_entity_id": "6", 
     "quantity": "1"
   }
 ]
 PATCH /cart/{order}/items?_format=json
 {
   3: {"quantity": 1},
   9: {"quantity": 2},
 }
  • 47. Centarro: Commerce with Confidence Cart API: Cart Tokens ! PHP Sessions persist via cookies ! Cookies are opt-in when making CORS enabled AJAX requests ! Cookies are blocked on cross-origin CORS enabled AJAX requests ! Solution: a passable token as a query parameter or header. GET /cart?_format=json
 Accept: application/json
 Commerce-Cart-Token: 123ABC GET /cart?_format=json&cartToken=123ABC
 Accept: application/json
  • 48. Centarro: Commerce with Confidence JSON:API ! Not out of the box without cross- bundle collection resources ! JSON:API is now stable and in Drupal core, easier to integrate and extend! ! Cart API 2.x will use JSON:API over RESTful Web Services plugins. ! Provides a cart collection endpoint and Cart Manager integration
  • 49. Centarro: Commerce with Confidence GraphQL ! GraphQL supports cross-bundle querying for cart item collections ! Carts are restricted by query access, so only the requesting user’s carts are returned ! Mutations are part of GraphQL Mutations module ! Requires writing GraphQL Mutation plugins
  • 50. Patrick Roger Fully decoupled Drupal Commerce https://snipcart.com/blog/case-study-patrick-roger-drupal-angular
  • 51.
  • 52. Centarro: Commerce with Confidence Headless Drupal Commerce & Angular with Snipcart Drupal Commerce is used for product and inventory management, shipping and tax calculations, and order fulfillment management Snipcart provides cart management and checkout, orders are synchronized through webhooks.
  • 53. Integrating Bots with Drupal Commerce Conversational Commerce https://2018.decoupleddays.com/session/conversational-commerce-integrating-bots-drupal-commerce
  • 54.
  • 56. Centarro: Commerce with Confidence Cart API: Coupons ! RESTful Web Services endpoint plugin ! Redemption via coupon code ! Limited to single coupon to avoid abuse ! Coupon reference constraint to validate coupons when attached, better API level handling
  • 57. Centarro: Commerce with Confidence JSON:API ! Requires querying for the coupon without exposing all
 currently available coupons ! Take the coupon identifier and PATCH a relationship ! Need custom relationship endpoint to accept coupon code ! Validation constraint will reject the coupon if invalid
  • 58. Centarro: Commerce with Confidence GraphQL ! Requires a custom mutation ! Accept the coupon code directly, like the RESTful Web Services endpoint
  • 60. Centarro: Commerce with Confidence Checkout over the API ! Experimented with a bespoke Checkout API for a GatsbyJS. ! Completing checkout is really just running the place order transition ! Problem is most of our validations are in the Checkout Form, not in data level constraints
  • 61. Centarro: Commerce with Confidence Checkout over the API ! In evaluation and discovery ! With JSON API or GraphQL Entity Mutation, direct entity access is not allowed for modifying an order ! Need to review entity access control to allow modifying order fields ! Entity and field constraints for checkout validation
  • 62. Centarro: Commerce with Confidence Third party checkouts
  • 63. Concern Worldwide Fully decoupled Drupal Commerce https://www.drupal.org/case-study/concern-worldwide-mobilisation-usability
  • 64. Custom add to cart for direct checkout
  • 65. Decoupled checkout using a custom built Checkout API module
  • 66. What’s on the horizon?
  • 67. Centarro: Commerce with Confidence What’s next? ! Improving query access and entity access
 https://www.drupal.org/project/commerce/issues/3041758 ! Coupon validation constraint in Drupal Commerce
 https://www.drupal.org/project/commerce/issues/3041856 ! Computed base order total field (subtotal, adjustments, total)
 https://www.drupal.org/project/commerce_cart_api/issues/3048704
  • 68. Centarro: Commerce with Confidence What’s next? ! Convert variations and order_item fields from Field Config to base fields
 https://www.drupal.org/project/commerce/issues/3002939 ! Resolved pricing (price list support, promotions support) ! Improved product availability handling (entity reference constraint)
  • 69. Centarro: Commerce with Confidence HIGH_VOLUME_DRUPAL7_HEADLESS_STORE migrates to headless Commerce 2.x ! High volume online convenience store ! Multiple stores, multiple currencies, and shipping integrations ! Drupal 7 API backend & multiple React frontend ! Tested to support well over 4,000 concurrent shopping sessions ! Third-party checkout
  • 70. Ready to get started?
  • 72. Centarro: Commerce with Confidence Cart API commerce_cart_api 
 Provides a RESTful interface to interact with carts in Drupal Commerce via a lightweight public API. JSON API integration still sandboxed
  • 73. Centarro: Commerce with Confidence Cart Flyout commerce_cart_flyout The Cart Flyout is a drop-in progressively decoupled replacement of the cart block. Provides a decoupled add to cart form.
  • 74. Centarro: Commerce with Confidence JSON API Generates an API server that implements the JSON:API specification. JSON:API is now part of Drupal core! 🎉
  • 75. Centarro: Commerce with Confidence GraphQL graphql & graphql_search_api Lets you craft and expose a GraphQL schema for Drupal 8.
  • 77. Guaranteed answers to the questions you have as you go headless with Drupal Commerce. • Private Q&A forum moderated by core maintainers • Each seat includes access to Centarro Toolbox: • Update Assistant • Quality Monitor • Partner products Professional Support from $99 / mo
  • 78. Prioritized support on a per-site basis to solve your blockers and bugs as fast as possible. • On-boarding site audit / project review • Private tickets for project-specific support • Guaranteed 1 day response time • Opened issues influence core roadmap • Semi-annual consultation Priority Support from $499 / mo
  • 79. Thank you for coming!
  • 80. Questions? Give it a spin! https://commerce-decoupled-days-2019.web.app/
 (JSON:API + React) https://react.demo.centarro.io/ 
 (GraphQL + React) https://gatsbyjs.demo.centarro.io/ 
 (GatsbyJS) https://demo.commercekickstart.com/ 
 (Progressively decoupled) matt@centarro.io @nmdmatt