Display image in order comment in magento - magento

I have added a comment to order on checkout success page. The comment is path to an image file. I want to display the image there rather than its path.
I added the following code for adding the comment,
$order->setState('processing', 'invoiced', $img_path);
Is it possible if I send html of image and image is shown rather than path?

Create a custom module that extend app/design/adminhtml/default/default/template/sales/order/view/history.phtml
Change Line #71 from
<?php if ($_item->getComment()): ?>
<br/><?php echo $this->escapeHtml($_item->getComment(), array('b','br','strong','i','u')) ?>
<?php endif; ?>
To
<?php if ($_item->getComment()): ?>
<br/><?php echo $this->escapeHtml($_item->getComment(), array('b','br','strong','i','u', 'img')) ?>
<?php endif; ?>
(If you have any issues check the value of 'comment' in sales_flat_order_status_history db to see if it already escapeHtml)

Related

How to compare current_url with site_url in codeigniter?

I have used something like that-
<?php if(current_url() == site_url()): ?>
...
...
<?php endif; ?>
But it's not working. I think there's something that I missed.
If you simply want to check if you're on the homepage of your site try this:
<?php if(strcmp(uri_string(),'')==0) : ?>
We are on the home page.
<?php endif; ?>
This solution will still work regardless of whether the base url is set correctly or not, unlike comparing base_url() and current_url().
Ensure that you have loaded the url helper either in your constructor or via autoloading.

How to modify magento product template?

I would like to change the product page template in our magento store. Can you please advice how to insert this tag "/PACK" beside the product price?
See image links: http://www.thebodyshop.ie/price-pack/?___store=default
The second one, at the bottom would be the goal.
Thank you in advance!!!
Copy the price.phtml file from app/design/frontend/base/default/template/catalog/productAnd paste it into your theme_package_folder/template/catalog/product.Approx 201 and 203 lines you can find code to display price and final price in frontend.
<?php echo $_coreHelper->currency($_price, true, true) ?>
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
replace it with
<?php echo $_coreHelper->currency($_price, true, true).'/PACK' ?>
<?php echo $_coreHelper->currency($_finalPrice, true, true).'/PACK' ?>
If you want you can even give span to '/pack' and give your css.

Magento: Switch From Grid view To List View, Without Changing URL

I was wondering if you could guide me how to allow the user to select either list or grid view, without changing the URL of the catalog/category page.
I.e., the page is either www.example.com/category?mode=grid OR www.example.com/category?mode=list but I want to make it just www.example.com/category and show the grid view by default, with the list view being displayed without changing the URL.
I hope you can help
There is no tutorial I guess..you have to do your own code ..And its not a big deal .. Open your list.phtml file in app/design/frontend/default/YOURTHEME/template/catalog/product/
Here you can see, they separate two view mode like this,
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
..bla.. bla ...
And Grid mode:
<?php else: ?>
<?php // Grid Mode ?>
Here they check the mode like this
<?php if($this->getMode()!='grid'): ?>
Just remove this condition, so that you can load both views, so now just add new css class or id to separate both modes, and manage them by Js like onclik event or something like that ...

Show Product on Search Page - Magento 1.7

Currently I have a snippet of code that will forward a user to the product page if they search for a term and only 1 product is associated with that keyword.
<?php if($this->getResultCount() == 1): ?>
<?php $prodId = $this->_productCollection->getAllIds() ?>
<?php $singleProduct = Mage::getModel('catalog/product')->load($prodId) ?>
<?php header('Location: ' . $singleProduct->getProductUrl()) ?>
<?php exit; ?>
<?php elseif($this->getResultCount()): ?>
However, what I want to do now is actually serve up the product and all its details on the results page itself if its the only one with that tag/search term INSTEAD of redirecting to the product page. Im pretty new to php so please bear with me.
Block template is bad place for this. Good place - controller.
Maybe you need rewrite controller for this functionality.
For example/app/code/core/Mage/CatalogSearch/controllers/ResultController.php
In controller your code looks like:
$this->getResponse()->setRedirect($_product->getProductUrl());

Is it possible to target just Simple Product from phtml template?

I see something like:
<?php if(!$_item->isComposite() && $_item->isSaleable()): ?>
and this
<?php if(!$_product->isGrouped()): ?>
But couldn't find a way to target only the Simple Product type in similar manner.
<?php if( $_product->getTypeId() == 'simple' ): ?>
As an alternative possibility you could assume a Simple product is on that is no other type.
<?php if (!$_item->isComposite() && !$_item->isSuper() && !$_item->isVirtual()): ?>
<!-- Simple type only -->
<?php endif; ?>
There is already a template file catalog/product/view/type/simple.phtml that only displays for Simple type products.
If that doesn't show in the right place for you look in layout/catalog.xml for <PRODUCT_TYPE_simple> to see how to make your own Simple-only template file.

Resources