Rental Programming Guide Basics

An Important Note #

Do not “hack” the core or the rental extension module directly. All your code should be in app/code/local/yourcompany/yourmodule. That way if we update the rental system your changes will not be overwritten. This is generally how most programming frameworks work. You don’t directly edit the classes and methods, you extend them.

Are You A New Programmer Or New To Magento? #

Make sure to get familiar with PHP OOP concepts. We recommend the following learning resources:

1. Tutsplus PHP courses

2. Magento programming books from Packt

3. Alan Storm Magento tutorials

4. For design changes please check:

5. Good Magento overview: Magento The Right Way

Commonly Used Classes and Methods #

The most important class is ITwebexperts_Payperrentals_Helper_Data which is found in the helper folder. All the methods are static methods.

How to Display Rental Price Periods For A Product? #

ITwebexperts_Payperrentals_Helper_Data::getPriceList(productId,nr = -1)

it will provide a list of a specified number of pricing per periods. if $nr variable is -1 it will provide all of them, else it will provide the $nr number of pricing per periods.

How to Check Rental Price For Specific Dates? #

ITwebexperts_Payperrentals_Helper_Data::calculatePrice($productId, $startingDate, $endingDate, $qty, $customerGroup)

it will provide the price for a specific period for a specified productId. it needs $qty because that might have different pricing per qty and also $customerGroup because it might have different pricing per group.

How to Check Inventory For Reservation Product? #

ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($product_id, $startingDate, $endingDate)

It will return the number of items available for a productId in a specific interval.

How to Edit Reservation Dates On An Order? #

Mage::getResourceSingleton(‘payperrentals/reservationorders’)->updateStartEndByOrderId($id, $start, $end);
$id must be order increment id

How to Add To Rental Queue? #

// get product and buy request variable

$Product = $item->getProduct();

$buyRequest = $Product->getCustomOption(‘info_buyRequest’)->getValue();

// add to queue

ITwebexperts_Payperrentals_Helper_Data::::addProductToQueue($product, $buyRequest);


How to Check Order Reservation Dates and Order Dropoff & Pickup Dates? #

// $orderId is the id of your order you want to load

$order = Mage::getModel(‘sales/order’)->load($orderId);

$order->getStartDatetime() – reservation start date if the date is the same for all products on order.

$order->getEndDatetime() – reservation end date if the date is the same for all products on order.

$order->getSendDatetime() – dropoff date if the date is the same for all products on order.

$order->getReturnDatetime() – pickup date if the date is the same for all products on order.

How To Mark An Order Shipped and Returned? #

// supposing you want to send order $orderId

$coll = Mage::getModel(‘payperrentals/reservationorders’)




->addSelectFilter(“product_type = ‘”.ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE.”‘”)


foreach ($coll as $resOrder) {

$product = Mage::getModel(‘catalog/product’)->load($resOrder->getProductId());

$sn = array();


$coll1 = Mage::getModel(‘payperrentals/serialnumbers’)




foreach($coll1 as $item){

$sn[] = $item->getSn();                                                                                        }


foreach($sn as $serial){


->updateStatusBySerial($serial, ‘O’);


$serialNumber = implode(‘,’,$sn);

$sendTime = date(‘Y-m-d H:i:s’, Mage::getModel(‘core/date’)->timestamp(time()));

$sendReturn = Mage::getModel(‘payperrentals/sendreturn’)






->setReturnDate(‘0000-00-00 00:00:00’)


//here needs a check this should always be true



Mage::getResourceSingleton(‘payperrentals/reservationorders’)->updateSendReturnById($id, $sendReturn->getId());


// supposing you want to return order $orderId

$coll = Mage::getModel(‘payperrentals/sendreturn’)


->addSelectFilter(“return_date=’0000-00-00 00:00:00′”)


foreach ($coll as $resOrder) {

$sn = explode(‘,’, $resOrder->getSn());

$returnTime = date(‘Y-m-d H:i:s’, Mage::getModel(‘core/date’)->timestamp(time()));

foreach($sn as $serial){


->updateStatusBySerial($serial, ‘A’);



->updateReturndateById($id, $returnTime);


How To Update Turnover Time Before & After? #

There is no way. Turnover time before and after is based on a global variable or per product.

How To Check Reservation Dates Of A Product In The Cart? #

$quoteItems =  Mage::getSingleton(‘checkout/cart’)->getQuote()->getItemsCollection();

foreach($quoteItems as $item)


$Product = $item->getProduct();

$source = unserialize($Product->getCustomOption(‘info_buyRequest’)->getValue());





$start_date = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION];

$end_date = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION];


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!