I've read the other posts about this subject and tried loads of things but cant get a Variable from my controller file to the Checkout. I have very little experience with creating modules so followed a guide to create the following
app ▸ code ▸ local ▸ Creare ▸ AgeRestricted ▸ etc ▸ config.xml
<?xml version="1.0"?>
<config>
<modules>
<Creare_AgeRestricted>
<version>0.1.0</version>
</Creare_AgeRestricted>
</modules>
<global>
<events>
<payment_method_is_active>
<observers>
<age_restricted>
<type>singleton</type>
<class>AgeRestricted/observer</class>
<method>AgeRestricted</method>
</age_restricted>
</observers>
</payment_method_is_active>
</events>
<models>
<AgeRestricted>
<class>Creare_AgeRestricted_Model</class>
<resourceModel>agerestricted_mysql4</resourceModel>
</AgeRestricted>
</models>
<sales>
<quote>
<item>
<product_attributes>
<age_restricted/>
</product_attributes>
</item>
</quote>
</sales>
</global>
</config>
Macintosh HD ▸ WWW-local ▸ dexam ▸ htdocs_live ▸ app ▸ code ▸ local ▸ Creare ▸ AgeRestricted ▸ Model ▸ Observer.php
<?php
class Creare_AgeRestricted_Model_Observer
{
public function AgeRestricted(Varien_Event_Observer $observer)
{
Mage::register('feedback', $AgeRestricted);
$event = $observer->getEvent();
$method = $event->getMethodInstance();
$result = $event->getResult();
$AgeRestricted = false;
foreach (Mage::getSingleton('checkout/cart')->getQuote()->getAllVisibleItems() as $item)
{
if($item->getProduct()->getAgeRestricted()){
$AgeRestricted = true;
}
}
}
}
Notice I added the line:
Mage::register('feedback', $AgeRestricted);
then im trying to call this with:
echo Mage::registry('feedback');
in file: app/design/frontend/dexam/default/template/checkout/onepage/payment.phtml
but it displays nothing at all. I've tested the location in payment.phtml is working.. my test text appears but 'feedback' is not calling the $AgeRestricted.
I tried echo $AgeRestricted; in my controller, which echo'd lots of '1's at the top of my screen so I can see the variable contains the true value.
How can I call $AgeRestricted in payment.phtml?
Many thanks!! Daz