shopp_fedex_request

filters the request used to build FedEx Rates soap request.

add_filter( 'shopp_fedex_request', [callback] )

@param array $request request used to build FedEx Rates soap request
@param Address $Shipping shipping Address specified on checkout
@param array $Packages array of packages

Description

filters the request used to build FedEx Rates soap request.

Example

// register filter callback
add_filter('shopp_fedex_request', 'shopp_fedex_request_fltr', 10, 3);

// create filter function
function shopp_fedex_request_fltr( $req, $addy, $pkgs ) {
    $requested = array();
    $count = 0;

    foreach ( $pkgs as $seq => $pkg ) {
        $requested["$count"] = array();
        $requested["$count"]['SequenceNumber'] = $seq;
        if( $this->insure ) {
            $requested["$count"]['InsuredValue'] = array(
                'Amount' => $pkg['insure'],
                'Currency' => 'USD'
            );
        }
        if ( $pkg['description'] )
            $requested["$count"]['ItemDescription'] = $pkg['description'];

        $requested["$count"]['Dimensions'] = array(
            'Length' => ceil( $pkg['length'] ),
            'Width'  => ceil( $pkg['width'] ),
            'Height' => ceil( $pkg['height'] ),
            'Units'  => "IN"
            );

        $requested["$count"]['Weight'] = array(
            'Units' => 'LB',
            'Value' => number_format( ($pkg["weight"] < 0.1 ? 0.1 : $pkg["weight"]), 1, '.', '')
            );

        $count++;
    }

    $req['RequestedShipment']['RequestedPackageLineItems'] = $requested;

    return filtered_value;
}

See Also

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.

Skip to toolbar