Domanda

i m developping an extension for custom price and i wanna know how to get the unit price from cart i've tried this :

$itemProduct = $this->getProduct();

        $cart = Mage::getModel('checkout/cart')->getQuote();
        foreach ($cart->getAllItems() as $item) {
            $productId = $item->getProduct()->getProductId();
            $productPrice = $item->getProduct()->getPrice();

            if($productId == $itemProduct->getId()){
                /*
                 * do our check for 'same product' here.
                * Returns true if attribute is the same thus it is hte same product
                */
                if ($productPrice == $itemProduct->getPrice()) {
                    return true; //same product
                } else {
                    return false; //different product
                }

            }

but it returns always false i guess i didn't get the unit price

how to do that ?

È stato utile?

Soluzione

try direct to database like :

if you want to looking for quote unit price check ( table name : sales_flat_quote then column subtotal )

if you are looking for sales uni price take a look under ( table name : sales_flat_order then column subtotal )

this help you to improve your extension speed ( only to get content not add )

Thanks

Altri suggerimenti

Solved change this :

$productId = $item->getProduct()->getProductId();
$productPrice = $item->getProduct()->getPrice();

to this :

$productId = $item->getProductId();
$productPrice = $item->getPrice();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top