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
// Fedex Block Services for particular Zip Codes. | |
// Unset the shipping options of shipping method. | |
// You can find the shipping service codes by doing inspect element using | |
// developer tools of chrome. Code for each shipping service can be obtained by | |
// checking 'value' of shipping option. | |
add_filter('woocommerce_package_rates', 'wf_remove_shipping_options_for_particular_zip_codes', 10, 2); | |
function wf_remove_shipping_options_for_particular_zip_codes($rates, $package) | |
{ |
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','wf_fedex_label_request_callback', 10, 2 ); | |
function wf_fedex_label_request_callback($request,$order){ | |
$custom_product_description = 'My Product Description'; | |
$request['CustomerReferences'][] = array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => $custom_product_description ); | |
$RequestedPackageLineItems = !empty( $request['RequestedShipment']['RequestedPackageLineItems'] ) ? $request['RequestedShipment']['RequestedPackageLineItems'] : array() ; | |
$flag = 0; |
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','wf_fedex_label_request_callback', 10, 2 ); | |
function wf_fedex_label_request_callback($request,$order){ | |
$custom_product_description = 'My Product Description'; | |
$commodities = !empty( $request['RequestedShipment']['CustomsClearanceDetail']['Commodities'] ) ? $request['RequestedShipment']['CustomsClearanceDetail']['Commodities']: array() ; | |
foreach ($commodities as $product_id => $value) { | |
$request['RequestedShipment']['CustomsClearanceDetail']['Commodities'][$product_id]['Description'] = $custom_product_description; | |
} | |
return $request; | |
} |
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','wf_fedex_label_custom_product_name_request_callback', 10, 2 ); | |
function wf_fedex_label_custom_product_name_request_callback($request, $order){ | |
$product_name = 'Book'; //Type here a product name it'll come as name of all products, Don't leave this blank or white space | |
$product_description = 'Book'; //Description, This will come for all products, Don't leave this blank or white space | |
$commodities = isset( $request['RequestedShipment']['CustomsClearanceDetail']['Commodities'] ) ? $request['RequestedShipment']['CustomsClearanceDetail']['Commodities'] : ''; | |
if($commodities != '' ){ | |
foreach ($commodities as $key => $commodity) { | |
$request['RequestedShipment']['CustomsClearanceDetail']['Commodities'][$key]['Name'] = sanitize_title( $product_name ); | |
$request['RequestedShipment']['CustomsClearanceDetail']['Commodities'][$key]['Description'] = sanitize_title( $product_description ); |
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','wf_fedex_label_request_reff_callback', 10, 2 ); | |
function wf_fedex_label_request_reff_callback($request,$order){ | |
$po_number = 'x'; | |
$inv_number = 'x'; | |
$customs_duties_payer = 'SENDER'; | |
$reff = array(); | |
$reff['CustomerReferences'][] = array( 'CustomerReferenceType' => 'P_O_NUMBER', 'Value' => $po_number ); | |
$reff['CustomerReferences'][] = array( 'CustomerReferenceType' => 'INVOICE_NUMBER', 'Value' => $inv_number ); | |
$reff['CustomerReferences'][] = array( 'CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => $order->id ); |
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
// Snippet for Rate request: | |
add_filter('wf_fedex_calculate_shipping_request','wf_fedex_dual_account_rate_request_callback', 10, 2 ); | |
function wf_fedex_dual_account_rate_request_callback($request,$packages){ | |
$ship_from_country_code = ''; // Origin Countrycode | |
$ship_from_postal_code = ''; // Postal code associated with alternative account | |
$fedex_international_acc_no = ''; // Alternative account number | |
$fedex_international_meter_number = ''; // Alternative account meter number | |
$fedex_international_key = ''; // Authentication Key of alternative account | |
$fedex_international_pwd = ''; // Password of alternative account |
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_canadapost_request','wf_canadapost_label_request_callback', 10, 2 ); | |
function wf_canadapost_label_request_callback($request,$order){ | |
$custom_product_description = 'My product description'; // This text might not exceed 35 characters | |
$xml = new SimpleXMLElement($request); | |
if($xml->{'delivery-spec'}->{'destination'}->{'address-details'}->{'country-code'} != 'CA'){ //if international | |
$ref_no = $xml->{'delivery-spec'}->{'references'}->{'customer-ref-1'}; | |
$custom_text = $ref_no.", ".$custom_product_description; | |
$xml->{'delivery-spec'}->{'references'}->{'customer-ref-1'} = substr($custom_text,0,35); |
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_australia_post_rate_services', 'alter_service_rate_adjustments', 10, 2 ); | |
function alter_service_rate_adjustments( $rate_service, $rate_code){ | |
// Array of service codes with combination of shipping class and price adjustment | |
$adjustments = array( | |
'AUS_PARCEL_REGULAR' => array( | |
'16' => 4, // Shipping Class ID => Adjustment Price | |
'17' => 3, | |
), | |
'AUS_PARCEL_EXPRESS' => array( |
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_ups_shipment_confirm_request','alter_shipment_request',10,3); | |
function alter_shipment_request($request,$order){ | |
$customer_first_name = $order->shipping_first_name; | |
$customer_last_name = $order->shipping_last_name; | |
$customer_full_name = $customer_first_name.' '.$customer_last_name; | |
$request = str_replace('<CompanyName>-</CompanyName>','<CompanyName>'.$customer_full_name.'</CompanyName>',$request); | |
return $request; | |
} |
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_shipping_skip_product','skip_my_products',10,3); | |
function skip_my_products($skip = false, $product, $package){ | |
$shipping_free_classes = array(16); // array of shipping class ids to exclude from cart | |
$shipping_class = $product['data']->get_shipping_class_id(); | |
if(in_array($shipping_class, $shipping_free_classes)){ | |
$skip = true; | |
} |