[{"data":1,"prerenderedAt":28},["ShallowReactive",2],{"$f24p4nmo5egrki":3,"$f38h4rgfxzd3qv":21},{"content":4,"package":5,"version":20},"# Usage\n\n## The Data Model\n\nA sample is a product variant. It belongs to the same product as the variant it samples, and the two are joined one-to-one:\n\n- `ProductVariant::getSample()` — the sample for this variant, or `null`\n- `ProductVariant::getSampleOf()` — the variant this one is a sample *of*, or `null` for a normal variant\n\n`sampleOf` is the discriminator. Anything in the plugin that has to tell a sample from a real variant tests it, and `null === $variant->getSampleOf()` is what \"this is a real variant\" means throughout.\n\nBecause a sample is an ordinary variant row, it carries its own channel pricing, shipping category, dimensions, weight, and tax category. Nothing special is needed to price, ship, or tax one.\n\n## Enabling Samples on a Product\n\nSamples are switched on per product, on the **Product Samples** tab of the admin product form. The tab holds a single *Samples Available* checkbox for a product with variants; for a simple product it also holds the sample's pricing, shipping, and tax fields.\n\nSaving the product with samples active is what generates the samples. Event listeners for the `sylius.product.pre_create` and `sylius.product.pre_update` events walk the product's variants and creates a sample for every one that does not already have one, so:\n\n- Enabling samples on a product that already has variants generates their samples on that save.\n- Adding a variant later generates its sample when the product, or the variant itself, is next saved.\n- A variant that already has a sample is left alone — samples are never regenerated or duplicated.\n\nSwitching *Samples Available* back off stops samples being offered, but does not delete the sample variants that already exist.\n\n### What a Generated Sample Starts With\n\n| Field                 | Initial value                                                                                 |\n|-----------------------|-----------------------------------------------------------------------------------------------|\n| Code                  | Built by the code generator                                                                   |\n| Name (per locale)     | Built by the `babdev_sylius_product_samples.product_variant.prefixed_sample_name` translation |\n| Option values         | Copied from the parent variant                                                                |\n| Channel pricing       | Price **0** in every channel the product is enabled in                                        |\n| Shipping \u002F tax fields | Empty                                                                                         |\n\n::div{class=\"docs-note docs-note--tip\"}\n\u003Cstrong>A generated sample is free until somebody prices it.\u003C\u002Fstrong> The common use case is free samples, and that is how the plugin's pricing defaults.\n::\n## Pricing and Editing a Sample\n\nSample product variants share a similar configuration as the core product variants they build on, with their settings in a dedicated \"Product Samples\" tab in the admin product management.\n\nSetting an *original price* above the sample's price marks the sample as discounted, exactly as it does for a normal variant. The storefront reports it as a `data-sample-original-price` attribute alongside the price; the plugin's own JavaScript component does not render a struck-through price on the button, so using it is a theme decision.\n\n## What the Shopper Sees\n\nOn the product page, a product with samples active renders a \"Request a Sample\" button beside the \"Add to cart\" button. The button's label reflects the selected variant's sample price in the current channel and is updated on-the-fly based on the customer's selection.\n\nClicking it submits the same add-to-cart form, and the plugin swaps the cart item's variant for that variant's sample before validation runs. The shopper gets the sample in their cart, not the product.\n\nSample line items are marked as samples wherever they appear, in one of two ways:\n\n| Surface                             | Treatment                                         |\n|-------------------------------------|---------------------------------------------------|\n| Cart widget popup, checkout summary | The product name is prefixed with `Sample -`      |\n| Cart summary and order line items   | A **Sample** tag is added beside the product name |\n| Admin order view                    | A **Sample** tag is added beside the product name |\n\nSample variants are kept out of the places a shopper picks a product: they are excluded from the product's enabled variants, from the variant choices on the product page and in the cart, and from the admin product variant grid.\n\n## Limiting Samples per Order\n\nEach channel carries an optional \"Max Samples Per Order\" value on the admin channel form. Leaving it empty means that channel imposes no limit.\n\nThe field only accepts values of 1 or more, so an empty value is the only way to express \"no limit\".\n\nWhen it is set, adding a sample that would take the order past the limit is rejected with a validation error, and so is editing cart quantities to the same effect. The limit counts the total **quantity** of sample items in the order, not the number of sample line items — three of one sample counts as three.\n",{"name":6,"slug":7,"description":8,"github":9,"packagistName":12,"packageType":13,"hasDocumentation":14,"supported":14,"visible":14,"versions":15},"Sylius Product Samples Plugin","product-samples-plugin","Adds support for product samples to Sylius applications.",{"owner":10,"repo":11},"BabDev","SyliusProductSamplesPlugin","babdev\u002Fsylius-product-samples-plugin","sylius-plugin",true,[16],{"version":17,"gitBranch":18,"released":19},"1.x","0.1",false,{"version":17,"gitBranch":18,"released":19},{"content":22,"package":23,"version":27},"- [Introduction](\u002Fopen-source\u002Fpackages\u002Fproduct-samples-plugin\u002Fdocs\u002F1.x\u002Fintro)\n- [Installation & Setup](\u002Fopen-source\u002Fpackages\u002Fproduct-samples-plugin\u002Fdocs\u002F1.x\u002Finstallation)\n- [Configuration](\u002Fopen-source\u002Fpackages\u002Fproduct-samples-plugin\u002Fdocs\u002F1.x\u002Fconfiguration)\n- [Usage](\u002Fopen-source\u002Fpackages\u002Fproduct-samples-plugin\u002Fdocs\u002F1.x\u002Fusage)\n",{"name":6,"slug":7,"description":8,"github":24,"packagistName":12,"packageType":13,"hasDocumentation":14,"supported":14,"visible":14,"versions":25},{"owner":10,"repo":11},[26],{"version":17,"gitBranch":18,"released":19},{"version":17,"gitBranch":18,"released":19},1790007747499]