UPS takes into account the value of the goods being shipped to produce its quote. This module is basically sending a 0 for the value of the products inside the box, so everything is being under-quoted. Consider adding code like this to commerce_ups.xml.inc around line 103 to include the order value with the shipping quote to get more accurate quotes.

$order_total = $order_wrapper->value();
$order_total = $order_total->commerce_order_total;
$order_total = array_values($order_total);
	    
$order_currency = $order_total[0][0]['currency_code'];
$order_total = $order_total[0][0]['amount'];
$order_total = $order_total / 100;
	
$package_service_options = $package->addChild('PackageServiceOptions');
$insured_value = $package_service_options->addChild('InsuredValue');
$insured_value->addChild('CurrencyCode',$order_currency);
$insured_value->addChild('MonetaryValue',$order_total);

Comments

andrew m riley’s picture

Assigned: Unassigned » andrew m riley

Thanks for looking into this Brent. I do think we should add this as a feature but I'm thinking it should be done on a per item basis. This way the shop owner gets to pick and choose which products are calculated as part of the total value and which ones are not. This way the users who want to use it can and the ones that don't want do don't have to and they have the flexibility of choosing both.

I'm going to talk with Ryan Szrama about possibly getting a new entity added to commerce_physical so all shipping modules will be able to take advantage of it. (I'll be asking about the feasibility of it living in the physical module vs shipping)

-- Research (for when I forget in a week why I wanted to go down this route) --
http://www.ups.com/content/us/en/shipping/time/service/value_added/decla...
http://www.ups.com/content/us/en/shipping/time/service/value_added/daily... (scroll down to declared value)

Declaring a value isn't something you have to do and it does affect the overall shipping cost. By default, without a declared value UPS' liability is limited to $100.

Pricing per domestic package and international shipment*:
$0.80 for each $100.00 (or portion of $100.00) of the total value declared, with a minimum charge of $2.40.

ultimike’s picture

Status: Active » Postponed (maintainer needs more info)

I've opened up an issue in Commerce Shipping in regards to this request. In speaking with Andrew Riley (another one of the maintainers of Commerce UPS), we figured that other modules might need access to this data, so it belongs further up the chain.

Thanks,
-mike

googletorp’s picture

Status: Postponed (maintainer needs more info) » Active

FYI: I've closed #1624878: "Declare product value" field? as won't fix.

svouthi’s picture

Since this module does not provide for adding the cost of insurance to shipments through passing on their value and there is no method built into Commerce for adding a fee based on the order subtotal using rules (I found only order total tokens which include the shipping cost), perhaps I can save others some time by providing the results of my searching. If you like, install Commerce Fees and Commerce Price By Components modules. After setup, compose rules to "apply a fee to an order" using the commerce-order:commerce-order-total:base-price:amount token (effectively the order subtotal) for each UPS insurance price bracket. e.g.:

{ "rules_insurance_for_ups_shipments_100_01_199_99" : {
    "LABEL" : "Insurance for UPS Shipments 100.01-199.99",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "commerce_order", "rules", "commerce_shipping", "commerce_fees" ],
    "ON" : [ "commerce_fees_order" ],
    "IF" : [
      { "AND" : [
          { "commerce_order_compare_address" : {
              "commerce_order" : [ "commerce_order" ],
              "address_field" : "commerce_customer_shipping|commerce_customer_address",
              "address_component" : "country",
              "value" : "US"
            }
          },
          { "data_is" : {
              "data" : [ "commerce-order:commerce-order-total:base-price:amount" ],
              "op" : "\u003E",
              "value" : "10000"
            }
          },
          { "data_is" : {
              "data" : [ "commerce-order:commerce-order-total:base-price:amount" ],
              "op" : "\u003C",
              "value" : "20000"
            }
          }
        ]
      },
      { "AND" : [
          { "OR" : [
              { "commerce_shipping_compare_shipping_service" : { "commerce_order" : [ "commerce_order" ], "service" : "ups_ground" } },
              { "commerce_shipping_compare_shipping_service" : {
                  "commerce_order" : [ "commerce_order" ],
                  "service" : "ups_next_day_air_saver"
                }
              }
            ]
          }
        ]
      }
    ],
    "DO" : [
      { "commerce_fees_apply" : {
          "entity" : [ "commerce-order" ],
          "fee" : "shipping_insurance",
          "amount" : "260",
          "currency_code" : "USD",
          "include_tax" : "0"
        }
      }
    ]
  }
}

UPS insurance rates (declared value charges) vary depending upon whether you are paying retail, standard/list, or perhaps a negotiated rate. Also, I am sure they are subject to periodic reevaluation and potential price increases, which would result in undercharging until the fees in the rules were adjusted to match. This is a very inelegant workaround. I would really like to see the declared value sent to UPS for accurate quoting real time.

svouthi’s picture

All right, as googletorp states above, ultimike's issue in Commerce Shipping has been closed.

I'm going to close this for two reasons.

1. Nobody wants to work on this.

2. Commerce and thus Commerce Shipping have the "small core" approach. Which means that we don't want to add a lot of extra stuff that maybe some other module can use. If a shipping method requires extra info like total cost, weight etc, it's not up to shipping module to store this info and pass it along. The shipping method get's the full order and can based on that do all the calculations it wants.

If some one disagrees with this, feel free to reopen and we can have a discussion about this issue.

It looks like declaring a shipment value is either destined for an independent module or for each of the shipping modules themselves.

Unless, Mr. Riley, Ryan had anything to say about it?

I'm going to talk with Ryan Szrama about possibly getting a new entity added to commerce_physical so all shipping modules will be able to take advantage of it. (I'll be asking about the feasibility of it living in the physical module vs shipping)
svouthi’s picture

I tried inserting aiquandol's code -

$order_total = $order_wrapper->value();
$order_total = $order_total->commerce_order_total;
$order_total = array_values($order_total);
       
$order_currency = $order_total[0][0]['currency_code'];
$order_total = $order_total[0][0]['amount'];
$order_total = $order_total / 100;
   
$package_service_options = $package->addChild('PackageServiceOptions');
$insured_value = $package_service_options->addChild('InsuredValue');
$insured_value->addChild('CurrencyCode',$order_currency);
$insured_value->addChild('MonetaryValue',$order_total);

and received a fatal error: Call to a member function addChild() on a non-object in /home/example/public_html/sites/all/modules/commerce_ups/commerce_ups.xml.inc on line 108

Has anyone else successfully inserted the above code to obtain UPS rates with insurance?

joelpittet’s picture

Assigned: andrew m riley » Unassigned
Issue summary: View changes

I'm on board with committing this if someone can submit a working patch to this issue.