I am developing a module to receive commissions from companies that are selling in my magento store. This is already working, however, I need to add a new function that I am not getting.
I need to add an extra amount to the commission, if the request of any company is greater than "X" I did it in a way that did not work:
foreach($order->getAllVisibleItems() as $key => $item){
$product = Mage::getModel('catalog/product')->load($item->getProductId());
$price = $item->getPrice();
$valor_comissao = (int)$product->getAttributeText('comissao_vendedor')/100;
$comissao_valor2 = $price-($price*$valor_comissao);
$qty = $item->getQtyOrdered();
$valor_pedido = ($price*$qty);
if($valor_pedido > 150) {
$comissao_valor = ($comissao_valor2*$qty-17);
} else {
$comissao_valor=($comissao_valor2*$qty-2);
}
$comissoes[] = array (
'Razao' => 'Produto '.$item->getName().' id '.$item->getProductId().' x '.$item->getQtyToInvoice().' sku: '. $item->getSku(),
'Login' => $product->getAttributeText('login'),
'ValorFixo' => $comissao_valor
);
}
In this way, only if the product goes over $ 150.00 that the value is added and if you have 2 products of the same brand costing $ 100.00, the value is not added. I need the value to be added if the entire order for the brand exceeds $ 150.00.
The logic I'm trying to follow is as follows:
get total order value;
Filter by tags, that is, total order value per brand;
If the product is of a mark that has exceeded the value "x" and it has not yet received the additional value, add freight.