Question

I have integrated an extension which rewards some Credit Points to the customer when they return any product. These points are only assigned from backend.

Now, the customer can use this Credit Points during any purchase. But in case if the Order Grand Total exceeds the Credit Limit, then the customer is forced to choose some other mode of payment.

But instead, I want to convert these Credit Points into Discount Coupon and allow the customer to place the order. How can I implement this??

Any help will be appreciated. I am using the following extension: http://www.magentocommerce.com/magento-connect/credit-point-payment-4321.html

Was it helpful?

Solution

I think you are creating your module and you have to give discount as a coupons code.

find in your module NameSpace/ModuleName/Model/Quote/Address/Total/Discount.php File or you can find this file in Mage/core Folder.Find the below method in that.

public function collect(Mage_Sales_Model_Quote_Address $address)
{
     parent :: collect($address);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
        return $this;
     }
     $quote= $address->getQuote();

     //amount definition
     /*
     You have to give discount as a coupons so you have to create one method in your 
     data.php file and called as below.in that file you have to create the logic for 
     the coupen and assign hear it will add to your Total. 
     */
     $discountAmount =  Mage::helper('creditpoints')->calculateDiscount();

     //amount definition
     $discountAmount = $quote -> getStore() -> roundPrice($discountAmount);
     $this -> _setAmount($discountAmount) -> _setBaseAmount($discountAmount);
     $address->setData('discount_total',$discountAmount);

     return $this;
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top