Skip to content

Instantly share code, notes, and snippets.

add_filter('wf_ups_rate', 'wf_modify_ups_rate', 10, 2);
function wf_modify_ups_rate($xml, $packages){
$amount_to_add = 3; //change this with your value to be added with each packages
if($xml){
for( $i=0; $i<count($packages); $i++ ){
//if negotiated rate
if( isset($xml->RatedShipment->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue) ){
if( property_exists($xml->RatedShipment->NegotiatedRates->NetSummaryCharges, 'TotalChargesWithTaxes') ){
$xml->RatedShipment->NegotiatedRates->NetSummaryCharges->TotalChargesWithTaxes->MonetaryValue += $amount_to_add;
@Nishadup
Nishadup / functions.php
Created August 16, 2017 14:52 — forked from xadapter/functions.php
Alter WooCommerce Product Weight and Dimension Dynamically
function filter_get_hook_prefix_weight($this_weight, $instance) {
if (!$this_weight || $this_weight < 0.6) $this_weight = .6;
return $this_weight;
}
function filter_get_hook_prefix_height($this_height, $instance) {