문제

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 ?

도움이 되었습니까?

해결책

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

다른 팁

Solved change this :

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

to this :

$productId = $item->getProductId();
$productPrice = $item->getPrice();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top