# 1. Description

**Accessory Lock** prevents customers from purchasing accessory products without having the required main product in their cart. Validation is fully server-side and cannot be bypassed via JavaScript or browser manipulation.

## What the plugin does

Some products only make sense when the matching main product is also purchased — for example, a camera strap without a camera, or a charging cable without the compatible device. The plugin lets you configure these dependencies directly in the Shopware Admin and automatically enforces them at checkout.

**Key features:**

* **Cart validation:** Accessories cannot be ordered without a matching main product in the cart. The error message names the missing product by name.
* **Admin UI:** Every product detail page gets a dedicated "Accessory Lock" tab where you can assign and review dependencies.
* **Storefront hints:** Customers are guided on accessory product pages by a "Buy Together" widget. Main product pages automatically display a compatible accessories section.
* **Variant inheritance:** Configure the lock once on the parent product — all variants inherit the setting automatically.
* **n:n relationships:** An accessory can accept multiple main products (any one of them in the cart is sufficient).

## Storefront views

### "Compatible accessories" section on the main product page

On a main product's detail page, a section with all compatible accessories is automatically displayed below the product description. Customers can add both products to the cart together with a single click.

![Compatible accessories section on the main product page](https://459847022-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtiS3-dzuXFp_IH7yRw-1972196547%2Fuploads%2Fgit-blob-5490060177be9f1346086b298fc6af7771c5c269%2F4.png?alt=media)

### "Buy Together" widget on the accessory product page

On an accessory product's detail page, a widget replaces the standard purchase area. It lists all compatible main products as selectable options. Once a main product is already in the cart, the widget switches to an adapted view — showing the in-cart product as such and revealing the standard buy button.

![Buy Together widget on the accessory product page](https://459847022-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtiS3-dzuXFp_IH7yRw-1972196547%2Fuploads%2Fgit-blob-f08ce203a5c3c690e0bbbc6234902b0d68e534a8%2F5.png?alt=media)

## Technical details

* Compatible with **Shopware \~6.6.0** (plugin 1.x) and **Shopware \~6.7.0** (plugin 2.x)
* Requires **PHP 8.2+**
* No external services or API connections required
* Server-side validation via `CartValidatorInterface`
* Variant inheritance via Shopware's native DAL inheritance mechanism
