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', 'wf_ups_convert_charset'); | |
function wf_ups_convert_charset($request){ | |
return iconv("UTF-8", "ISO-8859-1//TRANSLIT", $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
// For Cart Page. | |
add_filter( 'woocommerce_no_shipping_available_html', 'wf_customize_default_message', 10, 1 ); | |
// For Checkout page | |
add_filter( 'woocommerce_cart_no_shipping_available_html', 'wf_customize_default_message', 10, 1 ); | |
function wf_customize_default_message( $default_msg ) { | |
$zip_array = array( | |
'30031', | |
); | |
if ( in_array( WC()->customer->get_shipping_postcode() , $zip_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
add_filter('woocommerce_package_rates', 'wf_hide_shipping_methods_when_free_shipping_is_applicable', 10, 2); | |
function wf_hide_shipping_methods_when_free_shipping_is_applicable($rates, $package) | |
{ | |
foreach($rates as $key => $value) { | |
if (strpos($key , 'free_shipping') !== false) { | |
foreach($rates as $ratekey => $ratevalue) { | |
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_cart_no_shipping_available_html', 'wf_custom_message_for_incomplete_address', 10, 1 ); // Alters message on Cart page | |
add_filter( 'woocommerce_no_shipping_available_html', 'wf_custom_message_for_incomplete_address', 10, 1 ); // Alters message on Checkout page | |
function wf_custom_message_for_incomplete_address( $default ) { | |
$wf_cart_country = WC()->customer->get_shipping_country(); | |
$wf_cart_state = WC()->customer->get_shipping_state(); | |
$wf_cart_postcode = WC()->customer->get_shipping_postcode(); | |
$shipping_msg_array = 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_remove_puerto_rico_country( $country ) { | |
if(array_key_exists('PR', $country)) | |
{ | |
unset($country['PR']); | |
} | |
return $country; | |
} | |
add_filter( 'woocommerce_countries', 'wf_remove_puerto_rico_country', 10, 1 ); | |
function wf_add_puerto_to_us_states( $states ) { |
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
// Altering rate request | |
add_filter('wf_ups_rate_request_data', 'wf_ups_modify_settings_fields',10, 3); | |
function wf_ups_modify_settings_fields($rate_req_data, $package){ | |
$destination_country = $package['destination']['country']; | |
$destination_state = $package['destination']['state']; | |
$alternate_accounts = 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
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 with extra costs. | |
$shipping_class_and_price = array( | |
13 => 10, | |
); | |
$shipping_services = 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
add_filter('woocommerce_package_rates', 'wf_ups_min_rate', 10, 2); | |
function wf_ups_min_rate($available_rates, $package) | |
{ | |
$min_shipping_rate = 10; | |
foreach($available_rates as $rate_key => $rate){ | |
if($rate->method_id == 'wf_shipping_ups' && $rate->cost<$min_shipping_rate){ | |
$available_rates[$rate_key]->cost = $min_shipping_rate; | |
} | |
} |
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_rate', 'wf_rate_adjustment', 10, 1); | |
function wf_rate_adjustment($rate_xml_object){ | |
$states_requires_price_adjustment = array('CA'); //add state code here | |
$service_code_requires_price_adjustment = array('01'=>0.1, '02'=>0.5, '03'=>0.12); //add service code with adjustment value. | |
$shipping_state = WC()->customer->shipping_state; | |
if(!empty($shipping_state) && in_array($shipping_state, $states_requires_price_adjustment) ){ | |
$code = (string)$rate_xml_object->RatedShipment->Service->Code; | |
if( array_key_exists($code, $service_code_requires_price_adjustment) ){ |
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_sort_shipping_methods', 10, 2); | |
function wf_sort_shipping_methods($available_shipping_methods, $package) | |
{ | |
// Arrange shipping methods as per your requirement | |
$sort_order = array( | |
'wf_shipping_ups' => array(), | |
'wf_shipping_usps' => array(), | |
'free_shipping' => array(), | |
'local_pickup' => array(), |