Exemplo n.º 1
0
 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="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . Mage::helper('payperrentals')->__('Rent') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />';
         } 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="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . Mage::helper('payperrentals')->__('Rent') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />';
             } else {
                 $htmlPrice .= '<input type="hidden" class="ppr_attr_butname" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . Mage::helper('payperrentals')->__('Rent') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />';
             }
         }
         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;
 }