Created
November 8, 2018 05:58
-
-
Save varun-pluginhive/4ca11475002212e4f6930c0c6ca83d44 to your computer and use it in GitHub Desktop.
Snippet to change Label size(LabelStockType) in FedEx create shipment request. WooCommerce FedEx Shipping Plugin with Print Label - https://www.pluginhive.com/product/woocommerce-fedex-shipping-plugin-with-print-label/
This file contains hidden or 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
| /** | |
| * Snippet to change Label size(LabelStockType) in fedex create shipment request. | |
| * Created at : 08 Nov 2018 | |
| * Updated at : 08 Nov 2018 | |
| * PluginHive Plugins : https://www.pluginhive.com/plugins/ | |
| * Gist Link : https://gist.github.com/varun-pluginhive/4ca11475002212e4f6930c0c6ca83d44 | |
| */ | |
| add_filter( 'wf_fedex_request', function( $request ){ | |
| // Fedex Services for which the label size need to be changed | |
| $services = array( | |
| 'FEDEX_1_DAY_FREIGHT', | |
| 'FEDEX_2_DAY_FREIGHT', | |
| 'FEDEX_3_DAY_FREIGHT', | |
| 'INTERNATIONAL_ECONOMY_FREIGHT', | |
| 'INTERNATIONAL_PRIORITY_FREIGHT', | |
| 'FEDEX_FIRST_FREIGHT', | |
| 'FEDEX_FREIGHT_ECONOMY', | |
| 'FEDEX_FREIGHT_PRIORITY', | |
| 'FEDEX_NEXT_DAY_FREIGHT' | |
| ); | |
| $LabelStockType = 'PAPER_LETTER'; // Label Size | |
| if( ! empty($request['RequestedShipment']['ServiceType']) && in_array( $request['RequestedShipment']['ServiceType'], $services) ){ | |
| if( ! empty($request['RequestedShipment']['LabelSpecification']['LabelStockType']) ) | |
| $request['RequestedShipment']['LabelSpecification']['LabelStockType'] = $LabelStockType; | |
| } | |
| return $request; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment