How to hide payment method on shopping cart price rules?
Another way to accomplish this would be to using an observer payment_method_is_active. See Disable payment options-only cash on delivery for particular product-magento
class Company_Module_Model_Observer
{
public function paymentMethodIsActive($observer)
{
$instance = $observer->getMethodInstance();
$result = $observer->getResult();
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
$grandtotal = round($totals["grand_total"]->getValue())
if ($instance->getCode() == "ccsave") {
if(1500 > $grandtotal && !Mage::app()->getStore()->isAdmin())
$result->isAvailable = false;
}
else{
$result->isAvailable = true;
}
}
}
}
Go into the
app/design/frontend/base/default/template/checkout/onepage/payment/methods.php
change your methods.php to this code
<?php
$methods = $this->getMethods();
$oneMethod = count($methods) <= 1;
?>
<?php if (empty($methods)): ?>
<dt>
<?php echo $this->__('No Payment Methods') ?>
</dt>
<?php else:
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
$grandtotal = round($totals["grand_total"]->getValue());
foreach ($methods as $_method):
$_code = $_method->getCode();
if($grandtotal > 1500)
{
?>
<dt>
<?php if(!$oneMethod): ?>
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
<?php $oneMethod = $_code; ?>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php
}
else
{
if($_code != 'ccsave')
{
?>
<dt>
<?php if(!$oneMethod): ?>
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
<?php $oneMethod = $_code; ?>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php
}
}
?>
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<dd>
<?php echo $html; ?>
</dd>
<?php endif; ?>
<?php endforeach;
endif;
?>
<?php echo $this->getChildChildHtml('additional'); ?>
<script type="text/javascript">
//<![CDATA[
<?php echo $this->getChildChildHtml('scripts'); ?>
payment.init();
<?php if (is_string($oneMethod)): ?>
payment.switchMethod('<?php echo $oneMethod ?>');
<?php endif; ?>
//]]>
</script>
EDIT:-
if you want to use this condition in model then go to the
app/code/core/mage/payment/helper/Data.php
Replace this function (getStoreMethods) with my code
public function getStoreMethods($store = null, $quote = null)
{
$res = array();
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
$grandtotal = round($totals["grand_total"]->getValue());
if($grandtotal > 1500)
{
foreach ($this->getPaymentMethods($store) as $code => $methodConfig) {
$prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/';
if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) {
continue;
}
$methodInstance = Mage::getModel($model);
if (!$methodInstance) {
continue;
}
$methodInstance->setStore($store);
if (!$methodInstance->isAvailable($quote)) {
/* if the payment method cannot be used at this time */
continue;
}
$sortOrder = (int)$methodInstance->getConfigData('sort_order', $store);
$methodInstance->setSortOrder($sortOrder);
$res[] = $methodInstance;
}
}
else
{
foreach ($this->getPaymentMethods($store) as $code => $methodConfig) {
if($code != 'ccsave')
{
$prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/';
if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) {
continue;
}
$methodInstance = Mage::getModel($model);
if (!$methodInstance) {
continue;
}
$methodInstance->setStore($store);
if (!$methodInstance->isAvailable($quote)) {
/* if the payment method cannot be used at this time */
continue;
}
$sortOrder = (int)$methodInstance->getConfigData('sort_order', $store);
$methodInstance->setSortOrder($sortOrder);
$res[] = $methodInstance;
}
}
}
usort($res, array($this, '_sortMethods'));
return $res;
}
Related
I need to implement shipping restriction based on the selected currency.
For example:
If people select / use US dollars to check out, their delivery address can only be in USA, and if people select GBP in currency drop down, their delivery address can only be in UK.
Anyone know how can I achieve that? I am a junior developer and this is my first Maganto project.
Here is my available.phtml file:
<?php $_shippingRateGroups = $this->getShippingRates(); ?>
<?php if (!$_shippingRateGroups): ?>
<p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
<?php else: ?>
<dl class="sp-methods">
<?php $shippingCodePrice = array(); ?>
<?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
<dt><?php echo $this->escapeHtml($this->getCarrierName($code)) ?></dt>
<dd>
<ul>
<?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
<?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
<li>
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages"><li class="error-msg"><ul><li><?php echo $this->escapeHtml($_rate->getErrorMessage()) ?></li></ul></li></ul>
<?php else: ?>
<?php if ($_sole) : ?>
<span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" /></span>
<?php else: ?>
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
<script type="text/javascript">
//<![CDATA[
lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
//]]>
</script>
<?php endif; ?>
<?php endif; ?>
<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>
<script type="text/javascript">
//<![CDATA[
<?php if (!empty($shippingCodePrice)): ?>
var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
<?php endif; ?>
$$('input[type="radio"][name="shipping_method"]').each(function(el){
Event.observe(el, 'click', function(){
if (el.checked == true) {
var getShippingCode = el.getValue();
<?php if (!empty($shippingCodePrice)): ?>
var newPrice = shippingCodePrice[getShippingCode];
if (!lastPrice) {
lastPrice = newPrice;
quoteBaseGrandTotal += newPrice;
}
if (newPrice != lastPrice) {
quoteBaseGrandTotal += (newPrice-lastPrice);
lastPrice = newPrice;
}
<?php endif; ?>
checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
return false;
}
});
});
//]]>
</script>
<?php endif; ?>
You can restrict the shipping methods according to the currency type. just go to the
app\design\frontend\base\default\template\checkout\onepage\shipping_method\available.phtml and get the currency by getting cart over here. And now by simple If/Else conditions according to the currency you can restrict the shipping methods.
This code displays all comments by all members. How can I make this only show comments that the current logged in user posted?
I know this is simple code but for the life of me I can not seem to get it.
The code listed below is the original code from the view.php file located in the guestbook block.
<?php $c = Page::getCurrentPage(); ?>
<h4 class="guestBook-title"><?php echo $controller->title?></h4>
<?php if($invalidIP) { ?>
<div class="ccm-error"><p><?php echo $invalidIP?></p></div>
<?php } ?>
<?php
$u = new User();
if (!$dateFormat) {
$dateFormat = t('M jS, Y');
}
$posts = $controller->getEntries();
$bp = $controller->getPermissionObject();
$dh = Loader::helper('date');
foreach($posts as $p) { ?>
<?php if($p['approved'] || $bp->canWrite()) { ?>
<div class="guestBook-entry<?php if ($c->getVersionObject()->getVersionAuthorUserName() == $u- >getUserName()) {?> authorPost <?php }?>">
<?php if($bp->canWrite()) { ?>
<div class="guestBook-manage-links">
<?php echo t('Edit')?> |
<?php echo t('Remove')?> |
<?php if($p['approved']) { ?>
<?php echo t('Un-Approve')?>
<?php } else { ?>
<?php echo t('Approve')?>
<?php } ?>
</div>
<?php } ?>
<div class="contentByLine">
<!---<?php echo t('Posted by')?>
<span class="userName">
<?php
if( intval($p['uID']) ){
$ui = UserInfo::getByID(intval($p['uID']));
if (is_object($ui)) {
echo $ui->getUserName();
}
}else echo $p['user_name'];
?>
</span>
<?php echo t('on')?>--->
<span class="contentDate">
<?php echo $dh->date($dateFormat,strtotime($p['entryDate']));?>
</span>
</div>
<?php echo nl2br($p['commentText'])?>
</div>
<?php } ?>
<?php }
if (isset($response)) { ?>
<?php echo $response?>
<?php } ?>
<?php if($controller->displayGuestBookForm) { ?>
<?php
if( $controller->authenticationRequired && !$u->isLoggedIn() ){ ?>
<div><?php echo t('You must be logged in for notes.')?> <?php echo t('Login')?> ยป</div>
<?php }else{ ?>
<a name="guestBookForm-<?php echo $controller->bID?>"></a>
<div id="guestBook-formBlock-<?php echo $controller->bID?>" class="guestBook-formBlock">
<!---<h5 class="guestBook-formBlock-title"><?php echo t('Leave a Reply')?></h5>--->
<form method="post" action="<?php echo $this->action('form_save_entry', '#guestBookForm-'.$controller->bID)?>">
<?php if(isset($Entry->entryID)) { ?>
<input type="hidden" name="entryID" value="<?php echo $Entry->entryID?>" />
<?php } ?>
<?php if(!$controller->authenticationRequired){ ?>
<label for="name"><?php echo t('Name')?>:</label><?php echo (isset($errors['name'])?"<span class=\"error\">".$errors['name']."</span>":"")?><br />
<input type="text" name="name" value="<?php echo $Entry->user_name ?>" /> <br />
<label for="email"><?php echo t('Email')?>:</label><?php echo (isset($errors['email'])?"<span class=\"error\">".$errors['email']."</span>":"")?><br />
<input type="email" name="email" value="<?php echo $Entry->user_email ?>" /> <span class="note">(<?php echo t('Your email will not be publicly displayed.')?>)</span> <br />
<?php } ?>
<?php echo (isset($errors['commentText'])?"<br /><span class=\"error\">".$errors['commentText']."</span>":"")?>
<textarea name="commentText"><?php echo $Entry->commentText ?></textarea><br />
<?php
if($controller->displayCaptcha) {
$captcha = Loader::helper('validation/captcha');
$captcha->label();
$captcha->showInput();
$captcha->display();
echo isset($errors['captcha'])?'<span class="error">' . $errors['captcha'] . '</span>':'';
}
?>
<br/><br/>
<input type="submit" name="Post Comment" value="<?php echo t('Save Note')?>" class="button"/>
</form>
</div>
<?php } ?>
Every $posts ($p) is an array. When you print the array you will notice the ID of the author is present in the array.
If you'd like to show only the comments of the logged in user, you should override the view.php and replace line number 16
<?php if($p['approved'] || $bp->canWrite()) { ?>
to
<?php if(($p['approved'] || $bp->canWrite()) && $u->getUserID() == $p['uID']) { ?>
When you've changed that line of code, a user should only see his/her comments and not the comment of someone else.
How to display all the categories in tree structure alike in a pop up window ie.) if i click the select category button in my page it should show the popup window with the tree
structured categories.i tried like this which will show all the categories in dropdown that does not look good
<?php
$categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter();
$allcatid = array();
$k=0;
foreach ($categories as $c) {
$allcatid[$k] = $c->getId();
$k++;
}
$finalcat=array_shift($allcatid);
$root= Mage::app()->getStore()->getRootCategoryId();
?>
<select id="category" class="myinput-text required-entry widthinput" name="category" >
<?php foreach($allcatid as $keycat){?>
<option value="<?php echo $keycat;?>"><?php echo Mage::getModel("catalog/category")->load($keycat)->getName(); ?></option>
<?php } ?>
This will help you to fetch you category tree
<?php
$rootcatId= Mage::app()->getStore()->getRootCategoryId();
$categories = Mage::getModel('catalog/category')->getCategories($rootcatId);
function get_categories($categories) {
$array= '<ul>';
foreach($categories as $category) {
$cat = Mage::getModel('catalog/category')->load($category->getId());
$count = $cat->getProductCount();
$array .= '<li>'.''. $category->getName() . "(".$count.")\n";
if($category->hasChildren()) {
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
$array .= get_categories($children);
}
$array .= '</li>';
}
return $array . '</ul>';
}
echo get_categories($categories); ?>
Output View
This code is included an end-level category with product count.
Step 1 Goto theme/layout/catalog.xml put this code in the file.
<reference name="left">
<block type="catalog/navigation" name="category_list_sidebar" template="catalog/navigation/categorymenu.phtml"/>
</reference>
Step 2 Goto theme/template/catalog/ and create navigation folder also create categorymenu.phtml file inside folder and put code into file.
<?php
$_helper = Mage::helper('catalog/category');
$_categories = $_helper->getStoreCategories();
$currentCategory = Mage::registry('current_category');
?>
<div class="block block-list block-categorys">
<div class="block-title">
<strong><span>Category</span></strong>
</div>
<div class="block-content">
<ul class="category_sub">
<?php
if (count($_categories) > 0){
global $index;
global $data;
foreach($_categories as $_category){
$check_child_class = check_child_par($_category->getId());
$collaps = ($check_child_class)? "<span class='show-cat'>+</span>" : "";
echo "<li class='".$check_child_class."'>";
echo "<a href='".$_helper->getCategoryUrl($_category)."'>".$_category->getName();
echo " (".product_count($_category->getId()).")";
echo "</a>".$collaps;
echo check_child($_category->getId());
echo "</li>";
}
}
?>
</ul>
</div>
</div>
<?php
function check_child($cid){
$_helper = Mage::helper('catalog/category');
$_subcategory = Mage::getModel('catalog/category')->load($cid);
$_subsubcategories = $_subcategory->getChildrenCategories();
if (count($_subsubcategories) > 0){
echo "<ul>";
foreach($_subsubcategories as $_subcate){
$check_child_class = check_child_par($_subcate->getId());
$collaps = ($check_child_class)? "<span class='show-cat'>+</span>" : "";
echo "<li class='".$check_child_class."'>";
echo "<a href='".$_helper->getCategoryUrl($_subcate)."'>".$_subcate->getName();
echo " (".product_count($_subcate->getId()).")";
echo "</a>".$collaps;
echo check_child($_subcate->getId());
echo "</li>";
}
echo "</ul>";
}else{
return "";
}
}
function check_child_par($cid){
$_subcat = Mage::getModel('catalog/category')->load($cid);
$_subsubcats = $_subcat->getChildrenCategories();
if (count($_subsubcats) > 0){
return "parent";
}else{
return "";
}
}
function product_count($cid){
$products_count = Mage::getModel('catalog/category')->load($cid)->getProductCount();
return $products_count;
}
?>
enter code here
<?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; ?>
this will fetch all catgory and sub category,,,hope this will help you
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>
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();