Jump to content

How to get a product actual price, discount percentage, and price after discount by product id


anuraj_pr

Recommended Posts

hello,

I want a product price,discount percentage/price,price after discount in a controller by product Id,..when i go through several search results it shows only  displayed it on a tpl file.

how to get these values in a controller file..


Thanks in advance..

Edited by anuraj_pr (see edit history)
Link to comment
Share on other sites

This is the way to find discount price percentage by product id:

        require_once('./config/config.inc.php');
        require_once('init.php');

        $context = \Context::getContext();

 

         $product=new Product($params['id_product'], false, $context->language->id);

        $id_customer = (isset($context->customer) ? (int)$context->customer->id : 0);
        $id_group = (isset($tcontext->customer) ? $tcontext->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_);
        $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT');
        $id_currency = (int)$context->cookie->id_currency;
        $id_shop = (int)$context->shop->id;
$quantity_discounts = SpecificPrice::getQuantityDiscounts($product->id, $id_shop, $id_currency, $id_country, $id_group, null, true,$id_customer);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...