Streamlining Quantity Calculation: A PrestaShop Module for Complex Product Units

Solving the 'How Many Boxes?' Dilemma in PrestaShop

For many PrestaShop merchants, a common friction point arises when customers need to purchase products like floor tiles, fabric, cable, or insulation. Shoppers often know the total amount they need (e.g., 47 square metres), but products are sold in fixed packs (e.g., boxes covering 1.44 square metres). This discrepancy frequently leads to customer calculation errors, resulting in either short orders, frustrating returns, or abandoned carts. The forum thread introduces a dedicated PrestaShop module designed to bridge this gap, enhancing the customer experience and operational efficiency.

The Problem: Customer vs. Product Units

The core issue highlighted is the mismatch between how customers think about quantities and how products are packaged and sold. Customers want to input '47 square metres,' but the product page demands 'how many boxes.' This mental arithmetic often leads to mistakes, impacting both customer satisfaction and store logistics.

The Solution: The Pack Calculator Module by MEG Venture

MEG Venture's 'Pack Calculator' module (version 2.0.0, compatible with PrestaShop 1.7, 8, and 9) provides an elegant solution by automating this conversion directly on the product page. Instead of manual calculations, customers can input their desired amount (e.g., 47 square metres), and the module automatically calculates and displays the required number of packs (e.g., 33 boxes, covering 47.52 square metres). Key features and benefits include:

  • Automatic Calculation & Rounding: Converts desired amount to packs, always rounding up to ensure sufficient quantity.
  • Bi-directional Sync: Changing the desired amount updates the pack quantity, and vice-versa.
  • Flexible Unit Support: Admins can define pack coverage in various units (area, length, volume, weight, count). Customers can also select their preferred units (e.g., square feet vs. square metres) with built-in conversion.
  • Waste Allowance: An optional percentage field allows customers to add extra for cuts and waste, a crucial feature for products like flooring.
  • Price Per Unit Display: Shows the actual price per unit (e.g., per square metre), aiding customer comparison.
  • Customizable Constraints: Supports minimum, maximum, and step quantities per product.
  • Placement Options: The calculator can be placed next to 'Add to cart,' in a dedicated product tab, or below the description, with shop-wide defaults and per-product overrides.
  • No Theme Overrides: The module integrates cleanly without modifying core theme files, simplifying updates and maintenance.

Addressing Critical PrestaShop 1.x Bugs

A significant highlight of version 2.0.0 is its rewrite, which specifically tackles several critical bugs prevalent in earlier PrestaShop 1.x implementations:

  • AJAX Combination Issues: Previously, changing product combinations via AJAX would often break event handlers, causing the calculator to stop responding. Version 2.0.0 resolves this, ensuring the calculator remains functional with combination changes.
  • Price Display Inaccuracies: The module fixes a bug where the displayed price did not update correctly when the quantity changed.
  • Empty Step Value Handling: Correctly manages empty step values, preventing 'Infinity' from appearing in the quantity box.
  • jQuery Optimization: Drops the reliance on jQuery 1.12.4 from a third-party CDN, improving performance.

These fixes are particularly valuable for developers and merchants who have struggled with the complexities of PrestaShop's front-end AJAX interactions.

What the Module Does Not Do

It's important to note the module's deliberate limitations:

  • It calculates packs based on desired amount but does not price items by the square metre; the price remains per pack.
  • The waste allowance is a flat percentage, not a sophisticated cutting plan.

Community Reception and Alternatives

The community response was positive, with users like 'prince73' praising the module's specific bug fixes, especially for the AJAX combination issues, and its practical utility for buyers. The discussion also revealed a demand for such functionality, with 'karan06' offering custom development services to implement similar features, underscoring the value of this type of solution for the PrestaShop ecosystem.

This module offers a robust, well-engineered solution to a common e-commerce problem, significantly improving the user experience for stores selling products with complex unit requirements.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools