Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. The Developer Center continues to support Commerce 6.13.0 through 7.4.1.Visit new site

Tutorial 4 - StopCondition

Tutorial 4 - StopCondition

Introduction

In this tutorial, you will learn how to add a need info link to a resource. By adding need info links, you can stop transactions from proceeding if not all the data has been obtained or confirmed. In the resource we will be working with, we will add a need info link that will prevent an order from proceeding until its Terms and Conditions form has been agreed to.

Warning: Before you begin

Make sure your development environment has been properly set up as described in Setting up your Developer Environment.

Begin: Installing Cortex API Tutorials

Source files

The files created in this tutorial may be found in the tutorials zip under /Rest-Tutorials/rest-resource-stopcondition directory.

rest-resource-corelookup has the following directory structure:

AgreeToTermsAndConditionsCommand.java and AgreeToTermsAndConditionsCommandImpl.java

AgreeToTermsAndConditionsCommand.java and AgreeToTermsAndConditionsCommandImpl.java implement the command for agreeing to the terms and conditions of an order.

BuildTermsAndConditionsFormCommand.java and BuildTermsAndConditionsFormCommandImpl.java

BuildTermsAndConditionsFormCommand.java and BuildTermsAndConditionsFormCommandImpl.java implement the command for building the terms and conditions form representation.

GetOrder.java

GetOrder.java is a class for getting an Order Representation.

TermsAndConditionsCsvLookup.java

TermsAndConditionsCsvLookup.java is a reader / writer to the Terms and Conditions CSV file.

TermsAndConditionsLookup.java

TermsAndConditionsLookup.java is responsible for getting and setting the AgreeToTerms value in the resource.

terms_and_conditions.csv

terms_and_conditions.csv is used by this tutorial to persist data regarding whether a user has agreed to the terms and conditions. In an actual environment, you will either cache this information or store it in a database.