Yep, Rules Components is the way to go here.

Thanks @agileadam for the suggestion to add something to the README.txt. This is done and has been committed.

Thanks,
-mike

Comments

agileadam’s picture

Status: Active » Needs review
StatusFileSize
new20.27 KB
new37.94 KB
new3.9 KB

Here's a patch that adds markup options to the Commerce UPS module. I've tested all options, validations, calculations, etc.
I am human, however... so please test before using.
Enjoy!

What it looks like:
UI of Commerce UPS markup fieldset
Markup choices

agileadam’s picture

Realized I used the wrong patch number in my first comment... it doesn't affect the patch, but the filename of the patch should've been:
commerce_ups-adds_rate_markup_options-1832350-1.patch

chrisNtampa’s picture

Works like a boss for me. Thanks!

gmaldonado’s picture

Status: Needs review » Reviewed & tested by the community

This funtionality is so needed.

Just migrated an old site from Oscommerce and the option to add this markup was there, it was odd that was not in the drupal module.

Also I am using the USPS module, which does have this markup option.

Thanks for this excellent patch, I've tested it and works great.

waltercat’s picture

Has anyone gotten this to work with 2.0-dev? I just tried installing the patch and it failed:

Hunk #2 succeeded at 338 (offset 7 lines).
Hunk #3 FAILED at 419.
1 out of 3 hunks FAILED -- saving rejects to file commerce_ups.admin.inc.rej
patching file commerce_ups.module
Hunk #1 succeeded at 99 with fuzz 2 (offset 6 lines).

jessepinho’s picture

Why not just use shipping calculation rules? That provides an abstract way of dealing with markups/markdowns without the need for duplicating this functionality in a shipping method-specific module.

MaWebDesigns’s picture

As a followup to jessepinho's comment - adding a standard markup is relativly easy using the commerce shipping rules. This video does a good job at explaining how to do it: http://www.youtube.com/watch?v=DNF4Mpy5f5w

Best part is that it can be used with any shipping module and no code changes required!

agileadam’s picture

I was going to re-patch for the 2.x branch, but I concur with jessepinho and MaWebDesigns.

Maintainers... this issue and associated patch should probably go away in favor of using shipping calculation rules. I'd love to see this mentioned or explained in the README for this module.

If someone needs a patch against 2.x I'd be happy to provide it, but it's probably not necessary.

BTW, I noticed some strange behavior when trying to apply a markup to UPS shipping rates only (not USPS, for example).
Here are the settings I use for a 30% markup: http://goo.gl/Y3dKCj

agileadam’s picture

As a follow-up, I see that Commerce USPS now states the following in regards to their 2.x branch:

Re-create any markups using rules components (the markup feature has been removed)

junetellain626’s picture

Can anyone post an export of their rules configuration that enabled them to modify the UPS service amount? (add, substract, etc).

Tried adding as a condition:
a. Data comparison
Parameter: Data to compare: [commerce-line-item:type], Data value: Shipping
b. Data comparison
Parameter: Data to compare: [commerce-line-item..., Data value: UPS 2nd Day Air (UPS)

Then added an action "Add an amount to the unit price".
But no UPS services can be accessed. The select boxes can only access the flat rate services.

Any tips? Thanks!

jessepinho’s picture

@junetellain626 Where do you expect the UPS services to be accessed? Do you mean under "Price component type"? If so, simply select "Shipping."

As far as I understand, different modules use price components differently. The Flat Rate module uses separate components for each rate, whereas the UPS module simply uses the "Shipping" component.

junetellain626’s picture

@jessepinho Thanks a lot! It worked!
Paired it up with the conditions I listed above and it limited the additional rate to only the UPS services that I specified.

Maybe I was confused since I started adding additional rates to Flat Rate services, and I could access these flat rate services directly via the "Price Component type". I thought, wrongly, that it should somehow be the same way with UPS services.

Here's the rule export of my shipping calculation. It should add $5 to the UPS services (Note: UPS services here are not complete):

{ "rules_add_5_to_ups_services" : {
    "LABEL" : "Add $5 to UPS services",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "commerce_line_item", "commerce_shipping" ],
    "ON" : [ "commerce_shipping_calculate_rate" ],
    "IF" : [
      { "data_is" : { "data" : [ "commerce-line-item:type" ], "value" : "shipping" } },
      { "OR" : [
          { "data_is" : {
              "data" : [ "commerce-line-item:commerce-shipping-service" ],
              "value" : "ups_2nd_day_air"
            }
          },
          { "data_is" : {
              "data" : [ "commerce-line-item:commerce-shipping-service" ],
              "value" : "ups_2nd_day_air_a.m."
            }
          },
          { "data_is" : {
              "data" : [ "commerce-line-item:commerce-shipping-service" ],
              "value" : "ups_3_day_select"
            }
          },
          { "data_is" : {
              "data" : [ "commerce-line-item:commerce-shipping-service" ],
              "value" : "ups_ground"
            }
          },
          { "data_is" : {
              "data" : [ "commerce-line-item:commerce-shipping-service" ],
              "value" : "ups_next_day_air"
            }
          },
          { "data_is" : {
              "data" : [ "commerce-line-item:commerce-shipping-service" ],
              "value" : "ups_next_day_air_saver"
            }
          },
          { "data_is" : {
              "data" : [ "commerce-line-item:commerce-shipping-service" ],
              "value" : "ups_next_day_early_a.m."
            }
          },
          { "data_is" : {
              "data" : [ "commerce-line-item:commerce-shipping-service" ],
              "value" : "ups_worldwide_saver"
            }
          }
        ]
      }
    ],
    "DO" : [
      { "commerce_line_item_unit_price_add" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : "500",
          "component_name" : "shipping",
          "round_mode" : "0"
        }
      }
    ]
  }
}
jessepinho’s picture

Glad I could help!

ultimike’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

This needs a re-roll for the 2.x branch of Commerce UPS or (possibly even better) some documentation on how to do this the Rules module (which I

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

hockey2112’s picture

Is there any way to modify this code to work with Commerce on Drupal 8?