Php OSCommerce USPS将重量单位从磅转换为盎司

Php OSCommerce USPS将重量单位从磅转换为盎司,php,oscommerce,shipping,usps,Php,Oscommerce,Shipping,Usps,我在一个OSCommerce网站上工作,对于USPS运输方法,我想将重量单位从磅转换为盎司,但没有办法,有人能帮忙吗 提前感谢考虑到1磅=16盎司,您基本上可以将其乘以16: $pounds = 8; $ounces = $pounds * 16; echo $ounces; // 128 …但是,如果英镑是浮动的,你可能会想将其取整。由于您谈论的是装运重量,您可能希望汇总: $pounds = 8.536; $ounces = ceil($pounds * 16); echo $ounces

我在一个OSCommerce网站上工作,对于USPS运输方法,我想将重量单位从磅转换为盎司,但没有办法,有人能帮忙吗


提前感谢

考虑到1磅=16盎司,您基本上可以将其乘以16:

$pounds = 8;
$ounces = $pounds * 16;
echo $ounces; // 128
…但是,如果英镑是浮动的,你可能会想将其取整。由于您谈论的是装运重量,您可能希望汇总:

$pounds = 8.536;
$ounces = ceil($pounds * 16);
echo $ounces; // 137
您可以将其放入函数中,如下所示:

function pounds_to_ounces ($pounds) {
  return ceil($pounds * 16);
}

echo pounds_to_ounces(8); // 128
echo pounds_to_ounces(8.536); // 137

你有没有试过用谷歌搜索OSCommerce USPS将重量单位从磅转换为盎司?那里似乎有有用的资源是的,我做了很多,但没有发现任何有用的东西…:(看起来这个contrib支持盎司,太棒了,非常感谢…它成功了…但我还有一个问题…现在我如何从USPS设置费率?您需要使用USPS评级API。或者