private function _getPrice( MShop_Order_Item_Base_Product_Interface $orderProduct, array $refPrices, array $attributes, $pos )
	{
		$context = $this->_getContext();

		// fetch prices of selection/parent products
		if( empty( $refPrices ) )
		{
			$productManager = MShop_Factory::createManager( $context, 'product' );
			$product = $productManager->getItem( $orderProduct->getProductId(), array( 'price' ) );
			$refPrices = $product->getRefItems( 'price', 'default', 'default' );
		}

		if( empty( $refPrices ) )
		{
			$pid = $orderProduct->getProductId();
			$pcode = $orderProduct->getProductCode();
			$codes = array( 'product' => array( $pos => 'product.price' ) );
			$msg = sprintf( 'No price for product ID "%1$s" or product code "%2$s" available', $pid, $pcode );

			throw new MShop_Plugin_Provider_Exception( $msg, -1, null, $codes );
		}

		$priceManager = MShop_Factory::createManager( $context, 'price' );
		$price = $priceManager->getLowestPrice( $refPrices, $orderProduct->getQuantity() );

		// add prices of product attributes to compute the end price for comparison
		foreach( $orderProduct->getAttributes() as $orderAttribute )
		{
			$attrPrices = array();
			$attrId = $orderAttribute->getAttributeId();

			if( isset( $attributes[$attrId] ) ) {
				$attrPrices = $attributes[$attrId]->getRefItems( 'price', 'default', 'default' );
			}

			if( !empty( $attrPrices ) ) {
				$price->addItem( $priceManager->getLowestPrice( $attrPrices, $orderProduct->getQuantity() ) );
			}
		}

		return $price;
	}
private function _getPrice( MShop_Order_Item_Base_Product_Interface $orderProduct, array $refPrices, array $attributes, $pos )
	{
		$context = $this->_getContext();

		// fetch prices of selection/parent products
		if( empty( $refPrices ) )
		{
			$productManager = MShop_Factory::createManager( $context, 'product' );
			$product = $productManager->getItem( $orderProduct->getProductId(), array( 'price' ) );
			$refPrices = $product->getRefItems( 'price', 'default', 'default' );
		}

		if( empty( $refPrices ) )
		{
			$pid = $orderProduct->getProductId();
			$pcode = $orderProduct->getProductCode();
			$codes = array( 'product' => array( $pos => 'product.price' ) );
			$msg = sprintf( 'No price for product ID "%1$s" or product code "%2$s" available', $pid, $pcode );

			throw new MShop_Plugin_Provider_Exception( $msg, -1, null, $codes );
		}

		$priceManager = MShop_Factory::createManager( $context, 'price' );
		$price = $priceManager->getLowestPrice( $refPrices, $orderProduct->getQuantity() );

		// add prices of product attributes to compute the end price for comparison
		foreach( $orderProduct->getAttributes() as $orderAttribute )
		{
			$attrPrices = array();
			$attrId = $orderAttribute->getAttributeId();

			if( isset( $attributes[$attrId] ) ) {
				$attrPrices = $attributes[$attrId]->getRefItems( 'price', 'default', 'default' );
			}

			if( !empty( $attrPrices ) ) {
				$price->addItem( $priceManager->getLowestPrice( $attrPrices, $orderProduct->getQuantity() ) );
			}
		}

		return $price;
	}
private function _getPrice ( MShop_Order_Item_Base_Product_Interface $ orderProduct , array $ refPrices , array $ attributes , $ pos ) { $ context = $ this -> _getContext ( ) ; // fetch prices of selection/parent products if ( empty ( $ refPrices ) ) { $ productManager = MShop_Factory :: createManager ( $ context , 'product' ) ; $ product = $ productManager -> getItem ( $ orderProduct -> getProductId ( ) , array ( 'price' ) ) ; $ refPrices = $ product -> getRefItems ( 'price' , 'default' , 'default' ) ; } if ( empty ( $ refPrices ) ) { $ pid = $ orderProduct -> getProductId ( ) ; $ pcode = $ orderProduct -> getProductCode ( ) ; $ codes = array ( 'product' => array ( $ pos => 'product.price' ) ) ; $ msg = sprintf ( 'No price for product ID "%1$s" or product code "%2$s" available' , $ pid , $ pcode ) ; throw new MShop_Plugin_Provider_Exception ( $ msg , - 1 , null , $ codes ) ; } $ priceManager = MShop_Factory :: createManager ( $ context , 'price' ) ; $ price = $ priceManager -> getLowestPrice ( $ refPrices , $ orderProduct -> getQuantity ( ) ) ; // add prices of product attributes to compute the end price for comparison foreach ( $ orderProduct -> getAttributes ( ) as $ orderAttribute ) { $ attrPrices = array ( ) ; $ attrId = $ orderAttribute -> getAttributeId ( ) ; if ( isset ( $ attributes [ $ attrId ] ) ) { $ attrPrices = $ attributes [ $ attrId ] -> getRefItems ( 'price' , 'default' , 'default' ) ; } if ( ! empty ( $ attrPrices ) ) { $ price -> addItem ( $ priceManager -> getLowestPrice ( $ attrPrices , $ orderProduct -> getQuantity ( ) ) ) ; } } return $ price ; }
Returns the actual price for the given order product.

@param MShop_Order_Item_Base_Product_Interface $orderProduct Ordered product
@param array $refPrices Prices associated to the original product
@param MShop_Attribute_Item_Interface[] $attributes Attribute items with prices
@param integer $pos Position of the product in the basket
@return MShop_Price_Item_Interface Price item including the calculated price
Returns the actual price for the given order product .