PS PrestaShop Beginner

DataFirefly Pack Variants: documentation

Set up combination choice in native PrestaShop 8 packs, from installation to bulk import.

Updated Module version 1.2.1

What the module does

In PrestaShop, a native pack forces you to pick one precise combination for each of its products, from the Pack tab in the back office. That product and combination pair is written to the database and the customer has no way to change it. Selling a pack containing a t-shirt in four sizes therefore means creating four packs.

DataFirefly Pack Variants adds a selector on the pack product page. For every item you make configurable, the customer picks the combination. The selection is validated server side, stored with the cart line, carried through to the invoice, and the stock decremented is the one of the combination actually chosen.

The module never modifies the PrestaShop pack table. The combination you declared in the back office stays in place and acts as the default value. Uninstall the module and your packs are strictly native again.

Installation

  1. In the back office, open Modules > Module Manager, click Upload a module and send the ZIP.
  2. The module creates its tables and adds a Pack variants tab under Catalog.
  3. Open the module configuration to set the block title, its position and how the native list behaves.

The module installs on PrestaShop 8.0 to 8.x. It requires no Composer dependency and no theme template override.

Configuring a pack

Go to Catalog > Pack variants. The search field at the top only lists products flagged as packs: type a name, a reference or an ID, then select the pack. Packs already configured are listed right below.

The edit screen shows every item of the pack, with its quantity, its declared combination and its thumbnail. Products without combinations are flagged and offer no setting.

The three modes

  • Fixed combination: native behaviour, no choice on the customer side. This is the default.
  • Customer chooses any combination: every combination of the product is offered.
  • Customer chooses among selected combinations: you tick the allowed combinations in the list. At least two are required, otherwise saving is refused.

Restricting the choice to one attribute group

A product with Size and Colour quickly generates dozens of combinations. The attribute group restriction covers the most common case: you pick Size, and the other attributes stay frozen on the values of the combination declared in the back office. The customer only sees a list of sizes, the colour stays the one you set for the pack.

The Reset this pack button at the bottom of the screen removes the whole configuration of the pack and puts it back on its native combinations.

Bulk import

If your catalogue already holds dozens of packs, the Bulk import panel on the module home screen applies one rule to all of them. You choose:

  • Packs to process: only those not configured yet, or all packs while overwriting existing settings.
  • Active packs only: to skip disabled packs.
  • Configuration to apply: free choice on every item, or a reset back to the native fixed combinations.
  • Restriction to an attribute group: Size for instance, applied wherever that group exists.
  • Items without that group: leave them fixed, or offer all their combinations.

The Preview button counts the packs involved and simulates the first batch without writing anything. The Run the import button then processes the catalogue in batches of 25, with a progress bar. Paging uses a cursor on the product id, which avoids the shifts caused by writing while walking the catalogue, and the timeouts on large catalogues.

General settings

In the module configuration:

  • Block title: the heading shown above the selectors, translatable per language.
  • Block position: below the product information through the native hook, or just above the add to cart button through a JavaScript move.
  • Hide the native pack list: on by default. The module renders the whole pack content itself, and keeping the native list would display the declared combinations, contradicting the customer choice.
  • CSS selector of the native list: .product-pack for Classic and Hummingbird. Change it only if your theme renders the pack content elsewhere.
  • Show item prices: the unit price of each product of the pack.
  • Hide out of stock combinations: when off, they stay selectable if the product allows ordering out of stock.
  • Hide the native customization box: keep it on, see the section below.

What the customer sees

On the pack product page, the module renders a card listing the whole content: a dropdown for each configurable item, the declared combination in plain text for the others. Every row carries the thumbnail, the quantity and, when the option is on, the unit price.

If the customer submits without completing a choice, an error message appears below the block and the add to cart is blocked. Out of stock combinations are disabled or hidden according to your settings.

Cart, order and invoice

The selection is stored in the native PrestaShop customization mechanism. That is what keeps two identical packs with different compositions on two separate cart lines, where the core normally merges lines carrying the same product. A customer adding the exact same composition twice simply sees the quantity of the existing line go to two.

The choice recap appears automatically in the cart, the order confirmation, the emails, the customer history, the back office order detail and the PDF invoice.

The module creates a text customization field on every pack product, flagged as a module field. Some themes still render an empty text box for it. The Hide the native customization box setting takes care of that and should stay on, unless your theme already hides module fields.

Stock

A native pack decrements the stock of the combination written in the pack table, not the one the customer picked. At order validation the module corrects it: the declared combination is credited back, the chosen one is debited, shop by shop.

This correction only applies to packs whose stock management mode decrements the products they contain. A pack set to decrement its own stock only is not concerned, and the edit screen warns you about it.

Troubleshooting

The block does not show on the product page

The block only appears when the pack holds at least one genuinely configurable item: a mode other than fixed, a product with combinations, and at least two candidate combinations left after the whitelist, attribute group and stock filtering. Also check that the displayProductAdditionalInfo hook is registered in your theme.

The native pack list is still visible

Your theme does not use .product-pack. Inspect the page, note the class or id of the container and set it in the CSS selector setting.

An empty text box appears on the page

That is the module customization field, rendered by some themes. Turn on the setting made for hiding it.

The choice does not show in the cart

Clear the PrestaShop cache and check that no third party module replaces the add to cart form. The module intercepts the button click in the capture phase to run before the theme script, but a form entirely rebuilt by another module can bypass that hook point.

Known limits

  • The combination price impact is ignored. A native pack is sold at a single price, which a customization cannot change. The edit screen flags the items concerned so you can exclude those combinations from the allowed list.
  • The invoice stays a single line at the pack VAT rate, with the details of the choices in the customization recap. If each component must be invoiced separately with its own rate, look at DataFirefly Pack Pro or Pack VAT Pro.
  • This version targets PrestaShop 8.0 to 8.x. The pack management screen having changed technical foundation in PrestaShop 9, the port will come as a dedicated version.

Compatibility

  • PrestaShop 8.0.0 to 8.x
  • Multistore: settings are stored per shop
  • Multilingual: module interface shipped in English, French, Spanish, German, Italian, Dutch, Polish and Portuguese
  • Tested on the Classic theme
Was this page helpful?

Still stuck? Contact support