1

I am using a module to process product returns, but unfortunatly the comment field is not required. I would like to add the check that people have to fill out WHY they return the product.

As far as I can find it should be in this bit of code:

        if ($p_qty == true) {

        $rma->save();

        //set sub products information
        foreach ($rmaProducts as $rmaProduct) {
            $id = $rmaProduct->getitem_id();

            //check
            if (isset($data['rp_qty_' . $id])) {
                $qty          = $data['rp_qty_' . $id];
                $description  = $data['rp_description_' . $id];
                $reason       = $data['rp_reason_' . $id];
                $request_type = $data['rp_request_type_' . $id];
                $rma->updateSubProductInformation($rmaProduct, $qty, $description, $reason, null, $request_type);
            }

        }

        //notify admin
        $rma->NotifyCreationToAdmin();

        //confirm & redirect
        Mage::getSingleton('customer/session')->addSuccess($this->__('Product Return successfully sent.'));
        $this->_redirect('ProductReturn/Front/View', array('rma_id' => $rma->getId()));
    } else {

        Mage::getSingleton('customer/session')->addError($this->__('Please select quantities to return.'));
        $this->_redirect('ProductReturn/Front/NewRequest', array('order_id' => $data['rma_order_id']));
    }

Is there a easy way to edit this and make the rp_reason mandatory?

1

Well you simply add the following before your code that creates the entries:

if (!Zend_Validate::is($data['rp_reason_'.$id], 'NotEmpty')) {
    Mage::throwException($this->__('Please provide a reason.'));
}

Please note that you will have to add the following try/catch block around your code:

try {
    // Your code here
}
catch (Mage_Core_Exception $e) {
    Mage::getSingleton('core/session')->addException($e);
    $this->_redirectReferer();
}
| improve this answer | |
  • there is a closeing ] missing, but this did put me in the right direction – Jacco Sep 12 '16 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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