Adding Custom Product Weight Fields in PrestaShop Product Pages

Adding Custom Product Weight Fields in PrestaShop

A PrestaShop merchant, Guylaine Pigeon, sought a way to display a product's weight directly on the product page, separate from the weight used for shipping calculations. The original request was posted on the PrestaShop forums.

The initial question was straightforward: how to add a custom field to the product page specifically for displaying the product's weight. This weight would be distinct from the weight used to calculate shipping costs.

Solutions and Suggestions

The first reply suggested using PrestaShop's built-in "features" functionality. This is a common and often suitable approach for adding extra product details.

The second reply highlighted the importance of providing more context, specifically requesting the PrestaShop version and the theme being used. This information is crucial for providing accurate and helpful advice, as different versions and themes may require different approaches.

Using Product Features

PrestaShop's product features allow you to add specific attributes to products. These features are displayed on the product page and can be used to provide additional information. To use features for displaying product weight:

  1. Navigate to Catalog > Attributes & Features in your PrestaShop admin panel.
  2. Create a new feature named "Product Weight" (or similar).
  3. Add values for this feature, such as weight values in kilograms or pounds.
  4. When editing a product, you can then assign a specific weight value from the available feature values.

Considerations for Custom Development

While using features is a quick and easy solution, it might not be ideal for all situations. If more advanced customization or specific formatting is required, developing a custom module might be necessary. A custom module would allow for greater control over how the weight is displayed and how it interacts with other elements on the product page.

Custom module development could involve:

  • Creating a new field in the product database table.
  • Modifying the product page template (likely a .tpl file) to display the custom field.
  • Using PrestaShop's API to save and retrieve the weight data.

Importance of Version and Theme Information

As pointed out in the replies, knowing the PrestaShop version and theme is vital. Different versions of PrestaShop have different database structures and template systems. Similarly, different themes have different layouts and CSS styles, which can affect how custom fields are displayed. Without this information, providing specific code examples or instructions is difficult.

For example, in older PrestaShop versions, you might need to override core classes or use specific hooks to modify the product page. In newer versions, the Symfony framework provides more structured ways to extend functionality.

Conclusion

Adding a custom product weight field to PrestaShop can be achieved using built-in features or through custom module development. The best approach depends on the specific requirements and the level of customization needed. Always remember to provide detailed information about your PrestaShop version and theme when seeking assistance, as this will greatly improve the quality of the support you receive.

Start with the tools

Explore migration tools

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

Explore migration tools