Skip to content

Instantly share code, notes, and snippets.

@renjith-ph
Created December 4, 2018 10:28
Show Gist options
  • Save renjith-ph/b53387e494192e4b316cfec7981acb22 to your computer and use it in GitHub Desktop.
Save renjith-ph/b53387e494192e4b316cfec7981acb22 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.PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* 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/
*/
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))
{
$custom_declared_value = get_post_meta( $product_data->get_id(), '_wf_ups_custom_declared_value', true );
if(!empty($custom_declared_value))
{
// $product_details['Unit']['Value']=$custom_declared_value;
$product_details['Unit']['Value']="11";
}
else
{
$product_details['Unit']['Value']="22";
}
}
else
{
$product_details['Unit']['Value']="33";
}
$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