Skip to content

Instantly share code, notes, and snippets.

@PogHallam
Created April 4, 2019 15:27
Show Gist options
  • Save PogHallam/f5f049b5bbdb3cdf9e5b2cf67957ef93 to your computer and use it in GitHub Desktop.
Save PogHallam/f5f049b5bbdb3cdf9e5b2cf67957ef93 to your computer and use it in GitHub Desktop.
Get the label/id of current payment methods. Use this to avoid issues with differing IDs on local/staging/production. e.g. 'flat_rate:9', 'table_rate:5:5', etc.
$packages = WC()->shipping->get_packages();
foreach ( $packages[0]['rates'] as $key => $shipping_rate ) {
dump( [ $shipping_rate->get_id(), $shipping_rate->get_label() ] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment