In this project, I created a custom WooCommerce setting called “Package Settings.” Within these settings, I added a checkbox field named “Active Sample Product.”

When checked, this option enables a button labeled “Muster bestellen” on the product’s front-end single page.

If a user clicks this button, the product is added to the cart with a prefix.

If the user tries to add the product to the cart again, an alert message displays, stating “Product already exists in cart.”

All the functionality is done programmatically by using my custom plugin.