Magento: Empty Payment Html in Methods.phtml - magento

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

Related

Payment method form not visible before click

We have created custom payment method. The method contains inputs etc in its form.phtml file. In checkout, we get to Payment methods and our method is checked, but its form is not visible until we check it again. We can click continue, but it throws exception that we need to fill those inputs. However, user does not see them so he'll be confused.
Real situation
Expected situation
Do we need to add any property?
Solution:
I added JS to form.phtml and it is working now.
var customMethodCheckbox document.getElementById("p_method_custom_method");
var customForm = document.getElementById("payment_form_<?php echo $this->getMethodCode() ?>");
if(customMethodCheckbox.checked){
customForm.style.display = "";
}
Once form.phtml is loaded, it triggers this JS. If custom payment method is checked as default, it removes display: none attribute from custom form and displays it. And you don't need to worry about changing payment methods etc, because it is solved by Magento.

Route not displaying correct page until refresh

I've never run into this before. on the /orders page there is the list of orders. When clicking the link it should take you to that order. However there is a long pause and the browser
re-displays the list even though the url is correct localhost/orders/2024 . If I look at the page source it shows the order, not the order list. If I refresh the page it shows the order not the order list. It does this in both firefox and chrome.
The only thing I can thing is that laravel is caching something.
My routes file:
<?
Route::get('orders/{id}',['as'=>'orders.show','uses'=> 'OrdersController#show']);
Route::get('orders', ['as'=>'orders.index','uses'=>'OrdersController#index']);
Does anyone have any idea about what's going on? I should add it does this from other computers also
EDIT: the show method. The order show file just display's "hello"
public function show($id)
{
return View::make('orders.show');
}
Looking at the source code for most browsers means refresh. To check your source code, open developers tool on Chrome, click the order link and then inspect your source code on the 'Elements' tab.
Somehow your order request in the first time is not being served by 'orders/{id}' and falling back to 'orders'. So do some tests:
1) Open a new browser tab and hit: localhost/orders/2024, what do you get?
2) Use dd() to understand where you are exactly:
public function show($id)
{
dd('on show!');
return View::make('orders.show');
}
public function index()
{
dd('on index!');
return View::make('orders.index');
}
3) Check the source code of your lists page, how those links are being generated? They might being somehow confusing Laravel routing system.
4) Create a link to a product manually and check if it does the same.
This didn't have anything to do with Laravel. It was twitter bootstrap. I haven't tracked down the problem yet but when I exclude twitter-bootstrap it works fine. Sorry, this should have been one of the first things I checked.

Displaying a static block as a popup window in Magento

I'm trying to display a static block in Magento as a popup window, but can't seem to get the code to work.
I've found code in various places on the internet that seems to be fairly close to what I want but I can't get any results. I've used the basic code to return the "top links" to my site so I know that the basics work.
I've created a delpopup.php script in my Magento root folder and put in this code:
<?php
require_once('app/Mage.php');
umask(0);
$layout = Mage::app()
->getLayout();
$layout
->getUpdate()
->addHandle('default')
->load();
$layout
->generateXml()
->generateBlocks();
echo '<p>before</p>';
echo $layout
->createBlock('cms/block')
->setBlockId('delivery-info')
->toHtml();
echo '<p>after</p>';
?>
Unfortunately the code doesn't display the static block. That part of the output is blank.
The idea is that I can place a link in a regular page in Magento and have my delivery into pop up. Like this:
<a title="" onclick="popWin('http://www.mysite.com.au/delpopup.php', 'deliveryinfo', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" href="#">Delivery Info</a>
Basically I want to be able to display a static block in a popup window that uses my Magento site's theme. Any ideas would be greatly appreciated.
As I thought, the problems lies on incorrect Block Id.
Now that the cms is able to be shown.
So now the question is: how to get the theme work?
Not really sure what do you mean by theme, if what you mean is css that was included in <default> tag, you can use:
Mage::getDesign()->setTheme('your theme');
echo $layout->getBlock('head')->toHtml();
After the xml has been finished generated, it means put that code after:
$layout
->generateXml()
->generateBlocks();
I'd first setup a controller and block(s) to render the type of layout that you want to throw within the popup. So, instead of doing this within a standalone php file, do it within the regular mage framework within a specific controller action.
Then, once you have that working - the question is how to pull it into a popup. I'd go with maybe a nice jquery popup widget that allows you to specify a URL to hit - and then just pass in the one that you prepped for step 1 above.
You may want to look at adminhtml/default/default/template/popup.phtml for inspiration. That's actually a popup template for the admin, not the frontend, but you can see what they've done.
They're pulling in some standard magento blocks including the head block, which should pull in all your CSS and JS, in order to give you the general color scheme / look&feel of your frontend, but without all of the navigation, etc.

Why can I not get the message block in Magento to show on the category page?

I'm trying to get Magento to redirect after a customer clicks the 'Add to Cart' button over to the category page, which I have done with no problem (after a little bit of searching around, of course) by using a hidden field with the name of "return_url". This part works perfectly, and the item is added to the cart, and the user is redirected back to the category page. Once here, no matter what I've tried I cannot get the message block to show the success (or error) message. Here is my most recent code attempt (in view.phtml):
$messages=Mage::getSingleton("checkout/session")->getMessages();
echo $this->getLayout()->createBlock("core/messages")->setMessages($messages)->getGroupedHtml();
Thanks!
Have you tried more simple addSuccess/addError/addNotice functions?
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('An error'));
Mage::getSingleton('core/session')->addSuccess(Mage::helper('core')->__('A success'));
Mage::getSingleton('core/session')->addNotice(Mage::helper('core')->__('A notice'));
You can add a message to different session model types like "catalog", "customer", "checkout" or simple "core".
Same as:
Mage::getSingleton('catalog/session')
Mage::getSingleton('customer/session')
Mage::getSingleton('checkout/session')
Mage::getSingleton('core/session')
In your case, the customer session messages are not initialized in the category controller. Take a look at
\Mage_Catalog_CategoryController::viewAction
The end of the function should look like this:
$this->_initLayoutMessages('catalog/session');
$this->_initLayoutMessages('checkout/session');
$this->renderLayout();
To display the messages from "customer/session", this area must look like this:
$this->_initLayoutMessages('catalog/session');
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('checkout/session');
$this->renderLayout();

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