- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020
05:25 AM
05-27-2020
05:25 AM
How to get Final price of the product in custom script ?
Hello Magedevs,
How can I get final price of any product which is displaying in product page I mean it should contain following things ?
1. Special Price
2. Catalog Rule
3. Currency conversion
Waiting.......
Thank you
Hiren Patel
5 REPLIES 5
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020
05:51 AM
05-27-2020
05:51 AM
Re: How to get Final price of the product in custom script ?
Hello @Hiren_K_Patel
You can get Regular price and Final price of all types of product using below way.
1. Simple Product
$regularPrice = $product->getPriceInfo()->getPrice('regular_price')->getValue(); $specialPrice = $product->getPriceInfo()->getPrice('special_price')->getValue();
2. Configurable product
if ($product->getTypeId() == 'configurable') { $basePrice = $product->getPriceInfo()->getPrice('regular_price'); $regularPrice = $basePrice->getMinRegularAmount()->getValue(); $specialPrice = $product->getFinalPrice(); }
Problem solved? Click Accept as Solution!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020
11:44 PM
05-27-2020
11:44 PM
Re: How to get Final price of the product in custom script ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2020
12:01 AM
05-28-2020
12:01 AM
Re: How to get Final price of the product in custom script ?
Hello @Hiren_K_Patel
For getting all rules applied in your cart you can use the below code:
Class <your classname> { protected $_item; public function __construct( ... \Magento\Quote\Model\Quote\Item $item ... ) { ... $this->_item = $item; ... } public function GetAppliedRulesDetails() { $appliedIds = $this->_item->getAppliedRuleIds(); /* here you need to load the results ids and get required details */ } }
Problem solved? Click Accept as Solution!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2020
12:03 AM
05-28-2020
12:03 AM
Re: How to get Final price of the product in custom script ?
Thank you @Bhanu Periwal
but, this is for cart rule and it retrieve data of cart item.
I need same price which display in product page.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023
08:39 PM
08-28-2023
08:39 PM
Re: How to get Final price of the product in custom script ?
Which files can I put these scripts on?