Example #1
0
 /**
  * @param Mage_Catalog_Model_Product $product
  * @param                            $nr
  * @param bool $simple
  *
  * @return string
  */
 protected static function _getGroupedPriceListHtml(Mage_Catalog_Model_Product $product, $nr = -1, $simple = false, $startDate = null, $endDate = null)
 {
     $html = '';
     $associatedProducts = $associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
     // child html
     $childHtml = array();
     foreach ($associatedProducts as $childProduct) {
         $childPriceList = self::getPriceList($product, $nr, $startDate, $endDate);
         if (count($childPriceList)) {
             foreach ($childPriceList as $childPrice) {
                 if (!isset($childHtml[$childPrice['period_type']])) {
                     $childHtml[$childPrice['period_type']] = 0;
                 }
                 $childHtml[$childPrice['period_type']] += $childPrice['price'];
             }
         }
     }
     // main html
     foreach ($childHtml as $childType => $childPrice) {
         // headline
         $childPrice = Mage::helper('core')->currency(Mage::helper("tax")->getPrice($product, $childPrice));
         if ($nr == -1 && !$simple) {
             $html .= '<div class="ppr-headline">' . Mage::helper('payperrentals')->__('Pricing:') . '</div>';
         }
         // pricing
         $typeText = ITwebexperts_Payperrentals_Helper_Html::getTextForType(1, $childType);
         $html .= $typeText . ' ' . Mage::helper('payperrentals')->__('Price:') . ' ' . Mage::helper('core')->currency($childPrice) . '&nbsp;&nbsp;<br/>';
     }
     return $html;
 }
Example #2
0
 public function getPrice()
 {
     $product = $this->getProduct();
     return ITwebexperts_Payperrentals_Helper_Html::completeListingAndProductInfoWithExtraButtons($product);
 }
Example #3
0
 /**
  * This function is used to return the configurable product
  * @param $product
  * @param $source
  */
 private function getProduct($product, $source)
 {
     if ($product->isConfigurable()) {
         if (isset($source['super_attribute'])) {
             $attributes = $source['super_attribute'];
             $product = Mage::getModel('catalog/product_type_configurable')->getProductByAttributes($attributes, $product);
             $product = Mage::getModel('catalog/product')->load($product->getId());
         } else {
             ITwebexperts_Payperrentals_Helper_Html::updateReservationError(Mage::helper("payperrentals")->__("You need to select attributes"));
             return $this;
         }
     }
     return $product;
 }
Example #4
0
 /**
  * @param      $productId
  * @param null $storeId
  *
  * @return string
  */
 public function getMinimumMessageText($productId, $storeId = null)
 {
     if ($productId > 0 && ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($productId, 'global_min_period') == 0) {
         $payperrentalsMinNumber = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($productId, 'payperrentals_min_number');
         $payperrentalsMinType = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($productId, 'payperrentals_min_type');
         $textMin = ITwebexperts_Payperrentals_Helper_Html::getTextForType($payperrentalsMinNumber, $payperrentalsMinType);
     } else {
         $textMin = ITwebexperts_Payperrentals_Helper_Html::getTextForType(Mage::getStoreConfig(ITwebexperts_Payperrentals_Helper_Config::XML_PATH_MIN_NUMBER, $storeId), Mage::getStoreConfig(ITwebexperts_Payperrentals_Helper_Config::XML_PATH_MIN_TYPE, $storeId));
     }
     return $textMin;
 }
Example #5
0
 public function updateBookedHtmlForShipping(Varien_Event_Observer &$observer)
 {
     $requestParams = $observer->getEvent()->getRequestParams();
     $bookedHtml = $observer->getEvent()->getBookedHtml();
     $product = $observer->getEvent()->getProduct();
     if (array_key_exists('shipping_method', $requestParams)) {
         if ($requestParams['shipping_method'] != '') {
             $shippingMethodForLoad = $requestParams['shipping_method'];
         } elseif (array_key_exists('shipping_method_select_box', $requestParams) && $requestParams['shipping_method_select_box'] != 'null') {
             $shippingMethodForLoad = $requestParams['shipping_method_select_box'];
         } elseif (array_key_exists('shipping_method_select_box_additional', $requestParams)) {
             $shippingMethodForLoad = $requestParams['shipping_method_select_box_additional'];
         } else {
             $shippingMethodForLoad = '';
         }
         $shippingMethod = Mage::getModel('rshipping/rshipping')->load($shippingMethodForLoad, 'shipping_method');
         $bookedHtml['shippingMinRentalPeriod'] = ITwebexperts_Payperrentals_Helper_Data::getPeriodInSeconds($shippingMethod->getMinRentalPeriod(), $shippingMethod->getMinRentalType());
         $bookedHtml['shippingMinRentalMessage'] = Mage::helper('payperrentals')->__('Minimum rental period is "%s". Please make sure you select at least that number', ITwebexperts_Payperrentals_Helper_Html::getTextForType($shippingMethod->getMinRentalPeriod(), $shippingMethod->getMinRentalType()));
         $upsTransitTime = 0;
         if (stripos($shippingMethod->getShippingMethod(), 'ups') !== false && Mage::getStoreConfig('payperrentals/rshipping_ups/enabled') && $shippingMethod->getUseLiveUpsApi()) {
             $zip = $requestParams['zip_code'];
             $upsTransitTime = Mage::helper('rshipping')->getTimeInTransit($zip, $product, $shippingMethod->getShippingMethod());
         }
         $paddingDays = array();
         /**
          * Day cutoff time. If current time > cutoff time => disable today and start from tomorrow
          * */
         $currentTime = (int) Mage::getModel('core/date')->timestamp(time());
         if ($shippingMethod->getShippingCutoffTime() != '') {
             $shipCutoffTime = strtotime(date('Y-m-d', $currentTime) . ' ' . $shippingMethod->getShippingCutoffTime());
             if ($currentTime > $shipCutoffTime) {
                 //$bookedHtml['disableToday'] = true;
                 $dateFormatted = date('Y-m-d', $currentTime);
                 $paddingDays[] = $dateFormatted;
             }
         }
         if ($shippingMethod->getStartDisabledDays()) {
             $bookedHtml['disabledForStartRange'] = ITwebexperts_Payperrentals_Helper_Data::getWeekdayForJs(explode(',', $shippingMethod->getStartDisabledDays()));
         } else {
             $bookedHtml['disabledForStartRange'] = '';
         }
         if ($shippingMethod->getEndDisabledDays()) {
             $bookedHtml['disabledForEndRange'] = ITwebexperts_Payperrentals_Helper_Data::getWeekdayForJs(explode(',', $shippingMethod->getEndDisabledDays()));
         } else {
             $bookedHtml['disabledForEndRange'] = '';
         }
         if (stripos($shippingMethod->getShippingMethod(), 'ups') !== false && $shippingMethod->getIgnoreTurnoverDay()) {
             $bookedHtml['ignoreTurnoverDay'] = ITwebexperts_Payperrentals_Helper_Data::getWeekdayForJs(explode(',', $shippingMethod->getIgnoreTurnoverDay()));
         }
         $turnoverBeforePeriod = (int) $shippingMethod->getTurnoverBeforePeriod() + $upsTransitTime;
         $turnoverAfterPeriod = (int) $shippingMethod->getTurnoverAfterPeriod();
         $bookedHtml['turnoverTimeBefore'] = $turnoverBeforePeriod;
         $bookedHtml['turnoverTimeAfter'] = $turnoverAfterPeriod;
         if ($turnoverBeforePeriod > 0) {
             $startTimePadding = Mage::getSingleton('core/date')->timestamp(time());
             while ($turnoverBeforePeriod > 0) {
                 $dateFormatted = date('Y-m-d', $startTimePadding) . ' 00:00';
                 if (!in_array($dateFormatted, $paddingDays)) {
                     $paddingDays[] = $dateFormatted;
                 }
                 $startTimePadding = strtotime('+1 day', $startTimePadding);
                 $turnoverBeforePeriod--;
             }
         }
         if (count($paddingDays) > 0) {
             $bookedHtml['disabledDatesPadding'] = ITwebexperts_Payperrentals_Helper_Data::toFormattedDateArray($paddingDays, false);
         }
         $observer->getEvent()->setBookedHtml($bookedHtml);
     }
 }