php - Select woocommerce chosen shipping method price -


i'm trying select chosen_shipping_method price in woocommerce using code:

$packages = wc()->shipping->get_packages(); foreach ($packages $i => $package) {     $chosen_method = isset(wc()->session->chosen_shipping_methods[$i]) ? wc()->session->chosen_shipping_methods[$i] : ''; } echo $chosen_method; 

the code works, prints id, , cannot figure out how make print out price.

here's package structure:

enter image description here

what code table_rate_shipping_shipping_self_install, need cost selected element, , not id.

i tried change code this:

foreach ($packages $i => $package['rates']) {     $chosen_method = isset(wc()->session->chosen_shipping_methods[$i]) ? wc()->session->chosen_shipping_methods[$i] : ''; } 

but printed out id, same before.

any ideas? sorry i'm bit new php. in advance

did try inside foreach loop?

$rate = $package['rates'][$chosen_method]->cost; 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -