Skip to content

Instantly share code, notes, and snippets.

@bolderelements
Created July 17, 2023 16:15
Show Gist options
  • Save bolderelements/a64231daa333c5c354e09209f7e63069 to your computer and use it in GitHub Desktop.
Save bolderelements/a64231daa333c5c354e09209f7e63069 to your computer and use it in GitHub Desktop.
Remove the extra number added to the Table Rate option ID
/*
* Remove the extra number added to the Table Rate option ID
*
* Requires Table Rate Shipping for WooCommerce 4.2+
*/
add_filter( 'betrs_calculated_table_rate_options', 'betrs_remove_table_id', 10, 1 );
function betrs_remove_table_id( $rates ) {
// look through all options created
if( is_array( $rates ) && count( $rates ) > 0 ) {
foreach( $rates as $key => $rate ) {
$rates[ $key ]['id'] = substr( $rate['id'], 0, strpos( $rate['id'], "-" ) );
}
}
return $rates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment