Diamond sponsors

The king is dead, long live the king - or how Hooks were superseded by object oriented alternatives in Commerce 2.x.

Profile picture for user Andreas Albers
Andreas
Albers
Developer
Linkfactory A/S
Profile picture for user zaporylie
Jakub
Piasecki
CTO
Linkfactory A/S
Type
Talk
Experience level
Beginner
Duration
45 minutes
Room
2.02 chromium
Starts at
Ends at
Industry track
Expertise topics
Summary

Commerce 2.x has almost completely ditched Hooks. They were replaced by Plugins, Services, Events. In this session, we will go through the Commerce API to answer, how can we implement the complex business logic and make your upcoming Commerce 2.x project a success story.

Description

---

Hooks were always a crucial part of Drupal API. For "Drupal7 Developer" hook system is everything. Probably every project built based on Drupal 7, which requires some custom code, have implemented at least one hook. Commerce 1.x provided all sort of hooks to interact with your online e-commerce platform.

In Drupal 8 hooks are still a vital part of Drupal API, especially around Entity component, and they still allow us to interact with Drupal Core and Contrib modules. But Drupal 8 is now object-oriented, so hooks just doesn't "look" or "feel" good anymore.

But we are not left on our own. Drupal is now highly pluggable in an object-oriented manner. We have - Plugins, (tagged) Services, and last but not least, Events. In this session, we will talk about the differences between all three. We will go through the most popular hooks from Commerce 1.x and check what they become in Commerce 2.x. We will give simple recipes on how to interact with the Order being placed, how to resolve Product price or Tax, how to filter out Product Variants based on custom criteria (not just disabled ones), we will implement custom condition plugins.

We will do the object-oriented-magic together.

Events are magic!

 

Platinum sponsors