本文整理汇总了PHP中ShopFunctions::convertDimensionUnit方法的典型用法代码示例。如果您正苦于以下问题:PHP ShopFunctions::convertDimensionUnit方法的具体用法?PHP ShopFunctions::convertDimensionUnit怎么用?PHP ShopFunctions::convertDimensionUnit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShopFunctions
的用法示例。
在下文中一共展示了ShopFunctions::convertDimensionUnit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getPreco_site_correios
function _getPreco_site_correios($cart, $method, $cart_prices)
{
//Define medidas e formato da embalagem
//Usei os valores mínimos (16x11x2 Cm) para todas as medidas a seguir:
//Comprimento médio dos pacotes utilizados para envio pelos Correios(Cm)
$this->Order_Length = $method->Comprimento_SN;
//Largura/Diâmetro médio dos pacotes utilizados para envio pelos Correios(Cm)
$this->Order_Width = $method->Larg_Diam_SN;
//Altura média dos pacotes utilizados para envio pelos Correios(Cm)
$this->Order_Height = $method->Altura_SN;
//Tipo de embrulho dos Correios
$this->Order_Formatos = $method->Formatos_SN;
//Taxa de empacotamento e manuseio, e será acrescida aos custos de envio retornados pelos Correios
$this->Order_Handling_Fee = $method->Handling_Fee_SN;
$this->Order_Handling_Fee = floatval(str_replace(",", ".", $this->Order_Handling_Fee));
//Serviço Mão Própria dos Correios
$this->Order_MaoPropria = $method->MaoPropria_SN;
//Aviso de Recebimento dos Correios
$this->Order_Aviso = $method->AvisoReceb_SN ? "S" : "N";
$this->correios_total = 0;
$this->correios_prazo = 0;
if ($method->FreteProduto_SN == 1) {
$product_length = 0;
$product_width = 0;
$product_height = 0;
foreach ($cart->products as $k => $product) {
// converte pra centímetros
if ($product->product_lwh_uom != 'CM') {
$product_length = ShopFunctions::convertDimensionUnit($product->product_length, $product->product_lwh_uom, "CM");
$product_width = ShopFunctions::convertDimensionUnit($product->product_width, $product->product_lwh_uom, "CM");
$product_height = ShopFunctions::convertDimensionUnit($product->product_height, $product->product_lwh_uom, "CM");
} else {
$product_height = $product->product_height;
$product_width = $product->product_width;
$product_length = $product->product_length;
}
if ($product_length < 16) {
$product_length = "16";
}
if ($product_width < 11) {
$product_width = "11";
}
if ($product_height < 2) {
$product_height = "2";
}
$this->Order_Length = round($product_length, 2);
$this->Order_Width = round($product_width, 2);
// $this->Order_Height = round($product_height * $product->quantity,2);
$this->Order_Height = round($product_height, 2);
// converte para kilos
$product_weight = ShopFunctions::convertWeigthUnit($product->product_weight, $product->product_weight_uom, "KG");
// $peso = $product_weight * $product->quantity;
$peso = $product_weight;
//$total_preco = $product->product_price * $product->quantity;
$total_preco = $product->product_price;
// sempre pega o maior prazo
$dados_frete = $this->_parametrosCorreios($total_preco, $method, $peso);
// pra cada produto, faz a soma de cada produto em separado
$dados_frete['valor'] = str_replace(",", ".", $dados_frete['valor']);
$this->correios_total = $dados_frete['valor'] * $product->quantity;
//$this->correios_total = $dados_frete['valor'];
// for ($i=0; $i < $product->quantity; $i++) {
// $this->correios_total += $dados_frete['valor'];
// }
if ($this->correios_prazo < $dados_frete['prazo']) {
$this->correios_prazo = $dados_frete['prazo'];
}
}
} else {
// calcular o volume total do pedido ( um cálculo por pedido )
foreach ($cart->products as $k => $product) {
//Define medidas minimas
// converte pra centímetros
$this->Order_Height = 0;
if (strtoupper($product->product_lwh_uom) != 'CM') {
$product_length = ShopFunctions::convertDimensionUnit($product->product_length, $product->product_lwh_uom, "CM");
$product_width = ShopFunctions::convertDimensionUnit($product->product_width, $product->product_lwh_uom, "CM");
$product_height = ShopFunctions::convertDimensionUnit($product->product_height, $product->product_lwh_uom, "CM");
} else {
$product_height = $product->product_height;
$product_width = $product->product_width;
$product_length = $product->product_length;
}
if ($method->debug) {
vmdebug('<b>Dimension Unit - ' . $product->virtuemart_product_id . '</b>:', $product->product_lwh_uom);
vmdebug('<b>Height - ' . $product->virtuemart_product_id . '</b>:', $product_height);
vmdebug('<b>Width - ' . $product->virtuemart_product_id . '</b>:', $product_width);
vmdebug('<b>Length - ' . $product->virtuemart_product_id . '</b>:', $product_length);
}
if ($method->VolumeProduto_SN == '1') {
$product_height = round($product_height * $product->quantity, 2);
if ($product_height > $this->Order_Height) {
$this->Order_Height += $product_height;
}
if ($product_width > $this->Order_Width) {
$this->Order_Width = $product_width;
}
if ($product_length > $this->Order_Length) {
$this->Order_Length = $product_length;
}
//.........这里部分代码省略.........