Skip to content

Instantly share code, notes, and snippets.

@luiseduardobraschi
Created March 27, 2018 23:11
Show Gist options
  • Save luiseduardobraschi/edfac88779f593c4a6774164d69cf4ed to your computer and use it in GitHub Desktop.
Save luiseduardobraschi/edfac88779f593c4a6774164d69cf4ed to your computer and use it in GitHub Desktop.
Change Melhor Envio shipping methods labels.
<?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);
@luiseduardobraschi
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment