Skip to content

Instantly share code, notes, and snippets.

@zacharydanger
Created August 31, 2009 20:48
Show Gist options
  • Save zacharydanger/178701 to your computer and use it in GitHub Desktop.
Save zacharydanger/178701 to your computer and use it in GitHub Desktop.
product_list = list of selected products and quantities;
global_dunnage = percentage defined by admin;
fudge_factor = percentage defined by admin;
if ( total_cost meets freight override conditions ):
return freight calculation;
exit;
else:
for each product in product_list:
if( product has dunnage override ):
product_weight = weight * product_dunnage * product_quantity;
else:
product_weight = weight * global_dunnage * product_quantity;
calculate recommended boxes;
UPS_options = list of options returned from UPS based on recommended boxes and calculated weights;
for each option in UPS_options:
if( customer has override ):
cost = cost - customer_percent;
if( zip code has override ):
cost = cost - zip_percent;
cost = cost * fudge_factor;
display UPS shipping options;
end-if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment