Last active
April 2, 2018 10:44
-
-
Save Nishadup/0ad4feeb8dc8133e2224b1e3407e2917 to your computer and use it in GitHub Desktop.
Print doctab in FedEx EPL/ZPL label Work with Xadapter FedEx plugin https://www.xadapter.com/product/woocommerce-fedex-shipping-plugin-with-print-label/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wf_fedex_request','custom_label_orientation', 10, 2 ); | |
function custom_label_orientation($request, $order){ | |
$fedex_settings = get_option( 'woocommerce_wf_fedex_woocommerce_shipping_settings', null ); | |
$selected_service = $request['RequestedShipment']['ServiceType']; | |
$custom_services = $fedex_settings['services']; | |
$shipping_charge = $order->get_total_shipping(); | |
$handling = $shipping_charge; | |
// Cost adjustment % | |
if ( ! empty( $custom_services[ $selected_service ]['adjustment_percent'] ) ) { | |
$handling = $handling + ( $handling * ( floatval( $custom_services[ $selected_service ]['adjustment_percent'] ) / 100 ) ); | |
} | |
// Cost adjustment | |
if ( ! empty( $custom_services[ $selected_service ]['adjustment'] ) ) { | |
$handling = $handling + floatval( $custom_services[ $selected_service ]['adjustment'] ); | |
} | |
$handling = abs($handling-$shipping_charge); | |
$request['RequestedShipment']['CustomsClearanceDetail']['CommercialInvoice']['HandlingCosts'] = array( 'Amount' => $handling, 'Currency' => get_woocommerce_currency() ); | |
$request['RequestedShipment']['RateRequestTypes'] = 'LIST'; | |
$request['RequestedShipment']['LabelSpecification']['LabelPrintingOrientation'] = 'TOP_EDGE_OF_TEXT_FIRST'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['DocTabContentType'] = 'ZONE001'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][0]['ZoneNumber'] = '1'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][0]['Header'] = 'Invoice'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][0]['DataField'] = 'REQUEST/PACKAGE/CustomerReferences[CustomerReferenceType="INVOICE_NUMBER"]/value'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][1]['ZoneNumber'] = '2'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][1]['Header'] = 'Customer'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][1]['DataField'] = 'REQUEST/SHIPMENT/Recipient/Contact/PersonName'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][2]['ZoneNumber'] = '3'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][2]['Header'] = 'Dept'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][2]['DataField'] = ''; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][3]['ZoneNumber'] = '4'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][3]['Header'] = 'PO Number'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][3]['DataField'] = 'REQUEST/PACKAGE/CustomerReferences[CustomerReferenceType="P_O_NUMBER"]/value'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][4]['ZoneNumber'] = '5'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][4]['Header'] = 'Date'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][4]['DataField'] = 'REQUEST/SHIPMENT/ShipTimestamp'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][5]['ZoneNumber'] = '6'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][5]['Header'] = 'Wgt'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][5]['DataField'] = 'REQUEST/PACKAGE/Weight/Value'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][6]['ZoneNumber'] = '7'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][6]['Header'] = 'COD'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][6]['DataField'] = 'REQUEST/SHIPMENT/SpecialServicesRequested/CodDetail/CodCollectionAmount/Amount'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][7]['ZoneNumber'] = '8'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][7]['Header'] = 'Delivery'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][7]['DataField'] = 'REPLY/SHIPMENT/OperationalDetail/DeliveryDate'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][8]['ZoneNumber'] = '9'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][8]['Header'] = 'Shipping'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][8]['DataField'] = 'REPLY/SHIPMENT/RATES/PAYOR_ACCOUNT_PACKAGE/TotalBaseCharge/Amount'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][9]['ZoneNumber'] = '10'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][9]['Header'] = 'Special'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][9]['DataField'] = 'REPLY/SHIPMENT/RATES/PAYOR_ACCOUNT_PACKAGE/TotalSurcharges/Amount'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][10]['ZoneNumber'] = '11'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][10]['Header'] = 'Handling'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][10]['DataField'] = 'REQUEST/SHIPMENT/CustomsClearanceDetail/CommercialInvoice/HandlingCosts/Amount'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][11]['ZoneNumber'] = '12'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][11]['Header'] = 'Total'; | |
$request['RequestedShipment']['LabelSpecification']['CustomerSpecifiedDetail']['DocTabContent']['Zone001']['DocTabZoneSpecifications'][11]['DataField'] = 'REPLY/SHIPMENT/RATES/PAYOR_ACCOUNT_PACKAGE/TotalNetCharge/Amount'; | |
return $request; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment