# 3. Usage

## Assigning an accessory lock to a product

Open the product you want to lock as an accessory (not the main product). Click the **Accessory Lock** tab.

![Accessory Lock tab with assigned main products and reverse view](https://459847022-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtiS3-dzuXFp_IH7yRw-1972196547%2Fuploads%2Fgit-blob-95a29d72897456731686f0ca52f0548a7a6abb4d%2F1.png?alt=media)

### Card: "Required Main Products"

The top card shows all main products that this product requires in the cart.

1. Click the product search field and type the name of the main product.
2. Select the desired product from the results.
3. The product appears in the table immediately.
4. Click **Save** in the top right to confirm the assignment.

**Multiple main products:** You can assign multiple main products. It is sufficient for any one of them to be in the cart — the customer does not need all of them.

**Removing an entry:** Click the three-dot menu in the relevant row and select **Delete**.

**Navigate to the main product:** Click the **Go to product** button in a row to jump directly to that product's detail page.

### Card: "Used as Main Product by"

The bottom card is a read-only information view. It shows all accessory products that require the current product as their main product. To change these assignments, open the respective accessory product.

Click on an accessory product's name to navigate directly to its detail page.

## How cart validation works

Once an accessory lock is configured, the plugin checks server-side on every cart update whether the required main product is present. If it is missing, an error message appears in the cart, naming both the accessory and the missing main product. The order cannot be completed until the main product is added.

Validation is fully server-side and cannot be bypassed by disabling JavaScript or through browser manipulation.

## Storefront behavior

### On the accessory product page

Customers see the **"Buy Together" widget**, which lists all compatible main products as selectable options. Clicking **"Add together to cart"** adds both the main product and the accessory to the cart at once.

If a main product is already in the cart, the widget switches to an adapted view: the in-cart main product is labeled as such, and the standard buy button is shown.

### On the main product page

A **"Compatible accessories"** section with a product slider is automatically shown below the product description. Each accessory card includes an **"Add together to cart"** button that adds both products at once.

Whether this section is displayed is controlled by the [configuration option](https://github.com/momocode-de/plugin-gitbook/blob/en/shopware-6/accessory-lock/configuration.md) **"Show 'Compatible accessories' section"**. Cart validation works independently of this setting.
