public function priceCalculator()
    {
        $return_price = 0;

        $price      = \floatval($this->getRequest()->query->get('price', 0));
        $product_id = \intval($this->getRequest()->query->get('product_id', 0));
        $action     = $this->getRequest()->query->get('action', ''); // With ot without tax
        $convert    = \intval($this->getRequest()->query->get('convert_from_default_currency', 0));

        if (null !== $product = ProductQuery::create()->findPk($product_id)) {
            if ($action == 'to_tax') {
                $return_price = $this->computePrice($price, 'without_tax', $product);
            } elseif ($action == 'from_tax') {
                $return_price = $this->computePrice($price, 'with_tax', $product);
            } else {
                $return_price = $price;
            }

            if ($convert != 0) {
                $return_price = $price * Currency::getDefaultCurrency()->getRate();
            }
        }

        return new JsonResponse(array('result' => $this->formatPrice($return_price)));
    }
public function priceCalculator()
    {
        $return_price = 0;

        $price      = \floatval($this->getRequest()->query->get('price', 0));
        $product_id = \intval($this->getRequest()->query->get('product_id', 0));
        $action     = $this->getRequest()->query->get('action', ''); // With ot without tax
        $convert    = \intval($this->getRequest()->query->get('convert_from_default_currency', 0));

        if (null !== $product = ProductQuery::create()->findPk($product_id)) {
            if ($action == 'to_tax') {
                $return_price = $this->computePrice($price, 'without_tax', $product);
            } elseif ($action == 'from_tax') {
                $return_price = $this->computePrice($price, 'with_tax', $product);
            } else {
                $return_price = $price;
            }

            if ($convert != 0) {
                $return_price = $price * Currency::getDefaultCurrency()->getRate();
            }
        }

        return new JsonResponse(array('result' => $this->formatPrice($return_price)));
    }
public function priceCalculator ( ) { $ return_price = 0 ; $ price = \ floatval ( $ this -> getRequest ( ) -> query -> get ( 'price' , 0 ) ) ; $ product_id = \ intval ( $ this -> getRequest ( ) -> query -> get ( 'product_id' , 0 ) ) ; $ action = $ this -> getRequest ( ) -> query -> get ( 'action' , '' ) ; // With ot without tax $ convert = \ intval ( $ this -> getRequest ( ) -> query -> get ( 'convert_from_default_currency' , 0 ) ) ; if ( null !== $ product = ProductQuery :: create ( ) -> findPk ( $ product_id ) ) { if ( $ action == 'to_tax' ) { $ return_price = $ this -> computePrice ( $ price , 'without_tax' , $ product ) ; } elseif ( $ action == 'from_tax' ) { $ return_price = $ this -> computePrice ( $ price , 'with_tax' , $ product ) ; } else { $ return_price = $ price ; } if ( $ convert != 0 ) { $ return_price = $ price * Currency :: getDefaultCurrency ( ) -> getRate ( ) ; } } return new JsonResponse ( array ( 'result' => $ this -> formatPrice ( $ return_price ) ) ) ; }
Invoked through Ajax; this method calculates the taxed price from the untaxed price, and vice versa.
@since version 2.2
Invoked through Ajax ; this method calculates the taxed price from the untaxed price and vice versa .