Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-bundle
Pricing
Price
DiscountCalculator.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Bundle\Pricing\Price
;
8
9
use
Magento\Catalog\Model\Product
;
10
14
class
DiscountCalculator
15
{
23
public
function
calculateDiscount
(
Product
$product
,
$value
=
null
)
24
{
25
if
(
$value
===
null
) {
26
$value
=
$product
->getPriceInfo()->getPrice(
FinalPrice::PRICE_CODE
)->getValue();
27
}
28
29
$discount =
null
;
30
foreach
(
$product
->getPriceInfo()->getPrices() as
$price
) {
31
if
(
$price
instanceof
DiscountProviderInterface
&&
$price
->getDiscountPercent()) {
32
$discount = min(
$price
->getDiscountPercent(), $discount ?:
$price
->getDiscountPercent());
33
}
34
}
35
return
(
null
!== $discount) ? $discount/100 *
$value
:
$value
;
36
}
37
}
Magento\Bundle\Pricing\Price\DiscountCalculator\calculateDiscount
calculateDiscount(Product $product, $value=null)
Definition:
DiscountCalculator.php:23
Magento\Bundle\Pricing\Price\DiscountProviderInterface
Definition:
DiscountProviderInterface.php:14
$price
$price
Definition:
product_alert.php:10
$value
$value
Definition:
gender.phtml:16
Magento\Bundle\Pricing\Price\DiscountCalculator
Definition:
DiscountCalculator.php:14
Magento\Catalog\Model\Product
Definition:
Product.php:42
Magento\Catalog\Model\Product
Definition:
ActionTest.php:6
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
Magento\Catalog\Pricing\Price\FinalPrice\PRICE_CODE
const PRICE_CODE
Definition:
FinalPrice.php:20
Magento\Bundle\Pricing\Price
Definition:
BundleOptionPrice.php:6