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
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; | |
} |
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
add_filter( 'woocommerce_package_rates', 'show_shipping_method_on_order_weight', 10, 2 ); | |
function show_shipping_method_on_order_weight( $available_shipping_methods, $package ) { | |
$order_weight = 0; | |
foreach( WC()->cart->cart_contents as $key => $values ) { | |
$product_weight = woocommerce_get_weight($values[ 'data' ]->get_weight(),'lbs'); | |
$quantity = $values['quantity']; | |
if($product_weight && $quantity){ |
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
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 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
add_filter('woocommerce_package_rates', 'wf_hide_shipping_methods_based_on_zipcode', 10, 2); | |
function wf_hide_shipping_methods_based_on_zipcode($available_shipping_methods, $package){ | |
$destination = $package['destination']; | |
$postcode = $destination['postcode']; | |
// Array of zipcodes with shipping methods to hide | |
$hide_methods = array( | |
'90002' => array( | |
'free_shipping', |
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
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 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
function wf_dhl_add_customer_reference($shipment_details, $order_id) { | |
//Add customer reference to the shipment request | |
$shipment_details['customerReference'] = 'Order Number : '.$order_id; | |
return $shipment_details; | |
} | |
add_filter('woocommerce_dhl_paket_request', 'wf_dhl_add_customer_reference', 10, 2); |
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
add_filter( 'woocommerce_package_rates', 'adjustment_in_rates_of_product_with_shipping_class', 10, 2 ); | |
function adjustment_in_rates_of_product_with_shipping_class( $available_shipping_methods, $package ) { | |
// Shipping class IDs that need to add extra cost | |
$shipping_class_ids = array( | |
0, | |
1, | |
); | |
// Give here extra cost you want add |
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
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 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
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 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 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 |