Can I have more than one success (onepage) page in magento - magento

Can I have more than one success (onepage) page in magento. One for Cash on delivery and another for Online Bank transfer.
thanks in advance.....

Just modify the template file for checkout success page (checkout/success.phtml) to display what you want it to for each method used. You have access to the order object in the template and can do everything there. If you need additional functionality just extend the checkout success block and use the new functions in the template. Absolutely no need to create a new success page and if you did you would need to extend the checkout controller which could cause you problems down the line with upgrades etc.
<?php $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); ?>
<?php if ($order->getPayment()->getMethod() == "checkmo"): ?>
<p>Check or Money Order HTML</p>
<?php else if ($order->getPayment()->getMethod() == "bank_transfer"): ?>
<p>Bank Transfer HTML</p>
<?php endif; ?>
See this article by fontis for more information: http://www.fontis.com.au/blog/magento/customise-magento-checkout-success-page-based-payment-type

Related

magento cms pages and checking if customer logged in

I have a CMS page that has a download link on it. Here is what I need to happen:
keep the download link if the user is logged in.
if the user isn't logged in, change the behavior of the link so it is a link to register.
I see that there is layout update xml i can use <customer_logged_in> and potentially change that link based on that. How can I use that layout update xml in this cms page so that the link is different?
Or is there a better approach that I could try?
The better approach is to go with your custom block creation. Here is how you can achieve what you want.
1) Create a CMS page and in content section include your custom block
For Ex:
{{block type="core/template" name="download_page" template="YourTemplateFolder/TemplateFileName.phtml"}}
2) Check if customer is logged in or not.
For Ex:
<?php if(!Mage::getSingleton('customer/session')->isLoggedIn()): ?> //If user is logged in
<?php $downloadUrl = 'Your Download URL'; ?> //generate your download URL
<div>
<?php echo $downloadUrl; ?> // Allow user to download
</div>
<?php else: ?>//If user is NOT logged in
<?php $registerUrl = 'Your Register URL'; ?> //generate your register URL
<div>
<?php echo $registerUrl; ?> // Ask user to Register
</div>
<?php endif; ?>

Magento: how to include a .phtml from one module in another

I have two modules installed.
One module (module1) that was developed for onepage checkout and it is working fine. It replaces available.phtml with some new shipping methods etc.
I want to include this available in a new cashier (module2) that is not based on the onepage checkout. So I tried doing this:
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('unifaun/checkout/onepage/shipping_method/available.phtml')->toHtml(); ?>
It successfully includes the available.phtml. However, available.phtml does not behave as it should.
The first line in available.phtml is:
<?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
<p><?php echo Mage::helper('unifaun')->__('No shipping methods that suit your order were found. Please contact customer service.') ?></p>
<?php else: ?>
etc...
The problem is that I don't get any shipping rates etc as I do in onepage checkout. I have also manually entered the following:
<?php
$country = Mage::getStoreConfig('shipping/origin/country_id');
$postcode = Mage::getStoreConfig('shipping/origin/postcode');
$city = Mage::getStoreConfig('shipping/origin/city');
$quote = Mage::getSingleton('checkout/session')->getQuote();
$quote->getShippingAddress()
->setCountryId($country)
->setCity($city)
->setPostcode($postcode)
->setCollectShippingRates(true);
?>
So my question is what I need to do to make the following line work correctly so that the code actually gets the availaable shipping methods etc..., as it does when the module is included in onepage checkout.
$_shippingRateGroups = $this->getShippingRates()
I'm not sure if this is enough information to solve this problem, but I thought I make it a try and post it and see if anyone know what I'm doing wrong. :)
Cheers!
You are including a basic block of type core/template, all blocks are based of that.
So in your context there is no method getShippingRates for it to find.
So change the following to something like:
<?php echo $this->getLayout()->createBlock('unifaun_onepage/the_block_name')->setTemplate('unifaun/checkout/onepage/shipping_method/available.phtml')->toHtml(); ?>
Where the_block_name is the folder in the modules block, eg /Block/The/Block/Name.php

How do I manually theme Views in Drupal 7?

I am new to drupal and I am trying to figure out how to theme Views. I currently have a content type called Category with the following fields:Title, Image and Body. I created a view for the above mentioned content type so that I would list view of all the categories I have created.
To custom theme the view I created a folder called views in my theme folder, and created the following view files:
views-view-fields--plugin-categories.tpl.php
views-view--plugin-categories.tpl.php
views-view-unformatted--plugin-categories.tpl.php
This is what I currently have in my first file:
<div class="<?php print $classes; ?>">
<?php if ($rows): ?>
<div class="view-content">
<?php print $rows; ?>
</div>
<?php elseif ($empty): ?>
<div class="view-empty">
<?php print $empty; ?>
</div>
<?php endif; ?>
<?php if ($more): ?>
<?php print $more; ?>
<?php endif; ?>
</div><?php /* class view */ ?>
Instead of $rows, I tired to use print $field['image'] and print $field['body'] but this method does seem to work. Could you kindly advise on how I could theme the three fields, within categories, displayed using view?
You should name your template like this
views-view-fields--<machine-name-of-your-view>.tpl.php
So I'm assuming from the above that your view is called 'plugin-categories'. An easy way to check is to go to edit the view and look at the URL while you're on the edit page. It should have the format /admin/structure/views/view/YOUR-VIEW'S-MACHINE-NAME/edit, so you can get it from there.
Once you're sure it has the right name, clear your cache to make sure Drupal is picking up your new template. You just need the one above, not all three to modify the output of the three fields in question.
Once you've cleared cache, Drupal should be picking up the new template. You didn't mention exactly what isn't working, just that it's not working, so I wanted to cover the naming and caching, just in case. Now, to output particular fields in this view template, call them like this:
$fields['your-field-machine-name']
So $fields['body'] (I think you're missing an 's')
You should have nothing about $rows in this template! If you have anything about $rows, you haven't copied and pasted from the correct views template. Simply output the fields as you want them to appear in your view, in whatever order you want with the syntax above and put in whatever css classes, etc you want.
Let us know if that works!

add block drop-down link(menu) on quick access link on header of magento

I want to add a new drop-down links(menu) on header links(quick access) and move links of on it
just when a customer sign in show this drop-down links on quick access and it does not show when customer is guest or log out and when customer log in show name of customer as topic of drop-down links .
for this scenario what do I do now? I make static block for drop-down block and remove log out, my wishlist ,my account from top.links on page.xml and call static block on header but I do not know how to avoid to show for all customer(gust or log in) and another way that I test I want to call static block on local.xml in tag but I do not how to call static block
another problem on static block I cant use php code and I do not use getWelcome() ?> for topic of drop-down links.
You can't use php code inside static block so you need to create your own template file.
If you create you own template file you can use:
<?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>
//put Welcome message with $this->getWelcome() or anything you needed
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('your_indentifer')->toHtml() ?>
<?php else: ?>
//if needed, display something for not logged-in usersY here
<?php endif; ?>
You can also use <customer_logged_in></customer_logged_in> node in your local.xml instead of isLoggedIn() method in order to add you .phtml template or statick block (please note that it's top-level node and shouldn't been wrapped in <default> node)

codeigniter dynamic data template

I have this template view at view/include
<?php $this->load->view('include/header'); ?>
<?php $this->load->view($sidebar_column); ?>
<?php $this->load->view($result_column); ?>
<?php $this->load->view($footer_row); ?>
<?php $this->load->view('include/footer'); ?>
and i have the footer_row html at view/include
<div> this is footer row <?php echo $username ?></div>
then i call the footer_row in my controller
$data['footer_row'] = 'include/footer_row';
$this->load->view('include/template',$data);
My question, the footer_row is logged in user info and it appear in EVERY pages. With the above method I use, I have to call and retrieve the user info in every controller. How can i make it reusable so i don't need to repeat myself.
Reusability comes from making use of your constructors, and parent classes. Have a look at my previous answers:
Header and Footer in CodeIgniter
Constructor session validation for different functions
Instead of using this method why dont you use a template library which is easy to use. I would recommend Philsturgeons Template Library but there are some more you can use any that fits to your requirements.
Williams Concepts
http://williamsconcepts.com/ci/codeigniter/libraries/template/
Phil Sturgeons's
http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/
Most Simple
http://maestric.com/doc/php/codeigniter_template
And Finally Binpresses's
http://www.binpress.com/app/codeigniter-template-library/223

Resources