Magento inline translation disabled on one specific page - magento

I have a mystery question: in my magento shop there is a specific page (part of /customer/account but from an extension) where inline translation is not working at all.
To be more specific: If inline translation is enabled for the entire shop, then it does usually work fine. Menus, Sub-Menus, Titles, everything can be translated.
But as soon I navigate to said page, I can't translate anything on the whole site. Not even the Menus and Sub-Menus, that do not even belong to the requested page.
As soon as I navigate to another page, translation works fine again.
I'm really lost and I hope that you guys can point me to places where this might be configurated?
for full disclousure: the extension mentioned is Webkul_Marketplacepartner and the page mentioned is marketplacepartner/partnerproducts/mydashboard/
the source code of the phtml looks like this:
<?php
$customerid=Mage::getSingleton('customer/session')->getCustomerId();
$isPartner= Mage::getModel('marketplaceprofile/marketplaceprofile')->isPartner($customerid);
$partner=Mage::getModel('marketplaceprofile/marketplaceprofile')->getPartnerProfileById($customerid);
if($isPartner==1){?>
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/global.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/jquery.jqplot.min.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/webkul-image-slider.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/shCoreDefault.min.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/shThemejqPlot.min.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jquery.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jquery.jqplot.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/shCore.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/shBrushJScript.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/shBrushXml.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.logAxisRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasTextRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasAxisLabelRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasAxisTickRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.dateAxisRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.categoryAxisRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.barRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasTextRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasAxisLabelRenderer.min.js'); ?>" type="text/javascript"></script>
<style>
div.example-plot { height: 400px;width: 650px;}
</style>
<?php
$mysqlprefix = Mage::getConfig()->getTablePrefix();
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$k="";
$i=0;
$Optioncreated=0;
// prefix checking and execute code
$j=0;$op=0;
$weeklytotal=0;
$todaytotal=0.0;
$yeartotal=0.0;
$sk=array();
$allskulist=array();
$allmageprolist=array();
$$allorderids=array();
$s1=0;
$s2=0;
$s5=0;
$today=date("Y-m-d");
$sqlQuery = "select * from ".$mysqlprefix."marketplacepartner_entity_saleslist where mageproownerid =".$customerid." order by autoid desc";
$querydata=$write->query($sqlQuery);
$grandTotal = array();
$dataArr= array();
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
$baseCurrencyCode = Mage::app()->getBaseCurrencyCode();
foreach($write->fetchAll($sqlQuery) as $row){
$l=explode('-',$row['cleared_at']);
$day=substr($row['cleared_at'],0,10);
$row['actualparterprocost'] = round(Mage::helper('directory')->currencyConvert($row['actualparterprocost'], $baseCurrencyCode, $currentCurrencyCode),2);
$order = Mage::getModel('sales/order')->loadByIncrementId($row['magerealorderid']);
if($order->getStatus()!='pending'){
if($day==$today){
$todaytotal+=$row['actualparterprocost'];
}
$week_number = date('W');
$year = date('Y');
for($days=1; $days<=7; $days++)
{
$m=date('Y-m-d', strtotime($year."W".$week_number.$days));
if($day==trim($m))
{
$row['magerealorderid'].$weeklytotal=$row['actualparterprocost']+$weeklytotal;
}
}
$grandTotal[$l[1]]=$row['actualparterprocost']+$grandTotal[$l[1]];
$dataArr[]= $row;
}
}
?>
<div class="prdouctbackground">
<div class="maindash">
<h4 class="textcolor"><span><?php echo $this->__('My Vendor Dashboard') ?></span></h4>
<div class="salesmonth">
<div class="todaydash"><?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); if($todaytotal<=0) {echo 0;} else {echo $todaytotal;}?> <span class="textcolordash"> <?php echo $this->__('Today') ?></span>
</div>
<div class="weekdash"><?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); if($weeklytotal<=0){ echo 0;} else {echo $weeklytotal;}?> <span class="textcolordash"> <?php echo $this->__('Week') ?></span>
</div>
<div class="monthdash"><?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
$d=date('m');
echo $grandTotal[$d];
?>
<span class="textcolordash"><?php echo $this->__('Month') ?></span>
</div>
</div>
<div class="salesemail"></div>
<div class="orderdproduct">
<table class="tablepostioneditdash">
<thead><tr>
<th class="headingbg"><span><?php echo $this->__('Latest Order') ; ?> </span></th>
</tr></thead>
<tbody id="tbodyingeditdash">
<?php
$m=0;
foreach($dataArr as $key=>$val){
$order = Mage::getModel('sales/order')->loadByIncrementId($val['magerealorderid']);
if($order->getStatus()!= 'pending'){ ?>
<tr>
<th class="tdpadfirsteditheadingdash">
<label for="name" class="rightgapeditheadedit">
<?php if($order->getStatus()=='pending') {?>
<div class="status" style="background-color:orange"><?php echo $this->__(strtoupper($order->getStatus())); ?> </div>
<?php }?>
<?php if($order->getStatus()=='canceled') {?>
<div class="status" style="background-color:red"><?php echo $this->__(strtoupper($order->getStatus())); ?> </div>
<?php }?>
<?php if($order->getStatus()=='complete') {?>
<div class="status" style="background-color:green"><?php echo $this->__(strtoupper($order->getStatus())); ?> </div>
<?php }?>
<?php if($order->getStatus()=='delivered') {?>
<div class="status" style="background-color:green"><?php echo $this->__(strtoupper($order->getStatus())); ?> </div>
<?php }?>
<?php if($order->getStatus()=='processing') {?>
<div class="status" style="background-color:blue"><?php echo $this->__(strtoupper($order->getStatus())); ?> </div>
<?php }?>
<p style="margin: 0 0 10px 6px;"><?php echo "<br>".$val['cleared_at']; ?></p> </label>
</th>
<th class="tdpadfirsteditheadingdash">
<label for="name" class="rightgapeditheadedit">
<div class="textcolordashdiv"><?php echo $this->__('Order'); ?> #<?php echo $val['magerealorderid']; ?></div>
<?php $shipping_address = $order->getShippingAddress();
if ( $shipping_address != null) {
?>
<div class="dd">
<?php echo "By: " . $shipping_address->getCustomerId(); ?>
<br>
<?php
$orddataing="SELECT * FROM ".$mysqlprefix."sales_flat_order_item where order_id='".$val['mageorderid']."' ORDER BY order_id DESC";
//$sqlProductQuery = "select * from ".$mysqlprefix."marketplacepartner_entity_saleslist where mageproownerid =".$customerid." AND magerealorderid='".$val['magerealorderid']."'";
$ordconnectioning = Mage::getSingleton('core/resource')->getConnection('core_read');
//$order = Mage::getModel('sales/order')->load($orderidenitity[$x]);
//$priceTwo = Mage::helper('directory')->currencyConvert($aa, $baseCurrencyCode, $currentCurrencyCode);
$shipammount=(int)$order->getShippingAmount();
$count=0;
$product;
foreach($ordconnectioning->fetchAll($orddataing) as $ordername){
$product=Mage::getModel('catalog/product')->load($ordername['product_id']);
if($ordername['product_id'] == $val['mageproid']){
if($count==0){
echo "<p style='color:silver;float:left;'>" . (int)$ordername['qty_ordered']." x ".$ordername['name']." (" . $product->getSku() .")</p>"; $proid[$m]=$ordername['product_id'];
}else{
echo "<p style='color:silver;float:left;'>, ". (int)$ordername['qty_ordered']." x ".$ordername['name']." (" . $product->getSku() .")</p>"; $proid[$m]=$ordername['product_id'];
}
$count++;
$m++;
}
}?>
</div>
<?php } ?>
</label>
</th>
<th class="tdpadfirsteditheadingdash">
<?php
/* (2014-01-07 AM) disabled till further notice */
?>
<label for="name" class="rightgapeditheadprice"><?php echo $this->__('Net margin') . ': '; echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); echo " ".$val['actualparterprocost']?> </label>
<?php
/**/
?>
</th>
<th>
<?php if($order->getStatus()=='processing') {?> <label for="name" class="rightgapeditheadedit">
<div class="status" style="background-color:blue"><?php echo $this->__('Ready To Shipped'); ?></div>
<p style='color:silver;text-align:center;'><?php echo $this->__('Click To Ship Item'); ?></p>
<p style='color:silver;text-align:center;'><?php
if ($order->hasInvoices()) {
$invoice = $order->prepareInvoice();
$invoice->register();
//$invoice->setEmailSent(true);
$invoice->save();
//$invoice->sendEmail();
$invoiceID = $invoice->getId(); ?>
<?php
/*
(2014-01-07 AM) disable till further notice
<?php echo $this->__('Print Invoice'); ?>
*/
?>
<?php } ?></p>
</label>
<?php }?>
<?php $updatedDate = $order->getUpdatedAt();
$terminationDays = $partner['terminationperiod'];
$TotalTime = strtotime($updatedDate) + $terminationDays * 86400;
$currentTime = time();
?>
<?php if($order->getStatus()=='delivered') {?>
<label for="name" class="rightgapeditheadedit">
<div class="status" style="background-color:green"><?php echo $this->__('Item Delivered'); ?></div></label>
<p style='color:silver;text-align:center;'><?php
if ($order->hasInvoices()) {
$invoice = $order->prepareInvoice();
$invoice->register();
//$invoice->setEmailSent(true);
$invoice->save();
//$invoice->sendEmail();
$invoiceID = $invoice->getId(); ?>
<?php
/*
(2014-01-07 AM) disable till further notice
Print Invoice
*/
?>
<?php
if($currentTime <= $TotalTime){
?>
<p style='color:silver;text-align:center;'><?php echo $this->__('Click After Item Received'); ?></p>
<?php } ?>
</p>
<?php } ?>
<?php } ?>
<?php if($order->getStatus()=='complete') {?>
<label for="name" class="rightgapeditheadedit">
<div class="status" style="background-color:green"><?php echo $this->__('Item Delivered'); ?></div></label>
<p style='color:silver;text-align:center;'><?php
if ($order->hasInvoices()) {
$invoice = $order->prepareInvoice();
$invoice->register();
//$invoice->setEmailSent(true);
$invoice->save();
//$invoice->sendEmail();
$invoiceID = $invoice->getId();
?>
<?php
/*
(2014-01-07 AM) disable till further notice
Print Invoice
*/
?>
<?php if($currentTime <= $TotalTime){
?>
<p style='color:silver;text-align:center;'><?php echo $this->__('Click After Item Received'); ?></p>
<?php } ?>
<?php } ?></p>
<?php } ?>
</p>
<?php //} ?>
</th>
</tr>
<?php
}else { }
}
?>
</tbody>
</table>
</div>
<div class="review">
<h4 colspan="2" class="headingbg"><?php echo $this->__('Latest Comments & Reviews'); ?></h4>
<table class="reviewtable">
<?php
$c=0;$cc=0;$r=0;
// prefix checking and execute code
$productget="select entity_pk_value from ".$mysqlprefix."review ORDER BY created_at DESC";
$ownerread = Mage::getSingleton('core/resource')->getConnection('core_read');
$q5=0;
foreach($ownerread->fetchAll($productget) as $value){
$storepro[$q5]=$value['entity_pk_value'];
$q5++;
}
$listingpro = array_unique($storepro);
foreach($listingpro as $q2){
$allpro=Mage::getModel('catalog/product')->load($q2);
$owner=Mage::getSingleton('customer/session')->getCustomer()->getEntityid();
$ownerconnection = Mage::getSingleton('core/resource')->getConnection('core_read');
// prefix checking and execute code
$cusresult=$ownerconnection->query("SELECT * FROM ".$mysqlprefix."marketplacepartner_entity_data where userid='".Mage::getSingleton('customer/session')->getCustomer()->getEntityid()."' and sku='".$allpro['sku']."'");
$ownerkey=$cusresult->fetch();
if($allpro['sku']==$ownerkey['sku']){
$ownerread = Mage::getSingleton('core/resource')->getConnection('core_read');
// mysql prefix checking and execute code
$ownerreadresulting=$ownerread->query("select * from ".$mysqlprefix."review where entity_pk_value ='".$allpro['entity_id']."' ORDER BY created_at DESC");
$ownerget=$ownerreadresulting->fetch();
// prefix checking and execute code
$ownerreviewresulting=$ownerread->query("select * from ".$mysqlprefix."review_detail where review_id ='".$ownerget['review_id']."' ORDER BY review_id DESC");
$ownerreviewget=$ownerreviewresulting->fetch();
// here i code for mysql prefix checking and execute code
$ratdatasql="select rating_summary from ".$mysqlprefix."review_entity_summary where entity_pk_value='".$allpro['entity_id']."' ORDER BY primary_id DESC";
$ownerrateresult=$ownerread->query($ratdatasql);
$ownerrateresulting=$ownerrateresult->fetch();
if((gettype($ownerreviewget)=='array')&& (gettype($ownerrateresulting)=='array')){
if(($c==0)||($c==1)){?>
<tr class="ex2">
<th class="reviewtablethleft">
<?php
$detail=$ownerreviewget['title'];
$nickname=$ownerreviewget['nickname'];
$status_id=$ownerget['status_id'];
$created_at=$ownerget['created_at'];
$rating_summary=$ownerrateresulting['rating_summary'];
?>
<div class="ratingslider-box"><div class="rating" style="width:<?php echo ceil($rating_summary);?>%;"></div></div>
<?php $productcity=Mage::getModel('catalog/product')->load($allpro['entity_id']); ?>
<p class="rightgapeditheadedit" style="margin: 5px 0 10px 6px;float: left;"><?php echo $this->__('Product') ?> : </p>
<p class="textcolorproalter"><?php echo $productcity['name']; ?></p>
<p class="rightgapeditheadedit" style="margin: 0 0 10px 6px;float: left;"><?php echo $this->__('Comment By') ?>: </p>
<p class="textcolorproalter"><?php echo $nickname; ?></p>
<p class="rightgapeditheadedit" style="margin: 0 0 10px 6px;float: left;"> </p>
<p class="textcolorproalter1"><?php echo $detail; ?></p>
</th>
<th class="reviewtablethright">
<br><br>
<?php if($status_id==1){?>
<p class="statusapp"><?php echo $this->__('Approved'); ?></p>
<?php } else{ ?>
<p class="statussunapp"><?php echo $this->__('Unapproved'); ?></p>
<?php }?>
<br>
<p class="rightgapeditheadedit" style="margin:0 0 10px 37%;float: left;"><?php echo $this->__('Review On') ?> : </p>
<p class="textcolorpro"> <?php echo trim($created_at); ?></p>
<?php $c++;?>
</th>
</tr>
<?php }
}
$r++;
}
}?>
</table>
</div>
<br>
<?php
/*(2014-01-07 AM) disabled till further notice
<div class="example-plot" id="chart2"></div>
*/
?>
</div>
<div class="button-set buttonarea">
<p class="headingbackindex">
« <?php echo $this->__('Back') ?>
</p>
</div>
</div>
<?php
/*(2014-01-07 AM) disabled till further notice
<script class="code" type="text/javascript" language="javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
var line2 = [['1/1/<?php echo date('Y');?>', <?php if($aa<=0){ echo 0; } else { echo $aa; }?>], ['2/1/<?php echo date('Y');?>', <?php if($bb<=0){ echo 0; } else { echo $bb; }?>], ['3/1/<?php echo date('Y');?>',<?php if($cc<=0){ echo 0; } else { echo $cc; }?>], ['4/1/<?php echo date('Y');?>',<?php if($dd<=0){ echo 0; } else { echo $dd; }?>], ['5/1/<?php echo date('Y');?>',<?php if($ee<=0){ echo 0; } else { echo $ee; }?>], ['6/1/<?php echo date('Y');?>', <?php if($ff<=0){ echo 0; } else { echo $ff; }?>], ['7/1/<?php echo date('Y');?>', <?php if($gg<=0){ echo 0; } else { echo $gg; }?>], ['8/1/<?php echo date('Y');?>', <?php if($hh<=0){ echo 0; } else { echo $hh; }?>], ['9/1/<?php echo date('Y');?>', <?php if($ii<=0){ echo 0; } else { echo $ii; }?>], ['10/1/<?php echo date('Y');?>', <?php if($jj<=0){ echo 0; } else { echo $jj; }?>], ['11/1/<?php echo date('Y');?>', <?php if($kk<=0){ echo 0; } else { echo $kk; }?>], ['12/1/<?php echo date('Y');?>', <?php if($ll<=0){ echo 0; } else { echo $ll; }?>]];
var plot2 = jQuery.jqplot('chart2', [line2], {
axes: {
xaxis: {
renderer: jQuery.jqplot.DateAxisRenderer,
label: '<?php echo $this->__("Month"); ?>',
labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
tickOptions: {angle: 30}
},
yaxis: {
label: '<?php echo $this->__("Money") ?>',
labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer
}
}
});
});
</script>
*/
?>
<?php }else{
echo "<h2 style='color:#ff0000;font-weight:600'>".$this->__('FOR BECOME SELLER CONTACT TO ADMIN..')."</h2>";
}?>
please note that this code is not mine. I just have to deal with it.. -.-

The question has been answered by the support team of the modules developers. the reason for the not working inline translation was an error in a java script.
the fix looks like this:
<script class="code" type="text/javascript" language="javascript">
$wk_jq=jQuery.noConflict();
(function($wk_jq){
jQuery(document).ready(function(){
var line2 = [['1/1/<?php echo date('Y');?>', <?php if($aa<=0){ echo 0; } else { echo $aa; }?>], ['2/1/<?php echo date('Y');?>', <?php if($bb<=0){ echo 0; } else { echo $bb; }?>], ['3/1/<?php echo date('Y');?>',<?php if($cc<=0){ echo 0; } else { echo $cc; }?>], ['4/1/<?php echo date('Y');?>',<?php if($dd<=0){ echo 0; } else { echo $dd; }?>], ['5/1/<?php echo date('Y');?>',<?php if($ee<=0){ echo 0; } else { echo $ee; }?>], ['6/1/<?php echo date('Y');?>', <?php if($ff<=0){ echo 0; } else { echo $ff; }?>], ['7/1/<?php echo date('Y');?>', <?php if($gg<=0){ echo 0; } else { echo $gg; }?>], ['8/1/<?php echo date('Y');?>', <?php if($hh<=0){ echo 0; } else { echo $hh; }?>], ['9/1/<?php echo date('Y');?>', <?php if($ii<=0){ echo 0; } else { echo $ii; }?>], ['10/1/<?php echo date('Y');?>', <?php if($jj<=0){ echo 0; } else { echo $jj; }?>], ['11/1/<?php echo date('Y');?>', <?php if($kk<=0){ echo 0; } else { echo $kk; }?>], ['12/1/<?php echo date('Y');?>', <?php if($ll<=0){ echo 0; } else { echo $ll; }?>]];
var plot2 = jQuery.jqplot('chart2', [line2], {
axes: {
xaxis: {
renderer: jQuery.jqplot.DateAxisRenderer,
label: '<?php echo $this->__("Month"); ?>',
labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
tickOptions: {angle: 30}
},
yaxis: {
label: '<?php echo $this->__("Money") ?>',
labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer
}
}
});
});
})($wk_jq);
</script>

Related

How to use different price.phtml file for different views?

I want to use custom new_price.phtml file for New Products block and price.phtml for all product view.I ahve seen some examples but as i am very new so i don't know how to implement thrm.
Can anyone tell me the proper steps for this.
Below is the Code for new.phtml.
<?php
// some helpers
$_helper = $this->helper('catalog/output');
$storeId = Mage::app()->getStore()->getId();
$catalog = $this->getLayout()->createBlock('catalog/product_list')->setStoreId($storeId);
$productCount = $this->getData('num_products');
?>
<?php
$visibility = array(
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
);
$collection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->setStoreId($storeId)
->addStoreFilter($storeId)
->distinct(true)
//->addAttributeToFilter('visibility', $visibility)
// ->addFieldToFilter('qty', array('gteq' => 1))
// ->addAttributeToFilter('is_in_stock',0)
//->addOrderedQty()
->setOrder('entity_id', 'desc')
->setPageSize($productCount);
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
/* To display product by category id */
if($categoryId=$this->getData('category_id')){
$category = Mage::getModel('catalog/category')->load($categoryId);
$collection->addCategoryFilter($category);
}
?>
<?php // if no products are currently sell, display some text
if (!$collection->count()) :
?>
<p class="note-msg"><?php echo $this->__('There are no products sell at the moment.') ?></p>
<?php else : ?>
<div class="products_slider">
<div class="product-title pro-name">
<span class=""><?php echo $this->__('New Products') ?></span>
</div> <!--product-title-->
<a id="products_slider_prev1" class="jcarousel-prev-horizontal" href="javascript:void(0)"></a>
<a id="products_slider_next1" class="jcarousel-next-horizontal" href="javascript:void(0)"></a>
<!-- BEGIN SLIDER CONTAINER -->
<div class="slider-container">
<div class=" jcarousel-skin-tango">
<div class="jcarousel-container jcarousel-container-horizontal" style="position: relative; display: block;">
<div class="jcarousel-clip jcarousel-clip-horizontal" style="overflow: hidden; position: relative;">
<ul class="products-grid-home jcarousel-list jcarousel-list-horizontal" id="products_slider1" style="overflow: hidden; position: relative; top: 0px; margin: 0px; padding: 0px; left: 0px; width: 2970px;">
<?php
$_collectionSize = $collection->count();
$_columnCount = 4;
$i = 0;
$v8=1;
foreach ($collection as $_product) :
$_product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($_product->getId());
?>
<?php if ($i++%$_columnCount==0): ?>
<?php endif ?>
<li class="jcarousel-item jcarousel-item-horizontal jcarousel-item-1 jcarousel-item-1-horizontal<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>" style="float: left; list-style: none outside none;">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
<?php //echo $this->helper('vistasettings')->getLabel($_product); ?>
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(228,319); ?>" class="small-image" width="228" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php /*?> <?php $product = Mage::getModel('catalog/product')->load($_product->getId());
foreach ($product->getMediaGalleryImages() as $image) {
?>
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $image->getFile())->resize(228, 319); ?>" class="thumbnail" width="228" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>"/>
<?php } ?><?php */?>
</a>
<script type="text/javascript">
/* jQuery(document).ready(function() {
jQuery("#various8<?php echo $v8; ?>").fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'onClosed' : function() { }
});
});*/
</script>
<!-- -->
<!-- POP UP --><div style="display: none;"><div id="inline8<?php echo $v8; ?>" class="info-box">
<div class="product-view">
<div class="product-essential">
<div class="product-img-box">
<div class="product-image">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class ="cloud-zoom" id="zoom1" rel="adjustX:10, adjustY:-2, zoomWidth:400, zoomHeight:400">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(260,260); ?>" width="260" height="260" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
</a>
</div> <!--product-image-->
<div class="more-images">
<div class="more-views">
<div class="more-views thumbnailscroller carousel">
<div style="overflow: hidden; position: relative;" class="thumbnail-viewport">
<ul style="width: 1200%; transition-duration: 0s; transform: translate3d(0px, 0px, 0px);" id="thumbscroller<?php echo $v8; ?>" class="thumbscroller slides">
<?php $product = Mage::getModel('catalog/product')->load($_product->getId());
foreach ($product->getMediaGalleryImages() as $image) : ?>
<li style="width: 100px; float: left; display: block;">
<a href="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $image->getFile()); ?>" class="cloud-zoom-gallery" rel="useZoom: 'zoom1', smallImage: '<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $image->getFile())->resize(260,260); ?>' ">
<img class="zoom-tiny-image" src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $image->getFile())->resize(80, 80); ?>" width="80" height="80" alt=""/>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<ul class="thumbnail-direction-nav"><li><?php echo $this->__('Previous');?></li>
<li><?php echo $this->__('Next');?></li></ul>
</div><!--thumbnailscroller carousel-->
</div><!--more-views-->
<script type="text/javascript">
$mtkb(window).load(function(){
$mtkb('.thumbnailscroller').flexslider({
namespace: "thumbnail-",
animation: "slide",
animationLoop: true,
itemWidth: 250,
itemMargin: 0,
slideshow: true,
minItems: 1,
maxItems: 1,
directionNav: true,
controlNav: false,
move: 1,
touch: true,
});
});
</script>
</div><!--more-images-->
</div> <!--product-img-box-->
<div class="product-shop">
<div class="product-name">
<h1><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
<?php echo $this->htmlEscape($_product->getName()); ?>
</a>
</h1>
</div> <!--product-name-->
<div class="short-description"><?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?></div>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="add-to-box">
<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<?php if(!$_product->isGrouped()): ?>
<div class="add-to-cart">
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty:') ?>" class="input-text qty" />
<button class="button-arrow button-up" type="button"><?php echo $this->__('Increase');?></button>
<button class="button-arrow button-down" type="button"><?php echo $this->__('Decrease');?></button>
</div> <!--add-to-cart-->
<?php endif; ?>
<div class="add-to-cart">
<?php if($_product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="this.form.submit()"><span><?php echo $this->__('Add to Cart') ?></span></button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
</div><!-- add-to-cart-->
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><?php echo $this->__('Add to wishlist');?></li>
<?php endif; ?>
<?php /*?> <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><span class="separator">|</span><?php echo $this->__('Add to compare');?></li>
<?php endif; ?><?php */?>
</ul>
<span class="email-friend"><a class="button link-friend" href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>" title="<?php echo $this->__('Email to a Friend') ?>"><?php echo $this->__('Email to a Friend') ?></a></span>
</form>
</div> <!--add-to-box-->
</div> <!--product-shop-->
</div> <!--product-essential-->
</div> <!--product-view-->
</div></div> <!-- End POP UP-->
<!-- BEGIN PROD IMAGE DETAIL -->
<div class="prod_image_detail">
<div class="inner">
<a class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php //echo $this->htmlEscape($_product->getName()) ?>
<?php $prod_name = $this->htmlEscape($_product->getName()) ;
/*if(strlen($prod_name) > 20) {echo substr($prod_name,0,20)."...";}else {echo $prod_name;}*/echo $prod_name;?></a>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php echo $this->getPriceHtml($_product, true) ?>
</div>
<div class="actions">
<?php if($_product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<span class="add-to-links"> <?php if ($this->helper('wishlist')->isAllow()) : ?>
<?php echo $this->__('Add to wishlist');?>
<?php endif; ?>
<?php /*?> <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<?php echo $this->__('Add to compare');?>
<?php endif; ?><?php */?> </span><!--add-to-links-->
</div> <!--actions-->
</div> <!--prod_image_detail-->
</li>
<?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
<?php endif ?>
<?php $v8++; ?>
<?php endforeach ?>
</ul>
</div> <!--jcarousel-clip jcarousel-clip-horizontal-->
</div> <!--jcarousel-container jcarousel-container-horizontal-->
</div> <!-- jcarousel-skin-tango-->
</div> <!--slider-container-->
</div> <!--products_slider-->
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<script type="text/javascript">
jQuery(document).ready(function($) {
var jwidth=$('.products-grid-home').width();
function mycarousel_initCallback(carousel) {
$('#products_slider_next1').bind('click', function(event) {
carousel.next();
if(jwidth==2800){
return false;
}
});
$('#products_slider_prev1').bind('click', function(event) {
carousel.prev();
return false;
});
};
/*$('#products_slider1').jcarousel({
scroll:1,
visible:4,
setupCallback: scrollCheck,
initCallback: mycarousel_initCallback,
buttonNextHTML: null,
itemFallbackDimension:240,
buttonPrevHTML: null,
animation: {
duration: 500,
easing: 'linear',
complete: function() {
}
}
});*/
$('#products_slider1').jcarousel({
scroll: 1,
initCallback:mycarousel_initCallback,
buttonNextHTML: null,
buttonPrevHTML: null
});
function scrollCheck(carousel) {
if (carousel.options.size <= carousel.options.visible) {
// If there is enough room to display all available items, then disable scrolling
carousel.stopAuto();
}
}
});
</script>
<?php endif ?>
I am very new on Magento.
Can anyone tell me the steps to go this?
You can specify it in the backend on the design tab of the product. if you want to do it programmatically, please precise your question with the way you import products...

Magento - Controller to Ajax Estimate Shipping: Load Block and display phtml

I copied estimatePostAction and made estimateAjaxPostAction (overriding core - I did not hack the core). The controller action works as well (class Mage_Checkout_CartController).
Now I want to get/create a block for replacing shipping block after estimate shipping with ajax. I tried this:
public function estimateAjaxPostAction()
{
$country = (string) $this->getRequest()->getParam('country_id');
$postcode = (string) $this->getRequest()->getParam('estimate_postcode');
$city = (string) $this->getRequest()->getParam('estimate_city');
$regionId = (string) $this->getRequest()->getParam('region_id');
$region = (string) $this->getRequest()->getParam('region');
$this->_getQuote()->getShippingAddress()
->setCountryId($country)
->setCity($city)
->setPostcode($postcode)
->setRegionId($regionId)
->setRegion($region)
->setCollectShippingRates(true);
$this->_getQuote()->save();
//$this->_goBack();
$this->loadLayout();
$block = $this->getLayout()->createBlock('Mage_Checkout_Block_Cart_Shipping','checkout.cart.shipping.ajax',array('template' => 'checkout/cart/shipping.phtml'));
if($block) {
$response = array();
$response['shipping'] = $block->toHtml();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
}
}
The block checkout.cart.shipping.ajax was created. But toHtml() returns nothing.
My JSON returns:
{"shipping":""}
Why toHtml method doesn't work?
Edit: My block code (checkout/cart/shipping.phtml)
<?php /** #var $this Mage_Checkout_Block_Cart_Shipping */ ?>
<div class="row contem-shipping">
<div class="col-xs-10 shipping">
<div class="text-ship">
<h2><?php echo $this->__('Calcular o frete:') ?></h2>
<p><?php echo $this->__('Insira o CEP do endereço<br />no campo ao lado.') ?></p>
</div>
<div class="shipping-form">
<form action="<?php echo $this->getUrl('checkout/cart/estimatePost') ?>" method="post" id="shipping-zip-form">
<ul class="form-list">
<li class="no-display">
<div class="input-box">
<?php echo Mage::getBlockSingleton('directory/data')->getCountryHtmlSelect($this->getEstimateCountryId()) ?>
</div>
</li>
<?php if($this->getStateActive()): ?>
<li>
<label for="region_id"<?php if ($this->isStateProvinceRequired()) echo ' class="required"' ?>><?php if ($this->isStateProvinceRequired()) echo '<em>*</em>' ?><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" style="display:none;"<?php echo ($this->isStateProvinceRequired() ? ' class="validate-select"' : '') ?>>
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
</select>
<script type="text/javascript">
//<![CDATA[
$('region_id').setAttribute('defaultValue', "<?php echo $this->getEstimateRegionId() ?>");
//]]>
</script>
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getEstimateRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
</div>
</li>
<?php endif; ?>
<?php if($this->getCityActive()): ?>
<li>
<label for="city"<?php if ($this->isCityRequired()) echo ' class="required"' ?>><?php if ($this->isCityRequired()) echo '<em>*</em>' ?><?php echo $this->__('City') ?></label>
<div class="input-box">
<input class="input-text<?php if ($this->isCityRequired()):?> required-entry<?php endif;?>" id="city" type="text" name="estimate_city" value="<?php echo $this->escapeHtml($this->getEstimateCity()) ?>" />
</div>
</li>
<?php endif; ?>
<li>
<div class="input-box">
<input class="input-text validate-postcode<?php if ($this->isZipCodeRequired()):?> required-entry<?php endif;?>" type="text" id="postcode" name="estimate_postcode" value="<?php echo $this->escapeHtml($this->getEstimatePostcode()) ?>" />
</div>
</li>
</ul>
<div class="buttons-set">
<button id="button-cep" style="width: 100px;" type="button" title="<?php echo $this->__('Get a Quote') ?>" onclick="calculaFreteAjax(jQuery('#postcode').val()); return false;" class="btn btn-2 btn-2a"><?php echo $this->__('Get a Quote') ?></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
//]]>
</script>
<?php $_shippingRateGroups = $this->getEstimateRates(); ?>
<?php if ($_shippingRateGroups): ?>
<form id="co-shipping-method-form" action="<?php echo $this->getUrl('checkout/cart/estimateUpdatePost') ?>">
<dl class="sp-methods">
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
<dt><?php echo $this->escapeHtml($this->getCarrierName($code)) ?></dt>
<dd>
<ul>
<?php foreach ($_rates as $_rate): ?>
<li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"';?>>
<?php if ($_rate->getErrorMessage()): ?>
<?php echo $this->escapeHtml($_rate->getErrorMessage()) ?>
<?php else: ?>
<input name="estimate_method" type="radio" value="<?php echo $this->escapeHtml($_rate->getCode()) ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio" />
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $this->escapeHtml($_rate->getMethodTitle()) ?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</label>
<?php endif ?>
</li>
<?php endforeach; ?>
</ul>
</dd>
<?php endforeach; ?>
</dl>
</form>
<?php endif; ?>
<script type="text/javascript">
//<![CDATA[
var coShippingMethodForm = new VarienForm('shipping-zip-form');
var countriesWithOptionalZip = <?php echo $this->helper('directory')->getCountriesWithOptionalZip(true) ?>;
coShippingMethodForm.submit = function () {
var country = $F('country');
var optionalZip = false;
for (i=0; i < countriesWithOptionalZip.length; i++) {
if (countriesWithOptionalZip[i] == country) {
optionalZip = true;
}
}
if (optionalZip) {
$('postcode').removeClassName('required-entry');
}
else {
$('postcode').addClassName('required-entry');
}
return VarienForm.prototype.submit.bind(coShippingMethodForm)();
}
//]]>
</script>
</div>
</div>
<div class="col-xs-6">
<?php
$totalItemsInCart = Mage::helper('checkout/cart')->getItemsCount(); //total items in cart
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
$subtotal = $totals["subtotal"]->getValue(); //Subtotal value
$grandtotal = $totals["grand_total"]->getValue(); //Grandtotal value
if(isset($totals['discount']) && $totals['discount']->getValue()) {
$discount = $totals['discount']->getValue(); //Discount value if applied
} else {
$discount = '';
}
$shipping = Mage::helper('checkout')->getQuote()->getShippingAddress()->getData();
$tax = $shipping["shipping_amount"];
/*if( $totals["tax"]->getValue()) {
$tax = $totals["tax"]->getValue(); //Tax value if present
} else {
$tax = '';
}*/
?>
<table class="totals-cart">
<tr>
<td class="total-tile">
Subtotal do pedido:
</td>
<td class="total-price">
<?php echo Mage::helper('core')->currency($subtotal, true, false); ?>
</td>
</tr>
<tr>
<td class="total-tile">
Frete:
</td>
<td class="total-price">
<?php echo Mage::helper('core')->currency($tax, true, false); ?>
</td>
</tr>
<?php if ($discount):?>
<tr>
<td class="total-tile">
Desconto:
</td>
<td class="total-price">
<?php echo Mage::helper('core')->currency($discount, true, false); ?>
</td>
</tr>
<?php endif;?>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-16">
<div class="grand-total">
<p class="text">Total:</p>
<p class="price"><?php echo Mage::helper('core')->currency($grandtotal, true, false);?></p>
</div>
</div>
</div>
<script type="text/javascript">
function calculaFreteAjax(cep) {
jQuery('.contem-shipping .shipping').html('<span class="remove-frete" style="display: block; margin: 0 auto; width: 20px;" id="login-please-wait"><img src="http://sites.xpd.com.br/cpaps/skin/frontend/xpd/default/images/opc-ajax-loader.gif" class="v-middle" alt=""/></span>');
var param = {'country_id': 'BR','estimate_postcode': cep};
console.log(param);
jQuery.ajax({
type: "GET",
url: '<?php echo Mage::getBaseUrl().'checkout/cart/estimateAjaxPost/'; ?>', //My Custom Controller
data: param,
success: function(response) {
response = jQuery.parseJSON(response);
if(response.shipping) {
jQuery('.contem-shipping').parent().html(response.shipping);
}
else {
alert('Falha ao calcular o frete. Tente novamente.');
}
}
});
jQuery('#co-shipping-method-form dd input.radio').click(function(){
//I will submit the shipping method selected
});
}
</script>
Denis... I have modify code please check
public function estimateAjaxPostAction()
{
$country = (string) $this->getRequest()->getParam('country_id');
$postcode = (string) $this->getRequest()->getParam('estimate_postcode');
$city = (string) $this->getRequest()->getParam('estimate_city');
$regionId = (string) $this->getRequest()->getParam('region_id');
$region = (string) $this->getRequest()->getParam('region');
$this->_getQuote()->getShippingAddress()
->setCountryId($country)
->setCity($city)
->setPostcode($postcode)
->setRegionId($regionId)
->setRegion($region)
->setCollectShippingRates(true);
$this->_getQuote()->save();
$response = array();
$response['shipping']=$this->eastmatesajax();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
}
protected function eastmatesajax()
{
$layout=$this->getLayout();
$layout->getMessagesBlock()->setMessages(Mage::getSingleton('checkout/session')->getMessages(true),Mage::getSingleton('catalog/session')->getMessages(true));
$block = $this->getLayout()->createBlock('checkout/cart_shipping')->setTemplate( 'checkout/cart/shipping.phtml');
return $block->toHtml();
}
Updated block issue solved using $this->_getQuote()->collectTotals(); before $this->_getQuote()->save();

Implementing Lightbox in Magento

I already have an existing page which I'm trying to turn into a Magento website. One the pages I'm working on makes use of Lightbox. I tried including the lightbox file through Design in the CMS Page. Same for content but it didn't work there. Is there any way I can include the lightbox javascript from the previous website without having to touch the xml, html and php files? How do I make the lightbox work on the website?
You can always add a javascript file to the page's head by adding the following to the design tab of your CMS page (note that the path is relative to the root js directory). However, if you plan on using lightbox on multiple pages, this would not be the preferred method because you'd have to copy this into the design tab of every page you needed it on.
<reference name="head">
<action method="addJs"><js>custom/lightboxjs</js></action>
</reference>
View.PHTML
<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<script type="text/javascript">
var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<?php $config = Mage::getStoreConfig('mdloption/product-type-option'); ?>
<?php if($config['product-view-option'] !=2 && $config['product-view-option'] !=3): ?>
<?php $classnNum ='span9'?>
<?php else:?>
<?php $classnNum ='f-fix'?>
<?php endif; ?>
<?php if($config['product-view-option']==3):?>
<?php $classnNum2 = 'left-carousel'?>
<?php endif; ?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div class="product-view <?php echo $classnNum; ?>">
<!--<a class="prePage" href="<?php //echo $_SESSION['core']['last_url'];?>"><?php //echo $this->__('Return to Previous Page')?></a>-->
<!--Prev/Next Code Start-->
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
$prev_url = $next_url = $url = $_product->getProductUrl();
if ($this->helper('catalog/data')->getCategory()) {
$category = $this->helper('catalog/data')->getCategory();
} else {
$_ccats = $this->helper('catalog/data')->getProduct()->getCategoryIds();
$category = Mage::getModel('catalog/category')->load($_ccats[0]);
}
$children = $category->getProductCollection();
$_count = is_array($children) ? count($children) : $children->count();
if ($_count) {
foreach ($children as $product) {
$plist[] = $product->getId();
}
$current_pid = $this->helper('catalog/data')->getProduct()->getId();
$curpos = array_search($current_pid, $plist);
$previd = isset($plist[$curpos+1])? $plist[$curpos+1] : $current_pid;
$product = Mage::getModel('catalog/product')->load($previd);
$prevpos = $curpos;
while (!$product->isVisibleInCatalog()) {
$prevpos += 1;
$nextid = isset($plist[$prevpos])? $plist[$prevpos] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
}
$prev_url = $product->getProductUrl();
$nextid = isset($plist[$curpos-1])? $plist[$curpos-1] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
$nextpos = $curpos;
while (!$product->isVisibleInCatalog()) {
$nextpos -= 1;
$nextid = isset($plist[$nextpos])? $plist[$nextpos] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
}
$next_url = $product->getProductUrl();
}
?>
<!--Prev/Next Code End-->
<div class="product-essential">
<div class="product-img-box span6 <?php echo $classnNum2;?>"> <?php echo $this->getChildHtml('media') ?> </div>
<div class="productDetailBox span6">
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<div class="no-display">
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
<input type="hidden" name="related_product" id="related-products-field_1" value="" />
</div>
<div class="product-shop">
<div class="product_left f-fix">
<div class="nextPre">
<!-- <a rel="tooltip" data-placement="left" title="<?php echo $this->__('No Products')?>" class="prod-prev disable" href="JavaScript:void(0);">Prev</a>
<a rel="tooltip" data-placement="right" title="<?php echo $this->__('No Products')?>" class="prod-next disable" href="JavaScript:void(0);">NEXT</a>-->
<?php if ($url <> $prev_url):?>
<a class="prod-next" rel="tooltip" data-placement="right" title="<?php echo $this->__('Volgende product')?>" href="<?php echo $prev_url; ?>"><i class="fa fa-angle-right"></i></a>
<?php endif; ?>
<?php if ($url <> $next_url):?>
<a rel="tooltip" data-placement="left" title="<?php echo $this->__('Vorige product')?>" class="prod-prev" href="<?php echo $next_url; ?>"><i class="fa fa-angle-left"></i></a>
<?php endif; ?>
</div>
<div class="product-name">
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
</div>
<div class="review"> <?php echo $this->getReviewsSummaryHtml($_product, false, true)?> </div>
<div class="stock_box">
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('<i class="fa fa-check-circle"></i> Beschikbaar') ?></span></p>
<?php else: ?>
<p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('<i class="fa fa-times-circle"></i> Verkocht') ?></span></p>
<?php endif; ?>
</div>
<?php if ($_product->getShortDescription()):?>
<div class="short-description">
<div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
</div>
<?php endif;?>
<div class="pro-left">
<div class="add_to_cart">
<?php if (!$this->hasOptions()):?>
<div class="add-to-box">
<?php if($_product->isSaleable()): ?>
<?php echo $this->getChildHtml('addtocart') ?>
<?php endif; ?>
<div class="price_box">
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml()?>
</div>
</div>
<?php endif; ?>
<?php echo $this->getChildHtml('other');?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
<?php endif;?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<div class="price_box">
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml()?>
</div>
<?php endif;?>
<div class="clear"></div>
</div>
<div class="f-fix">
<?php echo $this->getChildHtml('extrahint') ?>
<?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
<?php endif; ?>
<?php echo $this->getChildHtml('addto') ?>
<?php if ($this->canEmailToFriend()): ?>
<p class="email-friend"><a rel="tooltip" data-placement="top" title="<?php echo $this->__('Email to a Friend') ?>" href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><i class="fa fa-envelope"></i> <?php echo $this->__('Email to a Friend') ?></a></p>
<?php endif; ?>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4f74bbe87b978120"></script>
<!-- AddThis Button END -->
</div>
</div>
</div>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('static_links')->toHtml() ?>
</div>
</form>
</div>
<div class="product-collateral" id="tabs">
<?php echo $this->getChildHtml('info_tabs') ?>
</div>
</div>
</div>
<?php if($config['product-view-option'] !=2 && $config['product-view-option'] !=3): ?>
<div class="product_right span3">
<?php $config = Mage::getStoreConfig('mdloption/upsellsetting'); ?>
<?php if($config['upsellblocks']==1):?>
<?php echo $this->getChildHtml('upsell_products'); ?>
<?php elseif($config['upsellblocks']==2):?>
<?php if($_product->getUpsellProducts()): ?>
<?php echo $this->getChildHtml('upsell_products'); ?>
<?php else: ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('productBanner')->toHtml() ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product_custom_block')->toHtml() ?>
<?php endif ?>
<?php elseif($config['upsellblocks']==3):?>
<?php echo $this->getChildHtml('upsell_products'); ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('productBanner')->toHtml() ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product_custom_block')->toHtml() ?>
<?php endif;?>
<div class="staticSidebar">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product-static-box')->toHtml() ?>
</div>
</div>
<?php endif; ?>
<?php //echo $this->getChildHtml('upsell_products'); ?>
<?php //echo $this->getChildHtml('related'); ?>
<script type="text/javascript">
//<![CDATA[
var productAddToCartForm = new VarienForm('product_addtocart_form');
productAddToCartForm.submit = function(button, url) {
if (this.validator.validate()) {
var form = this.form;
var oldUrl = form.action;
if (url) {
form.action = url;
}
var e = null;
try {
this.form.submit();
} catch (e) {
}
this.form.action = oldUrl;
if (e) {
throw e;
}
if (button && button != 'undefined') {
button.disabled = true;
}
}
}.bind(productAddToCartForm);
productAddToCartForm.submitLight = function(button, url){
if(this.validator) {
var nv = Validation.methods;
delete Validation.methods['required-entry'];
delete Validation.methods['validate-one-required'];
delete Validation.methods['validate-one-required-by-name'];
// Remove custom datetime validators
for (var methodName in Validation.methods) {
if (methodName.match(/^validate-datetime-.*/i)) {
delete Validation.methods[methodName];
}
}
if (this.validator.validate()) {
if (url) {
this.form.action = url;
}
this.form.submit();
}
Object.extend(Validation.methods, nv);
}
}.bind(productAddToCartForm);
//]]>
</script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("a[rel=example_group]").fancybox({
hideOnContentClick : true,
showNavArrows : false,
arrows : false,
showTitle : false,
scrolling : 'no',
'transitionIn' : 'none',
'transitionOut' : 'none',
'titlePosition' : 'over',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' ' + title : '') + '</span>';
}
});
});
</script>

change text on select radio

Hi i need some help on this script. i need to show the sku on productcode div on select the radio label.
is some in line $j("input#attribute and input:radio that i cannot fix
Practically this get the sku on selectable size or color.
php code
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<div class="input-box">
<?php $configs = $this->getRegularConfig()?>
<?php foreach($configs['attributes'] as $config):?>
<?php foreach($config['options'] as $value):?>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<label class="label-radio-configurable" id="<?php echo (float)$value['price'] + (float) $_product->getPrice();?>">
<input type="radio" name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]"
id="attribute<?php echo $_attribute->getAttributeId() ?>"
class="validate-custom-configurable"
value="<?php echo $value['id']?>"/>
<?php echo $value['label']?> (+ $<?php printf("%.2f", $value['price'])?>)
</label>
<?php endforeach;?>
<?php endforeach;?>
</dd>
</div>
<?php endforeach; ?>
</dl>
<?php endif;?>
JS Script
<div id="productcode"></div>
<?php
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
?>
<script type="text/javascript">
var Skus =new Array();
<?php
$count = 1;
$itemId = array();
foreach($col as $simple_product){
$itemId[] = array($simple_product->getSelectLabel() => $simple_product->getSku());
}
foreach($itemId as $val){
foreach($val as $k => $v){
echo 'Skus['.$count.'] = "'.$v.'";'. "\n";
$count++;
}
};
?>
$j(document).ready(function(){
$j("#productcode").html("Code: " +Skus[1]);
$j("input#attribute<?php echo $_attribute->getAttributeId() ?>").change(function(){
var position = $j("#attribute<?php echo $_attribute->getAttributeId() ?> input").index($j("#attribute<?php echo $_attribute->getAttributeId() ?> input:radio));
$j("#productcode").html(Skus[position] ? "Code: " +Skus[position] : "Code: " +Skus[1]);
});
});
</script>
$j(document).ready(function()
Instead of j Use jQuery
Because of jquery conflict
also
please write the below code in your jquery file
jQuery.noConflict();

How to insert custom option into Magento theme product view template?

I've created a custom Magento theme for a jewelry store and for a ring that I've
added as a sample product, I created a custom option for ring size (a SELECT field).
How do I insert just that custom option above the 'add to cart' button in my
product view.phtml template file?
Here is the page: http://s1.mynewsitereview.com/fire-opal-ring.html
And here is my view.phtml code:
<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<script type="text/javascript">
var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div class="product-view">
<div class="product-essential">
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<div class="no-display">
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
<input type="hidden" name="related_product" id="related-products-field" value="" />
</div>
<div class="product-img-box">
<?php echo $this->getChildHtml('media') ?>
</div>
<div class="product-shop">
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
<?php if ($_product->getShortDescription()):?>
<p><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></p>
<?php endif;?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getChildHtml('extrahint') ?>
<p class="email-friend">
<?php if ($this->canEmailToFriend()): ?>
<?php echo $this->__('Email to a Friend') ?><br>
<?php endif; ?>
<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
</p>
<div class="add-to-box">
<?php if($_product->isSaleable()): ?>
<?php echo $this->getChildHtml('addtocart') ?>
<div><?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
<?php endif; ?>
<?php endif; ?>
<?php echo $this->getChildHtml('addto') ?>
</div>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var productAddToCartForm = new VarienForm('product_addtocart_form');
productAddToCartForm.submit = function(button, url) {
if (this.validator.validate()) {
var form = this.form;
var oldUrl = form.action;
if (url) {
form.action = url;
}
var e = null;
try {
this.form.submit();
} catch (e) {
}
this.form.action = oldUrl;
if (e) {
throw e;
}
if (button && button != 'undefined') {
button.disabled = true;
}
}
}.bind(productAddToCartForm);
productAddToCartForm.submitLight = function(button, url){
if(this.validator) {
var nv = Validation.methods;
delete Validation.methods['required-entry'];
delete Validation.methods['validate-one-required'];
delete Validation.methods['validate-one-required-by-name'];
// Remove custom datetime validators
for (var methodName in Validation.methods) {
if (methodName.match(/^validate-datetime-.*/i)) {
delete Validation.methods[methodName];
}
}
if (this.validator.validate()) {
if (url) {
this.form.action = url;
}
this.form.submit();
}
Object.extend(Validation.methods, nv);
}
}.bind(productAddToCartForm);
//]]>
</script>
</div>
<div class="product-collateral">
<?php echo $this->getChildHtml('other');?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
<?php endif;?>
</div>
</div>
Add this code
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<?php endif;?>
in your view.phtml file just above the
<?php echo $this->getChildHtml('addtocart') ?>

Resources