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

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Creating a State Policy extension point

Creating a State Policy extension point

In order to Creating a State Policy Contribution, you must add a State Policy extension point to the plugin.

To create a State Policy extension point for a plugin, do the following:

  1. Open plugin.xml in Eclipse.
  2. In the Extension Points tab, click the Add button next to the All Extension Points list.
  3. In the New Extension Point dialog, enter the following:
    Extension Point ID statePolicy

    Extension Point Name

    State Policy

    Extension Point Schema

    Leave blank and make sure Edit extension point schema when done is selected

    Click Finish. A new schema file named statePolicy.exsd is created and is displayed automatically.
  4. In the Source tab of the statePolicy.exsd file, paste the following:
    <?xml version='1.0' encoding='UTF-8'?>
    <!-- Schema file written by PDE -->
    <schema targetNamespace="com.elasticpath.cmclient.admin.gc" xmlns="http://www.w3.org/2001/XMLSchema">
    <element name="extension">
      <complexType>
        <sequence minOccurs="1" maxOccurs="unbounded">
          <element ref="statePolicyContribution"/commerce-legacy/>
        </sequence>
        <attribute name="point" type="string" use="required"/commerce-legacy/>
      </complexType>
    </element>
    <element name="statePolicyContribution">
      <complexType>
        <attribute name="targetId" type="string" use="required">
          <annotation>
            <documentation>The target of the given policy</documentation>
          </annotation>
        </attribute>
        <attribute name="statePolicy" type="string" use="required">
          <annotation>
            <documentation>The state policy that is being contributed</documentation>
            <appInfo><meta.attribute kind="java" basedOn=":com.elasticpath.cmclient.policy.StatePolicy"/commerce-legacy/></appInfo>
          </annotation>
        </attribute>
        <attribute name="priority" type="string" use="required">
          <annotation>
            <documentation>The priority of the contributed policy.
    This is used by a policy resolver to combine contributed policies.</documentation>
          </annotation>
        </attribute>
      </complexType>
    </element>
    </schema>