Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
@CasperBraske

This comment has been minimized.

Copy link
Owner Author

CasperBraske commented Mar 27, 2018

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.