Magento - Partially overriding indexAction of OnePage controller - magento

I need to partially override the indexAction of OnePage controller. I'm trying to add in a way to get direct to the review step on returning to onepage checkout - all other steps are completed at this point, it's just that Magento behaviour is to start again! It will mean changes to the onestep.phtml as well, but I haven't got the far yet!
My controller override is working fine. I can add a new action on the controller, say reviewStepAction, but if I have this as a simple override for testing, the standard onepage checkout is not displayed. I get blank page with just the standard sidebar:
public function reviewStepAction() {
parent::indexAction();
}
I've also tried copying and modify indexAction to my action function, but still not getting the onepage checkout to display. The final part of indexAction is:
$this->getOnepage()->initCheckout();
$this->loadLayout();
$this->_initLayoutMessages('customer/session');
$this->getLayout()->getBlock('head')->setTitle($this->__('Checkout'));
$this->renderLayout();
So I'm guessing it's not working because the URL is ../checkout/onpegage/reviewstep so it's trying to load a "reviewstep" layout and not finding one. How can I force reviewStepAction to finish off by loading the usual /checkout/onepage layout? I tred using Mage::getSingleton('checkout/opnepage) but that just crashed.
I can't just redirect to checkout/onepage at the end of my action because that would invoke the standard indexAction and I need to insert something between initCheckout and renderLayout.
Thanks.

The following works:
public function reviewStepAction()
{
$this->loadLayout(array('default','checkout_onepage_index'));
$this->getOnepage()->initCheckout();
...additional code...
$this->_initLayoutMessages('customer/session');
$this->getLayout()->getBlock('head')->setTitle($this->__('Checkout'));
$this->renderLayout();
}
Only point to note is that the body class is set to checkout-onepage-reviewstep instead of the usual checkout-onepage-index.

Related

Magento - Ignore controller or action in ReferrerUrl

I have a problem with redirectReferrer()
When I add a product in cart, I do it with ajax (call : http://wwwww.ww/quickview/product/add).
Until here, everything is ok.
But, if I want to remove product from my cart, the deleteAction() redirect me to http://wwwww.ww/quickview/product/add with the method $this->_redirectReferer(Mage::getUrl('*/*'));
Is it possible to ignore a whole Controller or just an Action in _redirectReferer, without any modification in the deleteAction() ??
I tried this Mage::getSingleton('customer/session')->setNoReferer(true);, but it not seems to work..
Thank you.
PS: Magento CE 1.9.3
I discovered that is inside my controller (and action), that the referrer is setted ...
I return in JSON:
$this->getLayout()->createBlock('checkout/cart_sidebar')->setTemplate('checkout/cart/sidebar.phtml')->toHtml();
I think this is this part who cause my issue..

Magento: Empty Payment Html in Methods.phtml

I’ve got a problem with the payment methods for my checkout. When I reach the Checkout Step for the Payment Methods, the several options are displayed but I am getting no further Information to the Methods “Bank Payment” and “Cash on Delivery” when I click on the radio button.
It seems to me that getPaymentMethodFormHtml (checkout/onepage/payment/methods.phtml) is empty for these Methods. As a result of this issue, I am getting no information in the Order Confirmation Mail (like Bank Name, Cash on Delivery Fee).
Can anyone help me?
Your error should be in
/app/design/adminhtml/default/default/template/payment/form/[cc.phtml]
/app/design/frontend/default/default/template/payment/form/[cc.phtml]
You may need to take a look at each payment method to see the path for their template
e.g
<?php
class MagePal_CimPaymentPro_Block_Form_Payment extends Mage_Payment_Block_Form_Cc
{
protected function _construct()
{
parent::_construct();
$this->setTemplate('magepal/cimpaymentpro/payment/form/cc.phtml');
}
Also, you may want to check to make sure you don't have any javascript error on that page.
You could also use Inspect Element in chrome/Firefox (or firebug) to see if the html is hidden by css

Cannot saveShippingMethod in Magento One Page Checkout

I am writing a custom Magento 1.5.0.1 one page checkout for my site following the instructions on this site:
http://inchoo.net/ecommerce/magento/magentos-onepage-checkout-in-a-nutshell/
In summary, I am calling these functions in order:
$checkout = Mage::getSingleton(‘checkout/type_onepage’);
$checkout->saveCheckoutMethod(‘guest’);
$checkout->saveBilling($billingAddress, false);
$checkout->saveShipping($shippingAddress, false);
$checkout->saveShippingMethod(‘flatrate_flatrate’);
$checkout->savePayment(array(‘method’=>’checkmo’));
// Extra part not on the site but saw it in the original magento onpage checkout controller
$checkout->getQuote()->getPayment()->importData(array(‘method’=>’checkmo’));
//
$checkout->saveOrder();
// Extra part not on the site but saw it in the original magento onpage checkout controller
$checkout->getQuote()->save();
//
The problem is that when the code is first run, the shipping method is not being set, I get a error saying that the shipping method was not set. However, just refreshing the page makes the order go through.
One solution was that right after setting the shipping method with saveShippingMethod, checking if it was set with:
Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getShippingMethod();
Which 100% of the time it is not, then redirecting it back onto the same page, which on the 2nd run the shipping method is set...
this seems to be such a stupid magento bug! any ideas on how to fix it with this redirection (i.e. page refresh)?
Maybe it is me not being extremely expert about magento, but I'm pretty sure you have to use setShippingMethod($method) instead of saveShippingMethod($method) when creating an order, you can check more here.

Magento: Show the Review Step in One Page Checkout

I have not been able to figure this out for the life of me. I wanted to show the order review step(final step before processing the order) right away on the one page checkout in Magento. Any suggestions? Thanks all.
If you look at the bottom of onepage.phtml, you will see
<?php if($this->getActiveStep()): ?>
accordion.openSection('opc-<?php echo $this->getActiveStep() ?>');
<?php endif; ?>
which calls Mage_Checkout_Block_Onepage::getActiveStep() to determine which step to show first. You can override this by creating your own onepage.phtml in your theme and changing the block above to be:
accordion.openSection('opc-review');
However, the openSection function only executes if the target element ('opc-review') in this case, has a class of "allow" which is set by Magento's AJAX once the previous checkout steps are completed. You could manually add the "allow" class using prototype, but once you get the step to display, you'll see that it is empty, since the AJAX hasn't populated the content based on the previous steps as the previous steps haven't happened yet!
So... You could create a new block based on Cart.php and insert that into onepage.phtml using $this->getChildHtml('block-id') and the layout xml. You would need to insert it inside the ol#checkoutSteps as an li#opc-summary.section allow or something like that, and make the js change above to be accordion.openSection('opc-summary');
That's the best I can do at the moment for you. HTH,
JD

HMVC and dynamic widgets

Background
I use the word widget as a partial view that have its own controller (so its own actions) and it is placed in almost all pages. I implement the rendering of this via HMVC, that is just great.
Problem
Now, the problem is that the widget itself execute actions. Think about a shopping cart widget. That widget is placed in all pages so the user can see his/her stuff all along. And the widget have actions that are related to it, for instance: RemoveItem, RefreshCart, ApplyDiscountCoupon, etc. Such actions should trigger by a button or link and the link should be something like (in HMVC):
<a href='<?site_url()?>/cart/cart/removeitem/the_item_id'>Remove this item</a>
Ok. Now the user clicks that link, the cart module and cart controller are loaded and the action is executed, the action should look something like:
function removeitem($itemid)
{
// remove the item from db
...
// "load the view" ???
}
As you can see, my question is how to load the view in a HMVC module. The thing is that if I only load the cart view, it will only show my cart, and I can’t just redirect or load the main page because it can be any main page, that is: the cart could be in any main page (select product, keep buying, see product details, billing info, checkout, etc). :/
Another thing: a requirement is that I can’t use AJAX in this project.
Do you know how HMVC handle this?
Thanks in advance.
Ok. No luck with the community. Nevertheless I found a workaround. Hope would be helpful to someone.
HMVC doesn't have a natural solution to this. So I decided to use this workaround:
Into each main controller (that is, no widget, no partial view) I grab the current url in session this way (/controllers/keep_buying.php):
class Keep_buying extends Controller
{
function Keep_buying()
{
parent::Controller();
$this->session->set_userdata('main_uri', uri_string());
}
...
}
Then in my partial view widget (HMVC module view) I have a normal link to my widget controller (/modules/cart/views/cart_show.php):
<a class="button" href="cart/cart/additem">Add Item</a>
At the controller action (HMVC module controller action) I retrieve the current main page, do stuff and then redirect to that page, that implicitly will get into my widget flow (due to HMVC).
class Cart extends Controller
{
...
function additem()
{
$to_redirect = $this->session->userdata('main_uri');
// add-item work stuff...
redirect($to_redirect);
}
}
That is. Is not the ideal approach IMHO, but works.
I know that this topic is over a year old, however I have been Googling to gain some more insight into the structure an HMVC program should take, and how it can be implemented in CI, and have not found very many answers.
I'm pretty sure that for HMVC to work properly, with several widgets incorporated on all pages of a site, they need to be orchestrated by one main controller. This will be the top level of the heirarchy. Let me try to give an example:
You have a site with a shopping cart widget on every page. When you wish to use the cart functionality, you will need to link to methods in the cart module, e.g.:
add
The problem using this link is that you do not want to reload the rest of the site from that module. Instead, you can route the link through your main controller and have it reload the module, calling the desired method. e.g.
add
Then in the site controller, it will simply pass the method call to the main view
<?php
function cart_add($item){
$data['cart'] = 'cart/add/'.$item;
$this->load->view('main', $data);
}
?>
The view will call the cart widget with the following:
<?php echo modules::run($cart); ?>
Obviously this is a simplified explanation, and the main site controller will be handling several widgets in one main view, so passing the correct data will need to be managed better than just calling the main view from within a method. But hopefully this gives an idea of the structure I am referring to.
If anyone reads this and thinks I'm wrong, I would love to hear other solutions people have found to this issue.

Resources