Basic Rental Module Flow (Version 1.3 and earlier)

// Basic flow
1. Extra templates are added to the product page using the layout xml file app/design/frontend/base/default/layout/payperrentals.xml note the line <block type=”payperrentals/catalog_product_view_rental” name=”” as=”product-rental” template=”payperrentals/catalog/product/view_rental.phtml”> and <block type=”payperrentals/catalog_product_view_price” name=”” as=”product-price” template=”catalog/product/price.phtml”/> this adds the calendar and pricing templates


2. Notice in app/design/frontend/base/default/template/payperrentals/catalog/product/view_rental.phtml the load order. First the php_initialisations.phtml is called. app/design/frontend/base/default/template/payperrentals/calendar/php_initialisations.phtml loads all variables so they are ready for the rental calendar and page like: product id, disabled dates, calendar settings, and time options. These are loaded using our helpers.


Further down in the view_rental.phtml template you will see where it shows the min/max periods, Deposit, and price using ITwebexperts_Payperrentals_Helper_Price::getPriceListHtml($_product);


The calendar itself is loaded with require($templateGlobalCalendar); which is the file app/design/frontend/base/default/template/payperrentals/calendar/global_calendar.phtml within this file you will see the calendar form fields like  <input type=”text” name=”read_start_date”/> and <input type=”text” name=”read_end_date” class=”readEndDate” <?php if ($_autoSelectEndDate) echo ‘readonly=”readonly”‘; ?> />

2B. Disabled dates use AJAX to update the calendar. This is done with the function updateBookedDates in app/design/frontend/base/default/template/payperrentals/calendar/frontend_functions.phtml notice the ajax in this function using this line: url: ‘‘,
data: selfObj.closest(‘form’).find(‘*’).serialize() + ‘&qty=’ + $jppr(‘#qty’).val(),
So here we are referencing app/code/community/ITwebexperts/Payperrentals/controllers/AjaxController.php the ajax controller and passing in an array of product ids and quantities. This ajax controller returns an html array of booked dates using our main function ITwebexperts_Payperrentals_Helper_Data::getBookedQtyForProducts to get booked dates array.

3. The create calendar function and mouse down listener (to show calendar when mouse clicks on start and end field) is in  app/design/frontend/base/default/template/payperrentals/calendar/global_calendar_functions.phtml
 listener for mousedown
$jppr(‘<?php echo $_jsContainerPrefix ?> .readStartDate, <?php echo $_jsContainerPrefix ?> .readEndDate’).mousedown(function (event) {
within that listener, createCalendar<?php echo $_jsFunctionPrefix ?>($jppr(‘<?php echo $_jsContainerPrefix ?> .datePicker’)); is called to attach the date picker.


4. Dates are added to cart using Magento custom options. app/code/community/ITwebexperts/Payperrentals/Helper/Rendercart.php the prepareForCartAdvanced function.


5. After order is placed an observer is called sales_order_place_after (defined in the app/code/community/ITwebexperts/Payperrentals/etc/config.xml file) which calls the observer’s reserveInventory function. This in turn references the helper function which reserves inventory.

30% Off All Licenses!


Code: 30SALE


Please signup with your email and we'll send you the files 

We'll send you a few follow up emails with great Rental Business Tips, Special Offers, ways to increase sales, and more.

No thanks, I'll pass

Get The Latest Rental Business Tips and Updates!

Special Offers, Product Updates, Insider Business Tips, sign up today to the Sales Igniter Email List!