Obtain value from an application by trade mark or company

Asked

Viewed 42 times

0

I am in the development of a module to receive commissions from companies that will sell in my store Mangento. This is already working, however, I need to add a new function that I’m not getting.

I need to add an extra amount to the commission in case any company’s request is greater than "X" I did it in a way that didn’t work out:

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
                                                );
    }

This way, only if the product goes from $150.00 the value is added and if you have 2 products of the same brand costing $100.00, the value is not added. I am needing the amount to be added if the entire order of the brand exceeds $150.00.

The logic I’m trying to follow is this::

  • pick up total order amount;

  • filter by brand, ie total value of the application by brand;

  • if the product is of a brand that exceeded the value "x" and she has not yet received the additional value, add freight.

  • Try to take a look at if the problem is not the foreach that is not closed.

  • The foreach was not closed.

  • Hi, thanks for the suggestion. Actually I ended up not putting the end of the code where it shows the lock: $commissions[] = array ( 'Reason' => 'Product'.$item->getName().' id '.$item->getProductId().' x '.$item->getQtyToInvoice().' sku: '. $item->getSku(), 'Login' => $product->getAttributeText(login), 'Fixed value' => $commission & #Xa; ); }

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.