0

In checkout page on Billing Section If user enter wrong address details (ex: address validation) I want inject block.

when I put my code in indexAction it's working. but saveBillingAction not working. Any Idea?

 public function indexAction()
    {
..............
$block = $this->getLayout()->createBlock(
            'Mage_Core_Block_Template',
            'my_block_name_here',
            array('template' => 'activecodeline/developer.phtml')
        );

        $this->getLayout()->getBlock('head')->append($block);
..............
     }

it's working.

    public function saveBillingAction()
        {

            if ($this->_expireAjax()) {
                return;
            }
            if ($this->getRequest()->isPost()) {
                $data = $this->getRequest()->getPost('billing', array());
                $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);

                if (!$customerAddressId) {
                    $continue = $this->ValidateAddress($data['city'], $data['stateOrProvince'],$data['postalCode'],$data['countryCode']);
                    if (!$continue) {

             $block = $this->getLayout()->createBlock(
                       'Mage_Core_Block_Template',
                      'my_block_name_here',
                      array('template' => 'activecodeline/developer.phtml')
                      );

                  $this->getLayout()->getBlock('head')->append($block);                            

                        return;
                    }
                }

            }

            parent::saveBillingAction();
        }

it's now working.

How Can I inject when user enter wrong details?

Thanks.

1

the saveBillingAction is not a regular action. It does not return a full page.
It does not have a layout to it. It just returns a JSON that is evaluated by the js in charge of the checkout.

If you want to display something in the page after the saveBillingAction is executed you can try to add that html as a section of the returned JSON and then modify the opcheckout.js file so you can inject that html in the section you need.

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.