Skip to content

Instantly share code, notes, and snippets.

@deivisonarthur
Created October 29, 2012 12:59
Show Gist options
  • Select an option

  • Save deivisonarthur/3973392 to your computer and use it in GitHub Desktop.

Select an option

Save deivisonarthur/3973392 to your computer and use it in GitHub Desktop.
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
<p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
<?php else: ?>
<dl class="sp-methods">
<?php
/*Prazo de entrega ###################################################################################################################*/
/*Prazo de entrega ###################################################################################################################*/
/*Prazo de entrega ###################################################################################################################*/
/*FUNÇÃO DE REMOÇÃO DE ACENTOS DAS DESCRIPTION E KEYS*/
function removeacentos1($str, $enc = "UTF-8"){
$acentos = array(
'A' => '/&Agrave;|&Aacute;|&Acirc;|&Atilde;|&Auml;|&Aring;/',
'a' => '/&agrave;|&aacute;|&acirc;|&atilde;|&auml;|&aring;/',
'C' => '/&Ccedil;/',
'c' => '/&ccedil;/',
'E' => '/&Egrave;|&Eacute;|&Ecirc;|&Euml;/',
'e' => '/&egrave;|&eacute;|&ecirc;|&euml;/',
'I' => '/&Igrave;|&Iacute;|&Icirc;|&Iuml;/',
'i' => '/&igrave;|&iacute;|&icirc;|&iuml;/',
'N' => '/&Ntilde;/',
'n' => '/&ntilde;/',
'O' => '/&Ograve;|&Oacute;|&Ocirc;|&Otilde;|&Ouml;/',
'o' => '/&ograve;|&oacute;|&ocirc;|&otilde;|&ouml;/',
'U' => '/&Ugrave;|&Uacute;|&Ucirc;|&Uuml;/',
'u' => '/&ugrave;|&uacute;|&ucirc;|&uuml;/',
'Y' => '/&Yacute;/',
'y' => '/&yacute;|&yuml;/',
'a.' => '/&ordf;/',
'o.' => '/&ordm;/');
@$palavra = preg_replace($acentos, array_keys($acentos),htmlentities($str,ENT_NOQUOTES, $enc));
$palavra = strtoupper($palavra);
$palavra = trim($palavra);
$palavra = eregi_replace("([ ]{1,})", ' ', $palavra);
return $palavra;
}
$session = Mage::getSingleton('checkout/session');
$prazo11 = 0;
$prazoReal11 = 0;
$qntProd3 = 0;
$fornecedor = 0;
$qntProd = 0;
//$naoesaocarlos = 1;
foreach ($session->getQuote()->getAllItems() as $item) {
$prazo11 = Mage::getModel('catalog/product')->load($item->getProduct()->getId())->getAttributeText('prazoentrega');
if($prazo11 > $prazoReal11){
$prazoReal11 = $prazo11;
$qntProd += 1;
};
$fornecedor = 0;
$fornecedor = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku() )->getAttributeText('fornecedor');
$fornecedor = removeacentos1($fornecedor);
if($fornecedor != "SAO CARLOS"){
$naoesaocarlos = 1;
};
};
$getcep3 = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getPostcode();
$getcep3 = preg_replace("/([0-9]{5})-?([0-9]{3})/", "\\1", $getcep3);
$getcepEx3 = explode("-", $getcep3);
//echo $getcepEx3[0]."<br /><br />";
switch (true) {
case ( $getcepEx3[0] > 69900 and $getcepEx3[0] < 69999 ): //AC
case ( $getcepEx3[0] > 69000 and $getcepEx3[0] < 69299 ): //AM
case ( $getcepEx3[0] > 78900 and $getcepEx3[0] < 78999 ): //RO
case ( $getcepEx3[0] > 69300 and $getcepEx3[0] < 69899 ): //RR
case ( $getcepEx3[0] > 66000 and $getcepEx3[0] < 68899 ): //PA
case ( $getcepEx3[0] > 68900 and $getcepEx3[0] < 68999 ): //AP
case ( $getcepEx3[0] > 77000 and $getcepEx3[0] < 77999 ): //TO
$regiao3 = 20;
//echo "Norte<br />";
break;
case ( $getcepEx3[0] > 78000 and $getcepEx3[0] < 78899 ): //MT
case ( $getcepEx3[0] > 79000 and $getcepEx3[0] < 79999 ): //MS
case ( $getcepEx3[0] > 74000 and $getcepEx3[0] < 76999 ): //GO
case ( $getcepEx3[0] > 70000 and $getcepEx3[0] < 73699 ): //DF
$regiao3 = 8;
//echo "Centro-Oeste<br />";
break;
case ( $getcepEx3[0] > 65000 and $getcepEx3[0] < 65999 ): //MA
case ( $getcepEx3[0] > 64000 and $getcepEx3[0] < 64099 ): //PI
case ( $getcepEx3[0] > 40000 and $getcepEx3[0] < 48999 ): //BA
case ( $getcepEx3[0] > 60000 and $getcepEx3[0] < 63999 ): //CE
case ( $getcepEx3[0] > 59000 and $getcepEx3[0] < 59999 ): //RN
case ( $getcepEx3[0] > 58000 and $getcepEx3[0] < 58999 ): //PB
case ( $getcepEx3[0] > 50000 and $getcepEx3[0] < 56999 ): //PE
case ( $getcepEx3[0] > 57000 and $getcepEx3[0] < 57999 ): //AL
case ( $getcepEx3[0] > 49000 and $getcepEx3[0] < 49999 ): //SE
$regiao3 = 14;
//echo "Nordeste<br />";
break;
case ( $getcepEx3[0] > 01000 and $getcepEx3[0] < 19999 ): //SP
case ( $getcepEx3[0] > 30000 and $getcepEx3[0] < 39999 ): //SP
case ( $getcepEx3[0] > 20000 and $getcepEx3[0] < 28999 ): //RJ
case ( $getcepEx3[0] > 29000 and $getcepEx3[0] < 29999 ): //RJ
$regiao3 = 4;
//echo "Sudeste<br />";
break;
case ( $getcepEx3[0] > 80000 and $getcepEx3[0] < 87999 ): //PR
case ( $getcepEx3[0] > 90000 and $getcepEx3[0] < 99999 ): //RS
case ( $getcepEx3[0] > 88000 and $getcepEx3[0] < 89999 ): //SC
$regiao3 = 4;
//echo "Sul<br />";
break;
default:
$regiao3 = 20;
//echo "Nao-Definido<br />";
break;
};
//echo $prazoReal1;
//echo $regiao3;
$totalprazo = $prazoReal11 + $regiao3;
/*
echo $prazoReal11.'<br />';
echo $regiao3.'<br />';
echo $totalprazo.'<br />';
*/
//imprime tempo real
if( isset($getcepEx3[0]) ){
echo "<br /><label style='padding-top: 0px !important; text-align: center; width: 100%; height: auto'>Prazo de entrega do pedido: &nbsp;<strong style=' color: #C32633'>".$totalprazo." dias &uacute;teis</strong></label><br /><br />";
$ozarp = base64_encode($totalprazo);
$_SESSION["ozarp"] = $ozarp;
setcookie("ozarp",$ozarp,time()+3600);
//Mage::getSingleton('core/session')->setPrazoMagento('$prazoReal1');
//echo Mage::getSingleton('core/session')->getPrazoMagento();
//Mage::getSingleton('core/session')->setPrazoMagento();
};
?>
<?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
<?php //echo $code;
//Pedro Teixeira modulo correios ###########################################################################
//Pedro Teixeira modulo correios ###########################################################################
//Pedro Teixeira modulo correios ###########################################################################
//echo $code;
if( $code == 'MultiFrete' ) :
$exibe = "nao";
?>
<dt><?php echo $this->getCarrierName($code) ?></dt>
<dd>
<ul>
<?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
<li>
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages"><li class="error-msg"><ul><li><?php echo $_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" checked="checked" 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 endif; ?>
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_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 endif; ?>
<?php
//Pedro Teixeira modulo correios ###########################################################################
//Pedro Teixeira modulo correios ###########################################################################
//Pedro Teixeira modulo correios ###########################################################################
//echo $code;
if( $code == 'flatrate' and !isset( $exibe ) ) :
?>
<dt><?php echo $this->getCarrierName($code) ?></dt>
<dd>
<ul>
<?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
<li>
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages"><li class="error-msg"><ul><li><?php echo $_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" checked="checked" 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 endif; ?>
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_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 endif; ?>
<?php //echo $code;
//freeshipping ###########################################################################
//freeshipping ###########################################################################
//freeshipping ###########################################################################
//echo $code;
$fretegratis = 1;
if( $code == 'freeshipping' && $regiao3 == '4' && $naoesaocarlos < 1 || $code == 'freeshipping' && $regiao3 == '3' && $naoesaocarlos < 1 || $code == 'freeshipping' && $fretegratis == '1' ) :
?>
<br /><br />
<dt><?php echo $this->getCarrierName($code) ?></dt>
<dd>
<ul>
<?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
<li>
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages"><li class="error-msg"><ul><li><?php echo $_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: ?>
<?php
if( $naoesaocarlos == "1" && $code == 'freeshipping'){
echo "
<br />
<h3 style='color: #C32633; text-decoration: blink;'>N&atilde;o est&aacute; habilitada a promo&ccedil;&atilde;o (Frete Gr&aacute;tis para Produtos S&atilde;o Carlos) para essa compra.</h3>
";
}else{
echo "
<br />
<h3 style='color: #C32633;'>Foi habilitada a promo&ccedil;&atilde;o (Frete Gr&aacute;tis para Produtos S&atilde;o Carlos) para essa compra, pois seus produtos s&atilde;o somente do fornecedor S&atilde;o Carlos.</h3>
";
$checkd = 'checked="checked"';
};
if($code == 'freeshipping' && $naoesaocarlos ){
echo "
<br />
<h3>*OBS: Somente poder&aacute; utilizar a forma de envio por Frete Gr&aacute;tis, nos casos abaixo! Caso contr&aacute;rio a sua compra poder&aacute; ser cancelada!</h3>
<ul style='color: #888888; font-size: 13px; padding: 15px; list-style: circle !important;'>
<li>Retirada do produto em nossa distribuidora</li>
<li>Compra somente de produtos do fornecedor S&atilde;o Carlos</li>
<!--<li>Combinado por ambas as partes previamente por email</li>-->
</ul>
<br />
";
};
?>
<!-- -->
<input name="shipping_method" <?=$checkd?> 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 endif; ?>
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_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 endif; ?>
<?php endforeach; ?>
</dl>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment