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
Related
In the category admin under Display settings I have assigned a static block. This is displaying fine but I need to position it further down the page. I've been looking for a callback like the generic getChildHtml but for blocks.
I was also thinking that the static block code that I normally use could be change from
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block-name')->toHtml();?>
to something like this
<?php echo $this->getLayout()->createBlock('cms/block')->toHtml();?>
but alas it did not work. I could possibly be done with the local.xml file but I'm not sure how to target it.
Bit stuck so any help would be greatly appreciated
I've come up with a workaround. It's not ideal but it's working. Instead of using the static block option in the category page I've added the static block to the list.phtml template. I then create a variable that gets the current category name and append it to a string.
<?php $blockid = 'category_banner_' . preg_replace('/\s+/', '', strtolower(Mage::registry('current_category')->getName())); ?>
I can then call this using the standard static block call
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId($blockid)->toHtml();?>
The last thing to do is make the static block and as long as it's named category_banner_CATEGORYNAME it should work fine.
As I said it's a bit of a workaround, but for the life of me I can't work out how to reposition the one set in the admin.
If anyone can come up with a better solution I would be eternally grateful
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.
I'm trying to move the 'Estimate Shipping' block, that usually sits in the Cart, to a CMS page.
I've successfully moved the form, however, upon clicking the 'Estimate..' button, I get redirected to the Cart.
I've tried changing
action="<?php echo $this->getUrl('checkout/cart/estimatePost') ?>"
to the cms page url:
`action="getUrl('delivery/estimatePost') ?>"`
and also a general:
action="<?php echo $this->getUrl('*/*/estimatePost') ?>"`
but then I just get a 404.
You should keep action="getUrl('checkout/cart/estimatePost') ?>" or otherwise you will need to create a different controller action which generate a different block content to allow to display in your cms block but it's not so easy as you try to do.
The string checkout/cart/estimatePost means module/controller/action, if you change that of course he won't find your page. That's why you need to develop a solution more complex with a mix of controller and based on the block classes used while the action estimatePost is called.
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.
I know how to use Zend_Acl to allow certain resources to certain usergroups but how do i use it to allow only specific parts of the page to be shown? For example
I have a button to delete a post via AJAX on the page but i only want to show the button to Admins only. I can use Zend_Acl to block access to the controller post/delete but i can't use it to block the button from showing.
// in controller
$this->view->allow_delete_post = $acl->isAllowed($role, 'delete_post');
.
// in template
<? if ($this->allow_delete_post): ?>[button html]<? endif; ?>
Would that not do it?
You can also write a custom static ACL class which you can then call directly from within your view script.
Since ACL is normally handled at plugin level it means that if your visitor is seeing the view then ACL has already allowed the resource, therefor inside your view you can now do something like this...
if(My_Custom_Acl::getIsAllowed('some_resource', 'delete_post_action'){
I did not specify the role name in the custom getIsAllowed() method, because at this point ACL is already suppose to know the user's Identity and the Role.
Hope this helps
Although Christof gave a good solution, an alternative is to split the views. Although this starts to violate DRY, when you have about 200 different admin things/controls, it's getting heavy in the view - thus splitting the view with $this->render('view') and $this->render('edit') for permissions from the controller is sometimes easier. Then only the edit view script has the edit links. But again, it's DRY, so not optimal, but an alternative. I guess you have to weigh it up, which one is more DRY, repeating the ACL check or the stuff in 2 views...