0

i want to add custom donate(like tip) module in addition to product price

suppose Product A (price 100) have text box field 1:donate with blank value which user have to enter user can insert any value and product price will be donated value + product price

how can i implement this via observer

i tried using "checkout_cart_product_add_after" observer

code of observer.php

class Mour_Customgroup_Model_Observer
{
    public function modifyPrice(Varien_Event_Observer $obs ){
    // Get the quote item

        $quote = $obs->getEvent()->getQuote();
        $item = $obs->getQuoteItem();
        $product_id=$item->getProductId();
        $_product=Mage::getModel('catalog/product')->load($product_id);
        $newprice=$_product->getPrice()+10;

        Mage::log('My log entry', null, 'mylogfile.log');

        // Set the custom price
        $item->setCustomPrice($newprice);
        $item->setOriginalCustomPrice($newprice);
        // Enable super mode on the product.
        $item->getProduct()->setIsSuperMode(true);

    }
}

but this code adds same amount to add items in cart

my issue are

  1. how to pass value of donate text box to observer
  2. add donated value to product price
  3. donted value should also show in admin order detail

1 Answer 1

0

you can get params value with

Front controller

Mage::app()->getFrontController()->getRequest()->getParams();

I am sure this will get done your work.

3
  • how to 2: add donated value to product price Jan 5, 2015 at 10:56
  • you can print all values in observer and see with above function
    – liyakat
    Jan 5, 2015 at 10:57
  • now i want to add donated value to product in cart like product price 100 donated value 10 =110 in cart via observer product b price 20 ,donated value 30=50 in cart Jan 5, 2015 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.