public function getPrice($product, $qty = null) { $isBuyout = false; if ($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION)) { $from_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION)->getValue(); } if ($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION)) { $to_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION)->getValue(); } if ($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::BUYOUT_PRICE_OPTION)) { $isBuyout = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::BUYOUT_PRICE_OPTION)->getValue(); } $price = 0; if (is_null($qty) || $qty <= 0) { $qty = 1; } $customerGroup = $this->_getCustomerGroupId($product); if (isset($from_date) && isset($to_date)) { $price = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($product, $from_date, $to_date, $qty, $customerGroup); $product->setData('final_price', $price); } if ($isBuyout) { $priceTemp = ITwebexperts_Payperrentals_Helper_Price::getBuyoutPrice($product); $product->setData('final_price', $priceTemp); $price = $priceTemp; } return $price; }
/** * function used to show the price near the bundle options. * @param $item * @param $order * * @return string */ public function getBundleOptionPriceAsHtml($item, $order) { $result = ''; if ($item->getParentItem()) { $isReservation = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($item->getParentItem()->getProductId(), 'is_reservation'); $bundlePriceType = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($item->getParentItem()->getProductId(), 'bundle_pricingtype'); if ($isReservation) { if (!$bundlePriceType || $bundlePriceType == ITwebexperts_Payperrentals_Model_Product_Bundlepricingtype::PRICING_BUNDLE_PERPRODUCT) { if ($item instanceof Mage_Sales_Model_Order_Item) { $options = $item->getProductOptions(); } else { $options = $item->getOrderItem()->getProductOptions(); } if (isset($options['info_buyRequest']['start_date'])) { $selectionPrice = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($item->getProductId(), $options['info_buyRequest']['start_date'], $options['info_buyRequest']['end_date'], $options['info_buyRequest']['qty'], ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup()); $formattedPrice = $order->formatPrice($selectionPrice); } else { $formattedPrice = ITwebexperts_Payperrentals_Helper_Price::getPriceListHtml($item->getProductId(), -1, true); } } else { $formattedPrice = ''; } $result = " " . $formattedPrice; } } return $result; }
/** * Check price calculations * * @param string $expectation * @param int $product_id * @param datetime $start_date * @param datetime $end_date * @param int $qty * @param int $customerGroup * @test * @loadFixture * @loadExpectation * @dataProvider dataProvider */ public function priceCalculations($expectation, $product_id, $start_date, $end_date, $qty, $customerGroup) { //$customerSessionMock = $this->getModelMock('customer/session', array('renewSession')); // $this->replaceByMock('singleton', 'customer/session', $customerSessionMock); $product = Mage::getModel('catalog/product')->load($product_id); $iPriceCalculated = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($product, $start_date, $end_date, $qty, $customerGroup); $iExpectedPrice = $this->expected($expectation)->getPrice(); //$this->_getExpectations()->getData($testNr . '/price') $this->assertEquals($iExpectedPrice, $iPriceCalculated); }
public function getPrice($product, $qty = null) { if (ITwebexperts_Payperrentals_Helper_Data::isReservationAndRental($product)) { $selectedAttributes = array(); $isBuyout = false; $configurableParent = null; if ($product->getCustomOption('attributes')) { $selectedAttributes = unserialize($product->getCustomOption('attributes')->getValue()); } if ($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION)) { $from_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION)->getValue(); } if ($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION)) { $to_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION)->getValue(); } if ($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::BUYOUT_PRICE_OPTION)) { $isBuyout = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::BUYOUT_PRICE_OPTION)->getValue(); $configurableParent = $product; } if ($product->isConfigurable()) { $product = Mage::getModel('catalog/product_type_configurable')->getProductByAttributes($selectedAttributes, $product); if (is_object($product)) { $product = Mage::getModel('catalog/product')->load($product->getId()); } } $price = 0; if (is_null($qty) || $qty <= 0) { $qty = 1; } if (isset($from_date) && isset($to_date) && is_object($product)) { $customerGroup = $this->_getCustomerGroupId($product); $price = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($product, $from_date, $to_date, $qty, $customerGroup); $product->setData('final_price', $price); } if ($isBuyout) { $priceTemp = ITwebexperts_Payperrentals_Helper_Price::getBuyoutPrice($product, $configurableParent); $product->setData('final_price', $priceTemp); $price = $priceTemp; } return $price; } else { return parent::getPrice($product, $qty); } }
/** * Check price calculations * * @param string $expectation * @param int $product_id * @param datetime $start_date * @param datetime $end_date * @param int $qty * @param int $customerGroup * @param string $bundleArr * @param string $bundleQty * @param string $bundleQty1 * @test * @loadFixture * @loadExpectation * @dataProvider dataProvider */ public function priceBundles($expectation, $product_id, $start_date, $end_date, $qty, $customerGroup, $bundleArr, $bundleQty, $bundleQty1) { $bundleOptions = array(1 => array(1, 90), 2 => array(3, 4)); //normally passed via dataProvider $oBundleType = Mage::getModel('catalog/product')->load($product_id)->getTypeInstance(); $cSelections = $oBundleType->getSelectionsCollection(array_keys($bundleOptions)); $bundleOptionBuyRequest = array(); foreach ($bundleOptions as $optionId => $selection) { $bundleOptionBuyRequest[$optionId] = $cSelections->getItemByColumnValue('product_id', $selection)->getSelectionId(); } $Product = Mage::getModel('catalog/product')->load($product_id); if ($Product->getBundlePricingtype() == ITwebexperts_Payperrentals_Model_Product_Bundlepricingtype::PRICING_BUNDLE_FORALL) { $iPriceCalculated = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($Product, $start_date, $end_date, $qty, $customerGroup); $iExpectedPrice = $this->expected($expectation)->getPrice(); $this->assertEquals($iExpectedPrice, $iPriceCalculated); } else { eval('$bundle_option = ' . $bundleArr . ';'); eval('$bundle_option_qty = ' . $bundleQty . ';'); eval('$bundle_option_qty1 = ' . $bundleQty1 . ';'); $iPriceCalculated = ITwebexperts_Payperrentals_Helper_Price::getBundlePricing($Product, $bundle_option, $bundle_option_qty, $bundle_option_qty1, $qty, $start_date, $end_date, $customerGroup); $iExpectedPrice = $this->expected($expectation)->getPrice(); $this->assertEquals($iExpectedPrice, $iPriceCalculated); } }
public static function getAdminDamageWaiverHtml($item, $productId) { $html = '<div>'; $startDate = Mage::getSingleton('core/session')->getData('startDateInitial'); $endDate = Mage::getSingleton('core/session')->getData('endDateInitial'); $damageWaiverSelected = false; if (isset($item) && $item != -1 && Mage::app()->getRequest()->getActionName() != 'configureProductToAdd') { $buyRequest = $item->getBuyRequest(); if ($buyRequest->getDamageWaiver() != '' && $buyRequest->getDamageWaiver() == '1') { $damageWaiverSelected = true; } $_showTime = (bool) Mage::getResourceModel('catalog/product')->getAttributeRawValue($item->getProductId(), 'payperrentals_use_times', $item->getStoreId()); if (!Mage::helper('payperrentals/config')->isNonSequentialSelect(Mage::app()->getStore()->getId())) { $startDate = $buyRequest->getStartDate() != '' ? $buyRequest->getStartDate() : ($startDate ? $startDate : false); $endDate = $buyRequest->getEndDate() != '' ? $buyRequest->getEndDate() : ($endDate ? $endDate : false); } else { $startDate = $buyRequest->getStartDate() != '' ? ITwebexperts_Payperrentals_Helper_Date::localiseNonsequentialBuyRequest($buyRequest->getStartDate(), $_showTime) : ($startDate ? $startDate : false); $endDate = $buyRequest->getStartDate() != '' ? ITwebexperts_Payperrentals_Helper_Date::localiseNonsequentialBuyRequest($buyRequest->getStartDate(), $_showTime) : ($startDate ? $startDate : false); } } if ($startDate) { list($startDate, $endDate) = ITwebexperts_Payperrentals_Helper_Date::convertDatepickerToDbFormat($startDate, $endDate); $rentalPrice = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($productId, $startDate, $endDate, 1, ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup()); $damageWaiverPrice = self::getDamageWaiver($productId, $rentalPrice); } else { $damageWaiverPrice = self::getDamageWaiver($productId, 0); } if ($damageWaiverPrice) { $html .= '<input type="radio" name="damage_waiver" class="damage-waiver-input" id="damageWaiverNo" value="0" '; if (!$damageWaiverSelected) { $html .= 'checked="checked"'; } $html .= '/>'; $html .= '<label for="damageWaiverNo">' . Mage::helper('payperrentals')->__(' No') . '</label>'; $html .= '</div>'; $html .= '<div>'; $html .= '<input type="radio" name="damage_waiver" class="damage-waiver-input" id="damageWaiverYes" value="1" '; if ($damageWaiverSelected) { $html .= 'checked="checked"'; } $html .= '/>'; $html .= '<label for="damageWaiverYes">' . Mage::helper('payperrentals')->__(' Yes +%s', Mage::helper('checkout')->formatPrice($damageWaiverPrice > -1 ? $damageWaiverPrice : $item->getData(ITwebexperts_Payperrentals_Helper_Price::DAMAGE_WAIVER_OPTION_PRICE), true, true)) . '</label>'; $html .= '</div>'; } return $html; }
/** * Get bundled selections (slections-products collection) * * Returns array of options objects. * Each option object will contain array of selections objects * * @return array */ public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item) { $options = array(); $product = $item->getProduct(); /** * @var Mage_Bundle_Model_Product_Type */ $typeInstance = $product->getTypeInstance(true); // get bundle options $optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids'); $bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array(); if ($bundleOptionsIds) { /** * @var Mage_Bundle_Model_Mysql4_Option_Collection */ $optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product); // get and add bundle selections collection $selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids'); $selectionsCollection = $typeInstance->getSelectionsByIds(unserialize($selectionsQuoteItemOption->getValue()), $product); $bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true); foreach ($bundleOptions as $bundleOption) { if ($bundleOption->getSelections()) { $option = array('label' => $bundleOption->getTitle(), 'value' => array()); $bundleSelections = $bundleOption->getSelections(); foreach ($bundleSelections as $bundleSelection) { $qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1; if ($qty) { $val = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName()) . ' '; if ($bundleSelection->getTypeId() == 'reservation') { if ($product->getBundlePricingtype() == ITwebexperts_Payperrentals_Model_Product_Bundlepricingtype::PRICING_BUNDLE_PERPRODUCT) { $customerGroup = ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup(); if (!is_object($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION))) { $source = unserialize($product->getCustomOption('info_buyRequest')->getValue()); if (isset($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION])) { $start_date = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION]; $end_date = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION]; } } else { $start_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION)->getValue(); $end_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION)->getValue(); } $data = new Varien_Object(array('start_date' => $start_date, 'end_date' => $end_date)); Mage::dispatchEvent('payperrentals_bundle_option_calculate_price_before', array('data' => $data, 'item' => $item, 'selection' => $bundleSelection)); extract($data->getData(), EXTR_OVERWRITE); $priceAmount = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($bundleSelection, $start_date, $end_date, $qty, $customerGroup); $val .= Mage::helper('core')->currency($priceAmount); } else { } } else { $val .= Mage::helper('core')->currency($this->getSelectionFinalPrice($item, $bundleSelection)); } $option['value'][] = $val; } } if ($option['value']) { $options[] = $option; } } } } return $options; }
public static function completeListingAndProductInfoWithExtraButtons($product) { if (Mage::getSingleton('core/session')->getData('startDateInitial') && !Mage::helper('payperrentals/config')->useListButtons()) { $htmlPrice = ''; if (Mage::helper('payperrentals/config')->keepListingPriceAfterDatesSelection()) { $htmlPrice = ITwebexperts_Payperrentals_Helper_Price::getPriceListHtml($product, Mage::getStoreConfig(ITwebexperts_Payperrentals_Helper_Config::XML_PATH_PRICING_ON_LISTING)); } else { $priceVal = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($product, Mage::getSingleton('core/session')->getData('startDateInitial'), Mage::getSingleton('core/session')->getData('endDateInitial'), 1, ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup()); if (!ITwebexperts_Payperrentals_Helper_Data::isAddToQueue($product) && !ITwebexperts_Payperrentals_Helper_Data::isAddToQueueGrouped($product)) { $htmlPrice = $product->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE ? Mage::helper('payperrentals')->__('Not available') : Mage::helper('payperrentals')->__(''); } if ($priceVal > 0) { $htmlPrice = '<div class="price-box"><span class="price">Price: ' . Mage::helper('core')->currency($priceVal) . '</span></div>'; } $buyoutHtml = ''; $isRentalBuyout = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($product->getId(), 'payperrentals_enable_buyout'); if ($isRentalBuyout) { $buyoutPrice = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($product->getId(), 'payperrentals_buyoutprice'); $buyoutHtml = Mage::helper('payperrentals')->__('Buyout: ') . Mage::helper('core')->currency($buyoutPrice, true, false); } $htmlPrice .= $buyoutHtml; } } else { $htmlPrice = ITwebexperts_Payperrentals_Helper_Price::getPriceListHtml($product, Mage::getStoreConfig(ITwebexperts_Payperrentals_Helper_Config::XML_PATH_PRICING_ON_LISTING)); if ($product->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE) { //use list buttons if (Mage::getSingleton('core/session')->getData('startDateInitial') && !Mage::registry('current_product')) { $selectedArray = Mage::helper('payperrentals/config')->getFixedSelection(); $notAvailable = false; foreach ($selectedArray as $iDay) { $startDate = Mage::getSingleton('core/session')->getData('startDateInitial'); $endDate = date('Y-m-d H:i:s', strtotime('+ ' . $iDay . ' DAY', strtotime($startDate))); $priceVal = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($product, $startDate, $endDate, 1, ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup()); if ($priceVal > 0) { $selectedDayLink = Mage::helper('checkout/cart')->getAddUrl($product, array('_query' => array('options' => array('selected_days' => $iDay), 'selected_days' => $iDay))); $htmlPrice .= '<input type="hidden" class="ppr_attr_sel_days" href="' . $selectedDayLink . '" value="' . Mage::helper('payperrentals')->__('Rent %s days at %s', $iDay, strip_tags(Mage::helper('core')->currency($priceVal))) . '" />'; } else { $notAvailable = true; break; } } if ($notAvailable) { if (!ITwebexperts_Payperrentals_Helper_Data::isAddToQueue($product) && !ITwebexperts_Payperrentals_Helper_Data::isAddToQueueGrouped($product)) { $htmlPrice = $product->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE ? Mage::helper('payperrentals')->__('Not available') : Mage::helper('payperrentals')->__(''); } else { $htmlPrice = ''; } } } } } $configHelper = Mage::helper('payperrentals/config'); $inventoryHelper = Mage::helper('payperrentals/inventory'); if ($configHelper->showAvailabilityOnProductListing()) { if ($product->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE) { $isAvailable = $inventoryHelper->isAvailable($product->getId(), Mage::getSingleton('core/session')->getData('startDateInitial'), Mage::getSingleton('core/session')->getData('endDateInitial'), 1); if ($isAvailable) { $htmlPrice .= ''; //Mage::helper('payperrentals')->__('Available for selected dates'); } else { $htmlPrice .= Mage::helper('payperrentals')->__('Not available for selected dates'); } } } if (ITwebexperts_Payperrentals_Helper_Data::isReservation($product) && ITwebexperts_Payperrentals_Helper_Data::isReservationType($product)) { if (Mage::getSingleton('core/session')->getData('startDateInitial') && Mage::getSingleton('core/session')->getData('endDateInitial')) { $getAddUrl = Mage::helper('checkout/cart')->getAddUrl($product, array('_query' => array('options' => array('start_date' => Mage::getSingleton('core/session')->getData('startDateInitial'), 'end_date' => Mage::getSingleton('core/session')->getData('endDateInitial')), 'start_date' => Mage::getSingleton('core/session')->getData('startDateInitial'), 'end_date' => Mage::getSingleton('core/session')->getData('endDateInitial')))); $htmlPrice .= '<input type="hidden" href="' . $getAddUrl . '" class="ppr_attr_butname_global" value=" ' . Mage::helper('payperrentals')->__('Rent') . ' " />'; } else { if (ITwebexperts_Payperrentals_Helper_Data::isUsingGlobalDates()) { $getAddUrl = Mage::helper('checkout/cart')->getAddUrl($product, array('_query' => array('options' => array('start_date' => '', 'end_date' => ''), 'start_date' => '', 'end_date' => ''))); $htmlPrice .= '<input type="hidden" href="' . $getAddUrl . '" class="ppr_attr_butname_global" value=" ' . Mage::helper('payperrentals')->__('Rent') . ' " />'; } else { $htmlPrice .= '<input type="hidden" class="ppr_attr_butname" value=" ' . Mage::helper('payperrentals')->__('Rent') . ' " />'; } } if (Mage::getStoreConfig(ITwebexperts_Payperrentals_Helper_Config::XML_PATH_ALLOW_LISTING_QTY) && Mage::app()->getRequest()->getRouteName() != 'wishlist') { $htmlPrice .= '<input type="hidden" class="ppr_attr_qty" prid="' . $product->getId() . '" value="' . Mage::helper('payperrentals')->__('Qty: ') . '" />'; } } if (Mage::helper('payperrentals/config')->isBuyout($product)) { $buyoutLink = Mage::helper('checkout/cart')->getAddUrl($product, array('_query' => array('options' => array('buyout' => 'true'), 'buyout' => 'true'))); $htmlPrice .= '<input type="hidden" class="ppr_attr_buyout" href="' . $buyoutLink . '" value="' . Mage::helper('payperrentals')->__('Buy Now') . '" />'; } $rentalLink = Mage::helper('checkout/cart')->getAddUrl($product, array('_query' => array('options' => array('one_option' => 'no_value'), 'is_reservation' => ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_RENTAL))); if (ITwebexperts_Payperrentals_Helper_Data::isAddToQueueGrouped($product)) { $htmlPrice .= '<input type="hidden" class="ppr_attr_queue" href="' . $rentalLink . '" value="' . Mage::helper('payperrentals')->__('Add All To Queue') . '" />'; } elseif (ITwebexperts_Payperrentals_Helper_Data::isAddToQueue($product)) { /** used to disable and gray out add to queue button if not enabled for membership */ $isalloweditem = ''; $disabled_queue_class = ''; if (Mage::getSingleton('customer/session')->isLoggedIn()) { $isalloweditem = Mage::helper('payperrentals/membership')->hasMembership($product->getId()); if ($isalloweditem == false) { $disabled_queue_class = ' notallowed'; } } $htmlPrice .= '<input type="hidden" class="ppr_attr_queue' . $disabled_queue_class . '" href="' . $rentalLink . '" value="' . Mage::helper('payperrentals')->__('Add To Queue') . '" />'; } return $htmlPrice; }
/** * Get product final price * * @param double $qty * @param Mage_Catalog_Model_Product $product * @return double */ public function getFinalPrice($qty = null, $product) { if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) { return $product->getCalculatedFinalPrice(); } $finalPrice = $this->getBasePrice($product, $qty); $product->setFinalPrice($finalPrice); Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty)); $finalPrice = $product->getData('final_price'); $finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice); $isReservation = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($product->getId(), 'is_reservation'); $bundlePriceType = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($product->getId(), 'bundle_pricingtype'); if ($isReservation != ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_DISABLED) { if ($bundlePriceType == ITwebexperts_Payperrentals_Model_Product_Bundlepricingtype::PRICING_BUNDLE_FORALL) { if (is_object($product->getCustomOption('info_buyRequest'))) { $source = unserialize($product->getCustomOption('info_buyRequest')->getValue()); if (isset($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION])) { $startingDate = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION]; $endingDate = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION]; } } if (isset($startingDate) && isset($endingDate)) { $customerGroup = ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup(); $finalPrice = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($product->getId(), $startingDate, $endingDate, $qty, $customerGroup); } } else { $finalPrice = $this->getTotalBundleItemsPrice($product, $qty); } } else { $finalPrice += $this->getTotalBundleItemsPrice($product, $qty); } $product->setFinalPrice($finalPrice); return max(0, $product->getData('final_price')); }