How to make Installments on product page get Final or SpecialPrice instead of GrantTotal? - magento

Maybe someone can help me on this one. I want to insert a dropdown installments on product page, and must show the price numbers with 2 decimals, for example: R$ 300,00 instead of R$ 300,0000. Thank you!
This is the code that i have and tried to modify it but with no success:
<?php
$standad = Mage::getSingleton('moip/standard');
$api = Mage::getSingleton('moip/api');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('o2ti_moip/css/formulario.css'); ?> "media="all">
<?php
$_product = $this->getProduct( );
$_coreHelper = $this->helper('core');
?>
<?php if ($standad->getConfigData('parcelamento')): ?>
<label id="dadoscartaoopc">Parcelamento no Cartão de Crédito:</label>
<select name="payment[credito_parcelamento]" id="credito_parcelamentoproduto" >
<?php
$parcelamento = $api->getParcelamento($_product->getFinalPrice());
foreach ($parcelamento as $k => $v): ?>
<option value="<?php echo $k ?>"><?php echo $k . "x R$ " . $v['valor'] . " | Total: R$ " .$v['total']."" ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>
<div id="addparcelas">
<?php
$standard = Mage::getSingleton('moip/standard');
$parcelamento = $standard->getInfoParcelamento();
if ($parcelamento['juros1'] == 0)
{
echo "<div id=\"addparcelasdesc\"> Sem juros até ".$parcelamento['ate1']." parcelas,</div>";
if ($parcelamento['ate1'] < 13)
{
echo "após juros de 1,99% ao mês.";
}
}
if ($parcelamento['juros1'] >= "1.99")
{
echo "Com juros de ".$parcelamento['juros1']." ao mês.";
}
?>
</div>
Printscreen of the actual dropdown: http://postimg.org/image/pokqf6xxj/03a4fda4/

Solution:
<?php
$standad = Mage::getSingleton('moip/standard');
$api = Mage::getSingleton('moip/api');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('o2ti_moip/css/formulario.css'); ?> "media="all">
<?php
$_product = $this->getProduct( );
$_coreHelper = $this->helper('core');
?>
<?php if ($standad->getConfigData('parcelamento')): ?>
<label id="parcelamentoproduto">PARCELAMENTO NO CARTÃO DE CRÉDITO:</label>
<select name="payment[credito_parcelamento]" id="credito_parcelamentoproduto" >
<?php
$parcelamento = $api->getParcelamento($_product->getFinalPrice());
foreach ($parcelamento as $k => $v): ?>
<option value="<?php echo $k ?>"><?php echo $k . "x R$ " . number_format($v['valor'],2,',',' ') . " ---------- Total: R$ " .number_format($v['total'],2,',',' ')."" ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>
<div id="addparcelas">
<?php
$standard = Mage::getSingleton('moip/standard');
$parcelamento = $standard->getInfoParcelamento();
if ($parcelamento['juros1'] == 0)
{
echo "<div id=\"addparcelasdesc\"> Sem juros até ".$parcelamento['ate1']." parcelas,</div>";
if ($parcelamento['ate1'] < 13)
{
echo "após juros de 1,99% ao mês.";
}
}
if ($parcelamento['juros1'] >= "1.99")
{
echo "Com juros de ".$parcelamento['juros1']." ao mês.";
}
?>
</div>

Related

code igniter . i have issue to show upcoming birthday of month(like July) custom

I am beginner in development i have issue to show upcoming birthday of month(like July) guide me to please fix this problem here is code. here is code to show upcoming birthday.
<h3 class="panel-title"><?php echo 'Upcomming Birthday' ?> - <?php echo date("F"); ?></h3>
<ul class="leave_apps">
<?php
$m = date("m"); // Month value
$y = date("Y"); // Year value
$num = cal_days_in_month(CAL_gregorian , $m, $y);
?>
<?php
for ($i = 0; $i < count($employee); $i++) :
$mem_bod_explode = explode("-", $employee[$i]->date_of_birth);
$m_bday = mktime(0, 0, 0, $mem_bod_explode[1], $mem_bod_explode[2], $y);
$start_date = date('Y-m', $m_bday) . '-01';
$end_date = date('Y-m', $m_bday) . '-' . $num;
if (date('Y-m-d') == date('Y-m-d', $m_bday)) {
$present_bday[] = $employee[$i];
$date = date('Y-m-d', $m_bday);
$pdate[] = date('d M Y', strtotime($date));
} else if (date('Y-m-d', $m_bday) > $start_date && date('Y-m-d', $m_bday) <= $end_date) {
$future_bday[] = $employee[$i];
$date = date('Y-m-d', $m_bday);
$fdate[] = date('d M Y', strtotime($date));
}
?>
<?php endfor; ?>
<?php if (!empty($present_bday)):foreach ($present_bday as $key => $v_bday): ?>
<li>
<a href="<?php echo base_url() ?>admin/employee/view_employee/<?php echo $v_bday->employee_id ?>">
<h5>
<div class="pull-left">
<img class="img-circle" src="<?php echo base_url() . $v_bday->photo ?>">
</div>
<span><?php echo $v_bday->first_name . ' ' . $v_bday->last_name ?></span>
<small class="apps_category" style="color:red">(Today)</small>
<p class="leave_para"><?php echo $pdate[$key]; ?></p>
</li>
<?php endforeach; ?>
<?php endif; ?>

Create multiple row product slider

I'm using magento and I have a new product slider on my homepage that shows the new products but it is only one row big and I want to decide if it's 2 rows or more on my homepage but i don't know what i need to change in the .phtml file so it is 2 rows instead of one.
If you go to parts2u.nl you can see what i mean underneath Nieuwe Artikelen that is the new product slider I'm talking about.
This is the code:
<?php
/**
*
*/
?>
<?php
$_productCollection = $this->getProductCollection();
?>
<?php if ($_productCollection && ($_collectionSize = $_productCollection->getSize())): ?>
<?php
$theme = $this->helper('fortis');
$helpLabels = $this->helper('fortis/labels');
$helpTemplate = $this->helper('fortis/template');
$helpImg = $this->helper('infortis/image');
$sliderClasses = '';
$gridClasses = '';
//Default image size
$imgWidth = 168;
$imgHeight = 168;
//Image aspect ratio
if ($theme->getCfg('category/aspect_ratio'))
{
$imgHeight = 0; //Height will be computed automatically (based on width) to keep the aspect ratio
}
//Basic slider block parameters
//--------------------------------------------------------------
$isResponsive = $this->getIsResponsive(); //param: is_responsive
$breakpoints = $this->getBreakpoints(); //param: breakpoints
$showItems = $this->getShowItems(); //param: show_products
if (!$showItems)
{
$showItems = 5; //IMPORTANT: set default number of visible products
}
//Slider timeout (if set: automatic slideshow)
$timeout = $this->getTimeout(); //param: timeout
if ($timeout === NULL) //Param not set
{
$timeout = intval($theme->getCfg('product_slider/timeout'));
}
else
{
$timeout = intval($timeout);
}
//Slider initial delay
$initDelay = intval($this->getInitDelay()); //param: init_delay
//Number of items that should move on animation
$move = $this->getMove(); //param: move
if ($move === NULL) //Param not set
{
$move = intval($theme->getCfg('product_slider/move_items'));
}
else
{
$move = intval($move);
}
//Additional slider classes
//--------------------------------------------------------------
if($isResponsive)
{
$sliderClasses .= ' itemslider-responsive';
}
if ($_collectionSize == 1)
{
$sliderClasses .= ' single-item';
}
//Additional grid classes
//--------------------------------------------------------------
//Size of grid elements
$size = $this->getSize(); //param: size
if ($size)
{
$gridClasses = ' ' . $size;
}
else
{
if ($showItems >= 8)
{
$gridClasses = ' size-xs';
}
elseif ($showItems >= 6)
{
$gridClasses = ' size-s';
}
}
//Align elements to the center
if ($this->getCentered()) //param: centered
{
$gridClasses .= ' centered';
}
//Set equal height for all items
if ($this->getEqualHeight()) //param: equal_height
{
$gridClasses .= ' equal-height';
}
?>
<h3 class="section-title padding-right"><?php echo $this->getBlockName(); ?></h3>
<div class="itemslider-wrapper new-itemslider-wrapper">
<div class="nav-wrapper gen-slider-arrows1 gen-slider-arrows1-pos-top-right"></div>
<div class="itemslider itemslider-horizontal<?php if($sliderClasses) echo $sliderClasses; ?>">
<ul class="slides products-grid<?php if($gridClasses) echo $gridClasses; ?>">
<?php foreach ($_productCollection->getItems() as $_product): ?>
<li class="item">
<div class="product-image-wrapper" style="max-width:<?php echo $imgWidth; ?>px;">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" class="product-image">
<img src="<?php echo $helpImg->getImg($_product, $imgWidth, $imgHeight, 'small_image'); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" />
<?php if ($theme->getCfg('category/alt_image')): ?>
<?php echo $theme->getAltImgHtml($_product, $imgWidth, $imgHeight); ?>
<?php endif; ?>
<?php echo $helpLabels->getLabels($_product); //Product labels ?>
</a>
<?php //Add-to links
if ($theme->getCfg('category_grid/display_addtolinks') != 0
&& $theme->getCfg('category_grid/addtolinks_simple'))
{
if ($theme->getCfg('category_grid/display_addtolinks') == 1) //Display on hover
{
echo $helpTemplate->getCategoryAddtoLinksComplex_2(
$_product, $this->getAddToCompareUrl($_product), 'addto-links-icons addto-onimage visible-onhover');
}
else //Always display
{
echo $helpTemplate->getCategoryAddtoLinksComplex_2(
$_product, $this->getAddToCompareUrl($_product), 'addto-links-icons addto-onimage');
}
}
?>
</div> <!-- end: product-image-wrapper -->
<h3 class="product-name"><?php echo $this->escapeHtml($_product->getName()) ?></h3>
<?php echo $this->htmlEscape($_product->getSku()); ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php echo $this->getPriceHtml($_product, true, '-new') ?>
<div class="actions">
<?php if($_product->isSaleable()): ?>
<?php if ($this->getHideButton() == false): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php endif; ?>
<?php else: ?>
<?php if ($this->getHideButton() == false): ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php endif; ?>
<?php //Add-to links
if ($theme->getCfg('category_grid/display_addtolinks') != 0 && !$theme->getCfg('category_grid/addtolinks_simple'))
{
if ($theme->getCfg('category_grid/display_addtolinks') == 1) //Display on hover
echo $helpTemplate->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right addto-texticons display-onhover');
else //Always display
echo $helpTemplate->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right addto-texticons');
}
?>
</div>
</li>
<?php endforeach; ?>
</ul> <!-- end: slides -->
</div> <!-- end: itemslider -->
</div> <!-- end: new-itemslider-wrapper -->
<script type="text/javascript">
//<![CDATA[
jQuery(function($) {
$('.new-itemslider-wrapper .itemslider').flexslider({
namespace: "",
animation: "slide",
easing: "easeInQuart",
<?php if ($timeout): ?>
slideshowSpeed: <?php echo $timeout; ?>,
animationLoop: true,
<?php else: ?>
slideshow: false,
animationLoop: false,
<?php endif; ?>
<?php if ($initDelay): ?>
initDelay: <?php echo $initDelay; ?>,
<?php endif; ?>
<?php if ($speed = intval($theme->getCfg('product_slider/speed'))): ?>
animationSpeed: <?php echo $speed; ?>,
<?php endif; ?>
pauseOnHover: true,
controlNav: false,
controlsContainer: ".new-itemslider-wrapper .nav-wrapper",
itemWidth: 188,
<?php if ($showItems): ?>
minItems: <?php echo $showItems; ?>,
maxItems: <?php echo $showItems; ?>,
<?php endif; ?>
move: <?php echo $move; ?>
})
<?php if ($breakpoints): ?>
.data("breakpoints", [ <?php echo $breakpoints; ?> ] )
<?php elseif ($showItems): ?>
.data("showItems", <?php echo $showItems; ?> )
<?php endif; ?>
; //IMPORTANT: don't remove semicolon!
});
//]]>
</script>
<?php endif; ?>
This seems like an incredibly convoluted implementation. I recommend that you seriously invest some time building your own slider rather than attempting to hack this to work the way you desire. Super cereal.

Show all subcategories of current parent caregory in sidebar navigation in MAGENTO

Trying to build sidebar category structure in Magento so that all children for an active category show when clicked. Using below as sample, when you go into main catalog only Main Cats appear. Then when clicking any Sub Cat the children for that respective category appear and so on.
For example
Main Cat 1
Sub Cat 1
Sub/Sub 1
Sub/Sub 1
Sub/Sub 1
Sub Cat 1
Sub Cat 1
Main Cat 2
Main Cat 3
Here's the current code I have, but once you get to the last category, only the Main Cats show (in other words, if you click on Sub/Sub, the menu closes and shows only the Main Cats).
<aside id="sidebar">
<div class="sidebar-nav">
<h2><?php echo $this->__('Products') ?></h2>
<ul>
<?php foreach ($store_cats as $cat) {
if ($cat->getName() == $current_cat) {
echo '<li>'.$cat->getName()."<ul>";
foreach ($obj->getCurrentChildCategories() as $subcat) {
echo '<li>'.$subcat->getName()."</li>";
}
echo "</ul></li>";
} else {
echo '<li>'.$cat->getName()."</li>";
}
} ?>
</ul>
</div>
<div class="sidebar-nav">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('holiday-nav-links')->toHtml() ?>
</div>
<div class="sidebar-nav">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('about-us-nav-links')->toHtml() ?>
</div>
</aside>
Any help is much appreciated. Thank you in advance for the help!
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo $_category->getName() ?>
</a>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Please check this link http://fishpig.co.uk/magento/tutorials/display-categories-and-subcategories-in-magento/
hope this help you
Had to do this very thing a few days back . get my whole function, may include some unnecessary html parts though. Shows 2nd level categories level onwards (for 3rd level category view as well)
public function getCatTree()
{
$treeHtml = '';
$_helper = Mage::helper('catalog/category');
$_categories = $_helper->getStoreCategories();
$category = Mage::registry('current_category');
$level = $category->getLevel();
switch($level)
{
case 4 :
$level3Cat = $category->getParentCategory();
$level2Cat = $level3Cat->getParentCategory();
break;
case 3 :
$level2Cat = $category->getParentCategory();
break;
case 2 :
$level2Cat = $category;
break;
default :
$level2Cat = null;
break;
}
//get the level 2 category ID
$categoryId = $level2Cat->getId();
if (count($_categories) > 0)
{
foreach ($_categories as $_category)
{
//match with the level 2 category, then list all its children
if ($_category->getId() == $categoryId)
{
$_category = Mage::getModel('catalog/category')->load($_category->getId());
$_catChildrens = $_category->getAllChildren();
foreach(explode(',',$_catChildrens) as $index=>$child)
{
$cat = Mage::getModel('catalog/category')->load($child);
if($cat->getLevel() == 3 && $cat->getIsActive())
{
$isParent = ($cat->hasChildren()) ? 'parent' : '';
$treeHtml .= '<li class="level1 nav'.$cat->getLevel().' '.$isParent.'">'.
'<a href="'.$cat->getUrl().'">'.
$cat->getName().
'</a>';
if($cat->hasChildren())
{
$treeHtml .= '<div class="sub-menu-wrap"><ul class="level1">';
foreach($cat->getChildrenCategories() as $indx=>$_subcategory)
{
if($_subcategory->getIsActive())
{
$cat4 = Mage::getModel('catalog/category')->load($indx);
$treeHtml .= '<li class="level2 nav'.$cat4->getLevel().'">'.
'<a href="'.$cat4->getUrl().'">'.
$cat4->getName().
'</a></li>';
}
}
$treeHtml .= '</ul></div>';
}
$treeHtml .= '</li>';
}
}
return $treeHtml;
}
}
}
}

Codeigniter nested foreach in slideshow?

I ask this https://stackoverflow.com/a/14277726/1670630 on other post but my problem still exist.
In codeigniter 2.1 I'm trying to display channels by category. So if i have a category called Film, i should see a list of Channels within Film. I tried a nested foreach loop to accomplish this but can't seem to get it to work in the slidshow and limit by number of row.
My model:
<?php
class Pages_model extends CI_Model {
function get_channels_by_categ_tv()
{
$this->db->select('categories.category_name, channels.channel_name');
$this->db->from('type_categ');
$this->db->join('categories', 'categories.category_id = type_categ.category_id');
$this->db->join('channels', 'channels.channel_id = type_categ.channel_id');
$this->db->order_by('categories.category_id');
//$this->db->group_by(array('categories.category_id'));
$query = $this->db->get();
if($query->num_rows() == 0)
{
#no channels
return false;
}
return $query->result_array();
}
}
I have this in the view:
<ul class="slides">
<li>
<?php $cat_shown = ''; ?>
<div class="programe-tv_link">
<?php $cat_show = ''; $cnl_show = '';?>
<?php foreach ($category_chaneels as $category): ?>
<?php
if ($cat_show != $category['category_name']) {
$cat_show = $category['category_name'];
echo '<p>' . $cat_show . '</p>';
}
$cnl_show = $category['channel_name'];
echo '<dd> >>' . $cnl_show . '</dd> ';
?>
<?php endforeach; ?>
</div>
</li>
<li>
<div class="programe-tv_link">
<p>Arte</p>
<dd> >> Acasa</dd>
<dd> >> Antena 1</dd>
<dd> >> Pro TV</dd>
</div>
<div class="programe-tv_link">
<p>Music Box</p>
<dd> >> Acasa</dd>
<dd> >> Antena 1</dd>
<dd> >> Pro TV</dd>
<dd> >> TLC</dd>
</div>
</li>
</ul>
I atache image with ilustration,
sorry for my english and if you don't understund me please write here. THX in advance.
My finale code is this.
<div id="programe-tv-slide" class="flexslider">
<strong>Programe TV</strong>
<div class="redLine"></div>
<?php $cat_cnl = array();
$list = array();
$i=1;
foreach ($category_chaneels as $option) {
$catname = $option['category_name'];
$chlname = $option['channel_name'];
$cat_cnl[$catname][$i] = $chlname;
$list[$i] = $catname;
$i++;
};
?>
<?php
$rows = array_chunk($cat_cnl, 4, TRUE);
foreach ($rows as $row) { //var_dump($rows);
?>
<ul class="slides">
<?php
echo ('<li>');
foreach ($row as $category => $channels) {
echo '<div class="programe-tv_link">';
echo '<p>' . $category . '</p>';
foreach ($channels as $channel) {
echo '<dd>' . $channel . '</dd> ';
};
echo '</div>';
};
echo ('</li>');
?>
</ul>
<?php }; ?>
</div>

Magento: Put "product list pager"-block in <head>

I have the following problem:
I want develop Pagination with rel=“next” and rel=“prev” for magento product lists.
http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html
How can I access the pager in ? The head-block has been already rendered when the pager-block will be rendered...
Is there any solution for my problem?
Yes, you can do edit the following file:
/app/design/frontend//default/template/page/html/pager.phtml
There you see for example:
<?php if (!$this->isFirstPage()): ?>
<li>
<a class="previous<?php if(!$this->getAnchorTextForPrevious()): ?> i-previous<?php endif;?>" href="<?php echo $this->getPreviousPageUrl() ?>" title="<?php echo $this->__('Previous') ?>">
<?php echo $this->__("Previous");?>
</a>
</li>
<?php endif;?>
Where you can easily add the rel="..." you want to the link, same goes for the "Next" link ;)
I added this code into the head.phtml file...
<?php
$actionName = $this->getAction()->getFullActionName();
if($actionName == 'catalog_category_view') // Category Page
{
$id = Mage::app()->getRequest()->getParam('id', false); //cat id
$category = Mage::getModel('catalog/category')->load($id);
$prodCol = $category->getProductCollection();
$tool = $this->getLayout()->createBlock('catalog/product_list_toolbar')->setCollection($prodCol);
$linkPrev = false;
$linkNext = false;
if ($tool->getCollection()->getSize()) {
if ($tool->getLastPageNum() > 1) {
if (!$tool->isFirstPage()) {
$linkPrev = true;
$prevUrl = $tool->getPreviousPageUrl();
}
if (!$tool->isLastPage()) {
$linkNext = true;
$nextUrl = $tool->getNextPageUrl();
}
}
}
?>
<?php if ($linkPrev): ?>
<link rel="prev" href="<?php echo $prevUrl ?>" />
<?php endif; ?>
<?php if ($linkNext): ?>
<link rel="next" href="<?php echo $nextUrl ?>" />
<?php endif; ?>
<?php
}
?>
From version 1.5 this solution doesn't work anymore, this is my solution:
$actionName = $this->getAction()->getFullActionName();
if($actionName == 'catalog_category_view') // Category Page
{
$id = Mage::app()->getRequest()->getParam('id', false); //cat id
$category = Mage::getModel('catalog/category')->load($id);
$prodCol = $category->getProductCollection()->addAttributeToFilter('status', 1)->addAttributeToFilter('visibility', array('in' => array(2, 4)));
$tool = $this->getLayout()->createBlock('page/html_pager')->setLimit($this->getLayout()->createBlock('catalog/product_list_toolbar')->getLimit())->setCollection($prodCol);
$linkPrev = false;
$linkNext = false;
if ($tool->getCollection()->getSize()){
if ($tool->getLastPageNum() > 1){
if (!$tool->isFirstPage()) {
$linkPrev = true;
if($tool->getCurrentPage()==2){
$url = explode('?',$tool->getPreviousPageUrl());
$prevUrl = $url[0];
}
else $prevUrl = $tool->getPreviousPageUrl();
}
if (!$tool->isLastPage()){
$linkNext = true;
$nextUrl = $tool->getNextPageUrl();
}
}
}
if ($linkPrev) echo '<link rel="prev" href="'. $prevUrl .'" />';
if ($linkNext) echo '<link rel="next" href="'. $nextUrl .'" />';
}

Resources