Created
March 27, 2018 23:11
-
-
Save luiseduardobraschi/edfac88779f593c4a6774164d69cf4ed to your computer and use it in GitHub Desktop.
Change Melhor Envio shipping methods labels.
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
<?php | |
function test_methods_array(){ | |
return [ | |
'wpmelhorenvio_Correios_PAC' => 'Encomenda normal', | |
'wpmelhorenvio_Correios_EXPRESSO' => 'Encomenda expressa', | |
'wpmelhorenvio_JadLog_.Com' => 'JadLog Bar', | |
'wpmelhorenvio_JadLog_.Package' => 'JadLog Foo', | |
]; | |
} | |
add_filter('woocommerce_package_rates', function($rates, $package){ | |
$methods_map = test_methods_array(); | |
foreach ($rates as $key => $rate) { | |
if(!in_array($key, array_keys($methods_map))) { | |
continue; | |
} | |
$method_label = $methods_map[$key]; | |
$rate->set_label($method_label); | |
} | |
return $rates; | |
}, 10, 2); |
Author
luiseduardobraschi
commented
Mar 27, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment