Troubleshooting PrestaShop Mondial Relay: Resolving 'Incorrect Parcel Weight' API 20 Error
Troubleshooting PrestaShop Mondial Relay: Resolving 'Incorrect Parcel Weight' API 20 Error
Shipping module integrations can be tricky, especially when dealing with specific API requirements for data like parcel weight. This community insight from the PrestaShop forum highlights a common and frustrating issue faced by merchants using the Mondial Relay module, specifically the "API 20: Poids du colis incorrect" (Incorrect parcel weight) error.
The Problem: Mondial Relay Module Refuses Correct Weight
A PrestaShop merchant, 'kerlin', reported an inability to generate shipping labels using the Mondial Relay module (version 4.3.1) on PrestaShop 8.1.4. Despite an order weighing 1.6 kg, the module would either reject the input as "less than 15g" when entered as "1.6" (expecting grams), or return the dreaded "API 20: Poids du colis incorrect" error when entering "1600" (the correct weight in grams).
Initial troubleshooting steps taken by 'kerlin' were extensive:
- Setting PrestaShop's default weight unit to grams.
- Attempting an older module version (3.6.2).
- Clearing cache and deleting development/production folders.
- Resetting and reconfiguring the module.
- Trying various weight formats (e.g., 20g).
Notably, the Colissimo module on the same setup worked without issues, suggesting the problem was specific to the Mondial Relay integration.
Community Diagnosis: Unit Mismatches and Data Formatting
The community, led by 'Alexandre Carette', quickly converged on the most probable causes: a mismatch in the expected weight unit or data format between the PrestaShop module and the Mondial Relay API. Key discussion points and diagnostic suggestions included:
- Verify Weight Units: Ensure both PrestaShop and the Mondial Relay module are consistently configured to use grams, and that product/order weights are correctly stored (e.g., 1600 for 1.6 kg).
- Check Module-Specific Settings: Look for parameters like "Default weight unit" or "Weight format" within the Mondial Relay module's configuration.
- Test with Rounded Weights: Trying values like 1500g or 2000g can help isolate issues related to decimal points or specific weight thresholds.
- Deep Dive into Module Code: If basic settings don't resolve it, examining the module's core files (e.g.,
carrier.phpormondialrelay.php) for automatic weight conversions (e.g.,(float)casts,number_formatfunctions) before the API call is crucial. The API might expect an integer while the module sends a float, or vice-versa, or use a different decimal separator (point vs. comma). - API Log Analysis: If available, comparing the actual request sent by the module to the Mondial Relay API documentation for valid weight formats can pinpoint the discrepancy.
Potential Breakthrough: A Known Bug in 4.3.1?
'GekkodeFR' introduced a significant lead by referencing another forum thread concerning Mondial Relay version 4.3.1. This other thread suggested a potential bug where the weight might be recalculated incorrectly just before label generation, specifically during the creation of the relay address. A proposed fix in SelectRelayActions.php was mentioned as a possible solution for this version.
'Waldbyte' reinforced this by advising to verify the exact weight value transmitted to the API at the moment of label generation, reiterating the possibility of a last-minute conversion or recalculation error within the module's code, and supporting the investigation into SelectRelayActions.php.
Conclusion & Actionable Insights for Merchants and Developers
While 'kerlin' did not post a final resolution in this thread, the collective insights provide a robust troubleshooting path for anyone encountering the "API 20: Poids du colis incorrect" error with Mondial Relay on PrestaShop:
- Systematic Configuration Check: Ensure all weight units and formats are consistent across PrestaShop, product data, and the Mondial Relay module settings.
- Code-Level Debugging: Be prepared to inspect the module's PHP files for explicit weight conversions or formatting functions that might conflict with the Mondial Relay API's expectations.
- Look for Version-Specific Bugs: Check PrestaShop forums or module developer documentation for known issues related to your specific module and PrestaShop versions, as highlighted by the
SelectRelayActions.phplead for version 4.3.1. - Monitor API Requests (if possible): Understanding what data is actually sent to the API is key to resolving such integration errors.
This thread underscores the importance of meticulous configuration and, when necessary, delving into the module's code to resolve integration challenges that are often subtle yet critical for e-commerce operations.