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( 'woocommerce_package_rates', 'wf_adjust_shipping_rate', 10, 2 ); | |
function wf_adjust_shipping_rate( $available_shipping_methods, $packages ){ | |
// Total quantity is total unit | |
$unit = 0; | |
$apply_final_filter = TRUE; | |
foreach ( $packages['contents'] as $item ) { | |
$unit+=$item['quantity']; | |
} | |
// if unit less than 3 , show D_FIRST_CLASS only |
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
// Exclude the services First-Class Mail Postcards, First-Class Mail Large Envelope and First-Class Mail Stamped Letter | |
add_filter('usps_disable_first_class_rate_first-class-mail-postcards', 'disable_first_class_rate_for_this_service',10,3); | |
add_filter('usps_disable_first_class_rate_first-class-mail-large-envelope', 'disable_first_class_rate_for_this_service',10,3); | |
add_filter('usps_disable_first_class_rate_first-class-mail-stamped-letter', 'disable_first_class_rate_for_this_service',10,3); | |
function disable_first_class_rate_for_this_service() { | |
return true; | |
} | |
// Include First-Class Mail Parcel ( Default Behaviour) | |
add_filter('usps_disable_first_class_rate_first-class-mail-parcel', 'disable_first_class_rate_for_parcel_service',10,3); |
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','my_call_back', 10, 2 ); | |
function my_call_back($request,$order){ | |
$request['RequestedShipment']['Recipient']['Contact']['PhoneNumber']='123-123-1234'; | |
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('woocommerce_package_rates', 'hide_auspost_method_when_shipping_class_product_is_in_cart', 10, 2); | |
function hide_auspost_method_when_shipping_class_product_is_in_cart($available_shipping_methods, $package) | |
{ | |
$shipping_class_ids = array( | |
16 | |
); | |
$shipping_services_to_hide = array( | |
'wf_australia_post:AUS_PARCEL_REGULAR', | |
'wf_australia_post:AUS_PARCEL_EXPRESS', |
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('woocommerce_package_rates', 'hide_shipping_method_if_particular_product_available_in_cart', 10, 2); | |
function hide_shipping_method_if_particular_product_available_in_cart($available_shipping_methods) | |
{ | |
global $woocommerce; | |
// products_array should be filled with all the products ids | |
// for which shipping method (stamps) to be restricted. | |
$products_array = 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('woocommerce_package_rates', 'wf_remove_shipping_options_for_particular_zip_codes', 10, 2); | |
function wf_remove_shipping_options_for_particular_zip_codes($rates, $package) | |
{ | |
global $woocommerce; | |
$excluded_zip_array = array( | |
'93999' | |
); | |
if (in_array($woocommerce->customer->get_shipping_postcode() , $excluded_zip_array)) { | |
unset($rates['wf_fedex_woocommerce_shipping:FEDEX_GROUND']); |
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('woocommerce_package_rates', 'wf_hide_undesired_service_for_required_states', 10, 2); | |
function wf_hide_undesired_service_for_required_states($rates, $package) | |
{ | |
$exclude = array( | |
'international_delivery' => array( | |
'CA' | |
) , | |
'wf_fedex_woocommerce_shipping:FEDEX_GROUND' => array( | |
'FL' |
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( 'woocommerce_package_rates', 'show_shippingpro_method_when_shipping_class_product_is_in_cart', 10, 2 ); | |
function show_shippingpro_method_when_shipping_class_product_is_in_cart( $available_shipping_methods, $package ) { | |
$shipping_class_ids = array( | |
16); | |
$shipping_services_to_show = array( | |
'wf_woocommerce_shipping_pro:Group1Express', | |
'wf_woocommerce_shipping_pro:group2Standard', | |
); | |
$shipping_services_to_show = array_map('strtolower', $shipping_services_to_show); | |
$shipping_class_exists = false; |
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('woocommerce_package_rates', 'wf_remove_shipping_pro_rate_when_free_shipping_is_applicable', 10, 2); | |
function wf_remove_shipping_pro_rate_when_free_shipping_is_applicable($rates, $package) | |
{ | |
if (isset($rates['free_shipping'])) { | |
foreach($rates as $ratekey => $ratevalue) { | |
if (strpos($ratekey, 'wf_woocommerce_shipping_pro:') !== false) { | |
unset($rates[$ratekey]); | |
} | |
} |
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('woocommerce_package_rates', 'hide_shipping_method_when_shipping_class_product_is_in_cart', 10, 2); | |
function hide_shipping_method_when_shipping_class_product_is_in_cart($available_shipping_methods, $package) | |
{ | |
// Shipping class IDs that need the method removed | |
$shipping_class_ids = array( | |
1111, | |
2232, |
OlderNewer