public function loadConvertedPrices()
    {
        $product_sale_element_id  = \intval($this->getRequest()->get('product_sale_element_id', 0));
        $currency_id = \intval($this->getRequest()->get('currency_id', 0));

        $price_with_tax = $price_without_tax = $sale_price_with_tax = $sale_price_without_tax = 0;

        if (null !== $pse = ProductSaleElementsQuery::create()->findPk($product_sale_element_id)) {
            if ($currency_id > 0
                &&
                $currency_id != Currency::getDefaultCurrency()->getId()
                &&
                null !== $currency = CurrencyQuery::create()->findPk($currency_id)) {
                // Get the default currency price
                $productPrice = ProductPriceQuery::create()
                    ->filterByCurrency(Currency::getDefaultCurrency())
                    ->filterByProductSaleElementsId($product_sale_element_id)
                    ->findOne()
                ;

                // Calculate the converted price
                if (null !== $productPrice) {
                    $price_without_tax = $productPrice->getPrice() * $currency->getRate();
                    $sale_price_without_tax = $productPrice->getPromoPrice() * $currency->getRate();
                }
            }

            if (null !== $product = $pse->getProduct()) {
                $price_with_tax = $this->computePrice($price_without_tax, 'with_tax', $product);
                $sale_price_with_tax = $this->computePrice($sale_price_without_tax, 'with_tax', $product);
            }
        }

        return new JsonResponse(array(
            'price_with_tax'         => $this->formatPrice($price_with_tax),
            'price_without_tax'      => $this->formatPrice($price_without_tax),
            'sale_price_with_tax'    => $this->formatPrice($sale_price_with_tax),
            'sale_price_without_tax' => $this->formatPrice($sale_price_without_tax)
        ));
    }
public function loadConvertedPrices()
    {
        $product_sale_element_id  = \intval($this->getRequest()->get('product_sale_element_id', 0));
        $currency_id = \intval($this->getRequest()->get('currency_id', 0));

        $price_with_tax = $price_without_tax = $sale_price_with_tax = $sale_price_without_tax = 0;

        if (null !== $pse = ProductSaleElementsQuery::create()->findPk($product_sale_element_id)) {
            if ($currency_id > 0
                &&
                $currency_id != Currency::getDefaultCurrency()->getId()
                &&
                null !== $currency = CurrencyQuery::create()->findPk($currency_id)) {
                // Get the default currency price
                $productPrice = ProductPriceQuery::create()
                    ->filterByCurrency(Currency::getDefaultCurrency())
                    ->filterByProductSaleElementsId($product_sale_element_id)
                    ->findOne()
                ;

                // Calculate the converted price
                if (null !== $productPrice) {
                    $price_without_tax = $productPrice->getPrice() * $currency->getRate();
                    $sale_price_without_tax = $productPrice->getPromoPrice() * $currency->getRate();
                }
            }

            if (null !== $product = $pse->getProduct()) {
                $price_with_tax = $this->computePrice($price_without_tax, 'with_tax', $product);
                $sale_price_with_tax = $this->computePrice($sale_price_without_tax, 'with_tax', $product);
            }
        }

        return new JsonResponse(array(
            'price_with_tax'         => $this->formatPrice($price_with_tax),
            'price_without_tax'      => $this->formatPrice($price_without_tax),
            'sale_price_with_tax'    => $this->formatPrice($sale_price_with_tax),
            'sale_price_without_tax' => $this->formatPrice($sale_price_without_tax)
        ));
    }
public function loadConvertedPrices ( ) { $ product_sale_element_id = \ intval ( $ this -> getRequest ( ) -> get ( 'product_sale_element_id' , 0 ) ) ; $ currency_id = \ intval ( $ this -> getRequest ( ) -> get ( 'currency_id' , 0 ) ) ; $ price_with_tax = $ price_without_tax = $ sale_price_with_tax = $ sale_price_without_tax = 0 ; if ( null !== $ pse = ProductSaleElementsQuery :: create ( ) -> findPk ( $ product_sale_element_id ) ) { if ( $ currency_id > 0 && $ currency_id != Currency :: getDefaultCurrency ( ) -> getId ( ) && null !== $ currency = CurrencyQuery :: create ( ) -> findPk ( $ currency_id ) ) { // Get the default currency price $ productPrice = ProductPriceQuery :: create ( ) -> filterByCurrency ( Currency :: getDefaultCurrency ( ) ) -> filterByProductSaleElementsId ( $ product_sale_element_id ) -> findOne ( ) ; // Calculate the converted price if ( null !== $ productPrice ) { $ price_without_tax = $ productPrice -> getPrice ( ) * $ currency -> getRate ( ) ; $ sale_price_without_tax = $ productPrice -> getPromoPrice ( ) * $ currency -> getRate ( ) ; } } if ( null !== $ product = $ pse -> getProduct ( ) ) { $ price_with_tax = $ this -> computePrice ( $ price_without_tax , 'with_tax' , $ product ) ; $ sale_price_with_tax = $ this -> computePrice ( $ sale_price_without_tax , 'with_tax' , $ product ) ; } } return new JsonResponse ( array ( 'price_with_tax' => $ this -> formatPrice ( $ price_with_tax ) , 'price_without_tax' => $ this -> formatPrice ( $ price_without_tax ) , 'sale_price_with_tax' => $ this -> formatPrice ( $ sale_price_with_tax ) , 'sale_price_without_tax' => $ this -> formatPrice ( $ sale_price_without_tax ) ) ) ; }
Calculate all prices

@return \Symfony\Component\HttpFoundation\JsonResponse
Calculate all prices