Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I ran into an issue where my client needed to add extra weight to the package weight to handle things like ice packs, peanuts and the weight of the box. This adds two configuration options to the UPS module that allows for a Numeric Value and a Addition Type (Percentage, Multiplier, Mass).
Comment | File | Size | Author |
---|---|---|---|
uc_ups.module.patch | 1.72 KB | McBastard | |
uc_ups.admin_.inc_.patch | 1.37 KB | McBastard | |
Comments
Comment #1
TR CreditAttribution: TR commented1) Remove tabs from your patch - check coding standards by running the Coder module on your site.
2) When you add system variables you need to modify hook_uninstall() to remove those variables when the module is uninstalled.
3) Reduce trim() calls - see how uc_fedex or uc_canadapost implement this markup. Should probably make that change in uc_ups_markup().
4) Should probably rename uc_ups_markup() to uc_ups_rate_markup() to distinguish it from uc_ups_weight_markup(), and change the two variables used by uc_ups_markup() correspondingly. Changing variable names necessitates writing a hook_update_N() to rename the stored variables in the database.
Comment #2
McBastard CreditAttribution: McBastard commentedI didn't write the uc_ups_markup function, it was already part of the core. If there is no issues with me doing what you asked, I'll fix it.
Comment #3
TR CreditAttribution: TR commentedI've already put most of this into 7.x-3.x for both uc_ups and uc_usps. Code was taken from my uc_fedex module. I addressed all the items in my comment #1. The only thing left to do is to add the line in the packaging code to do the actual markup - that's complicated by the fact that there's a max weight limit for the packages so you can't just scale the package weight. I'll complete this when I have some time to do proper tests.
I've moved this to the 7.x-3.x queue - it can be backported after it's finished.
Comment #4
TR CreditAttribution: TR commentedComment #5
TR CreditAttribution: TR commented