0

I need to create a new block in the sucess page when a customer wins a gift (all 10 commands) how do I do that? Can you help me please

This is my observer

public function countOrder(Varien_Event_Observer $observer) {

$resource = Mage::getSingleton('core/resource');
$writeConnection = $resource->getConnection('core_write');

$action = $observer->getEvent()->getAction();

$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
$_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$order->getCustomerId())
         ->addAttributeToFilter('created_at', array('from'=>strtotime('-20 day', time()), 'to'=>time(),'datetime' => true));                
$_orderCnt = $_orders->count();

Mage::log( $_orderCnt, null, 'count.log');    


  if( $_orderCnt % 10 === 0 ) {


          Mage::log( $_orderCnt . ' ', null, 'win.log'); 

        // i want add new block or create a new template success for the winner !!! 

  }  
}

this is my config.xml

 <events>
        <checkout_onepage_controller_success_action>
            <observers>
                <mycustom_module>
                    <type>singleton</type>
                    <class>mycustom_module/observer</class>
                    <method>countOrder</method>
                </mycustom_module>
            </observers>
        </checkout_onepage_controller_success_action>
        <core_block_abstract_to_html_before>
            <observers>
                <mycustom_module>
                    <type>singleton</type>
                    <class>mycustom_module/observer</class>
                    <method>insertBlock</method>
                </mycustom_module>
            </observers>
        </core_block_abstract_to_html_before>
    </events>

How i can add new block or create a new template success for the winner ? i don't understand how i can do this ? Can you help me please ?

0

You have to do this:

$layout = Mage::app()->getLayout();
$block = $layout->createBlock('core/template', 'payment_custom_block');
$block->setTemplate('custom_message.phtml');
$layout->getBlock('footer')->append($block);
| improve this answer | |
  • Thank you Prince, so i create new template in design/frontend/default/default/template/Myfolder/custom_message.phtml. In my function countOrder in my observer in my condition for the winner (if( $_orderCnt % 10 === 0 )) . I have put your code but it's not work , it's in success page than i want to add a message or picture for the winner . – devmagento Sep 26 '17 at 8:36

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.