Skip to content

Instantly share code, notes, and snippets.

@renjith-ph
Created December 4, 2018 10:23
Show Gist options
  • Save renjith-ph/3caef7cf052cb239af88fb50e15542ec to your computer and use it in GitHub Desktop.
Save renjith-ph/3caef7cf052cb239af88fb50e15542ec to your computer and use it in GitHub Desktop.
Snippet to change product price to custom declared value for international shipping.
/**
* Snippet to change product price to custom declared value for international shipping.
* Created at : 21 Nov 2018
* Updated on : 29 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))
{
$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;
}
}
return $product_details;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment