Skip to content

Instantly share code, notes, and snippets.

@renjith-ph
Created January 14, 2019 07:52
Show Gist options
  • Save renjith-ph/6fbedf4649f47d06bbf0d750274eb6e3 to your computer and use it in GitHub Desktop.
Save renjith-ph/6fbedf4649f47d06bbf0d750274eb6e3 to your computer and use it in GitHub Desktop.
Snippet to change product price to custom declared value and change unit of measurement for international shipping.
/* Snippet to change product price to custom declared value and change unit of measurement for international shipping.
Created at : 26 Nov 2018 PluginHive Plugins : https://www.pluginhive.com/plugins/
updated on : 14 Jan 2019
*/
add_filter( 'wf_ups_shipment_confirm_request_product_details', 'wf_ups_shipment_confirm_request_product_details', 10, 2 );
if( ! function_exists('wf_ups_shipment_confirm_request_product_details') ) {
function wf_ups_shipment_confirm_request_product_details( $product_details, $product_data ) {
if(!empty($product_data))
{
$product_id=(wp_get_post_parent_id($product_data->get_id())==0) ? $product_data->get_id() : wp_get_post_parent_id($product_data->get_id());
$custom_declared_value = get_post_meta( $product_id, '_wf_ups_custom_declared_value', true );
if(!empty($custom_declared_value))
{
$product_details['Unit']['Value']=$custom_declared_value;
}
}
$product_details['Unit']['UnitOfMeasurement']['Code']='SET'; // convert U/M to SET
return $product_details;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment