Validating Orders and Visibility Rules

Introduction

When creating or updating orders in the Ordermentum API, validation rules ensure that the data submitted is accurate, complete, and consistent with business logic. These rules help prevent errors and ensure orders are processed correctly.

This guide outlines key validation rules for managing orders and how visibility settings affect order processing.

Key Validation Rules for Orders

The Ordermentum API enforces several validation rules when creating or updating orders. These rules ensure that orders meet specific requirements before being accepted by the system.

Origin Property

The origin property can be used when creating or updating orders. The origin is crucial because different validation rules apply depending on whether the order is created by a supplier or a retailer. Suppliers generally have fewer restrictions compared to retailers.

Origin PropertyDescription
supplierOrder placed by supplier. Note: The user token needs access to the supplier that the products and rules originate from.
retailerOrder placed by retailer

Product Availability

When creating an order, ensure that the products being ordered are available to the retailer. Visibility settings (discussed below) determine which products and pricing are accessible to specific retailers.

Visibility Rules

Visibility rules control which products, pricing, and promotions a retailer can see when placing an order. These rules ensure that retailers can only order products that are relevant and available to them.

  • Product Visibility: Determines which products are visible to the retailer.
  • Price Group Visibility: Controls which price groups are applied to the retailer.
  • Add-on Visibility: Specifies which additional items (e.g., promotions) are available to the retailer.

How Visibility Affects Order Validation
When an order is submitted, the API checks that the retailer has access to the products and prices specified in the order. If a retailer attempts to order a product they do not have visibility for, the API will return a validation error.

Common Validation Errors

Here are some common validation errors you might encounter when creating or updating orders:

Error CodeDescription
400 Invalid ProductThe retailer does not have visibility for one or more products in the order.
400 Missing FieldsRequired fields are missing from the request.
403 UnauthorizedThe API token does not have permission to access the resource.

Best Practices for Handling Validations

Check Visibility Before Submitting Orders:
Ensure the retailer has visibility for all products and pricing included in the order.

Use the origin Property Correctly:
Set the origin property to indicate where the order originated from.

Handle Validation Errors Gracefully:
Implement error handling in your integration to manage validation errors and provide meaningful feedback to users.

By understanding validation rules and visibility settings, you can ensure that your orders are processed smoothly and without errors.