Created
July 17, 2023 16:15
-
-
Save bolderelements/a64231daa333c5c354e09209f7e63069 to your computer and use it in GitHub Desktop.
Remove the extra number added to the Table Rate option ID
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
/* | |
* 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