Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
Fire a js alert out of a model
 
holzi747
Jr. Member
 
Total Posts:  13
Joined:  2009-07-16
 

Hello,

I have created an observer (a model) which changes the prices during checkout in some special cases. Therefore I also have to tell this the customer somehow.
I think a javascript alert should be the easiest solution for this. But I could not find out how to create a js alert out of a model.

Does someone know how that could work?

Thanks!
holzi

 
Magento Community Magento Community
Magento Community
Magento Community
 
srinigenie
Guru
 
Avatar
Total Posts:  539
Joined:  2008-02-04
 

The main purpose of model classes in an MVC architecture is to handle logic and not worry about user interaction/interface. Given that, your scenario would be best handled by setting some messages in your Observer model and displaying these messages on your UI at the top.

 
Magento Community Magento Community
Magento Community
Magento Community
 
EcomDev
Sr. Member
 
Avatar
Total Posts:  122
Joined:  2010-03-17
Ukraine, Kyiv
 

Hi,
You can use something like this:

$session Mage::getSingleton('checkout/session');
// You can create any type of message, like notice
$session->addNotice(Mage::helper('youcustommodule')->__('Some Text'));
// Warning
$session->addWarning(Mage::helper('youcustommodule')->__('Some Text'));
// Error
$session->addError(Mage::helper('youcustommodule')->__('Some Text'));

It should works on shopping cart and multi-shipping checkout pages (message will be display at the top), but it’s easy to customize for displaying on one-page checkout too.

 Signature 

Articles about Magento and more at http://www.ecomdev.org/

Trainings for developers with any level of experience in Magento

 
Magento Community Magento Community
Magento Community
Magento Community
 
holzi747
Jr. Member
 
Total Posts:  13
Joined:  2009-07-16
 

Thank you! I made it like this now to get the message out of the model!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright 2012 Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
701238 users|909 users currently online|497292 forum posts