Last active
September 12, 2018 16:47
-
-
Save varun-pluginhive/0fff2c5a078192748aff1627756b862d to your computer and use it in GitHub Desktop.
Snippet to hide all ups rates apart from access point economy. If Access point has been selected. WOOCOMMERCE UPS SHIPPING PLUGIN WITH PRINT LABEL - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
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 to hide all ups rates apart from access point economy. If Access point has been selected. | |
* Created at : 12 Sep 2018 | |
* Updated at : 12 Sep 2018 | |
* PluginHive Plugins : https://www.pluginhive.com/ | |
* Gist Link : https://gist.github.com/varun-pluginhive/0fff2c5a078192748aff1627756b862d | |
*/ | |
if( ! function_exists('ph_hide_ups_rates_apart_from_access_point_economy') ) { | |
function ph_hide_ups_rates_apart_from_access_point_economy( $rates ) { | |
$access_point = WC()->session->get('ph_ups_selected_access_point_details'); | |
if( ! empty($access_point) ) { | |
foreach( $rates as $key => $rate) { | |
$method_id = $rate->get_method_id(); | |
if( $method_id == 'wf_shipping_ups') { | |
$shipping_id = $rate->get_id(); | |
if( $shipping_id != 'wf_shipping_ups:70') unset($rates[$key]); | |
} | |
} | |
} | |
return $rates; | |
} | |
add_filter( 'woocommerce_package_rates', 'ph_hide_ups_rates_apart_from_access_point_economy'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment