Desactivar todos los métodos de envío si está disponible el envío gratuíto en Magento

Al configurar nuestra tienda son muchos los que deciden activar el envío gratuito si se cumplen ciertas reglas en el carro (importe superior a una cantidad, envíos gratuitos a una zona, etc.). El problema viene cuando el usuario ha de elegir un método de envío, y entre ellos le aparece el gratuito. El cliente piensa, ¿por qué voy a elegir otro si me da a elegir uno gratuito?. No tengo muy claro si esto es un bug, es falta de criterio o simplemente un descuido, lo que si que sé es que esto se puede solucionar de forma rápida y sencilla. El método consiste en eliminar/ocultar el resto de métodos de envío si tenemos disponible el gratuito. Para ello, editamos el siguiente fichero:
  • app/design/frontend/TEMPLATE/default/template/checkout/onepage/shipping_method/available.php
Y el código debería quedar tal que así:
PHP:
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Academic Free License (AFL 3.0)
  8. * that is bundled with this package in the file LICENSE_AFL.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/afl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category design_default
  22. * @package Mage
  23. * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
  24. * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
  25. */
  26. ?>
  27. <?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
  28. <strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong>
  29. <?php else: ?>
  30. <dl class="shipment-methods">
  31. <?php $freeOnly = False; ?>
  32. <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
  33. <?php if ( $code == "freeshipping") {$freeOnly = True;}?>
  34. <?php endforeach; ?>
  35. <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
  36. <?php if (( $freeOnly == False) || ( ( $freeOnly == True ) && ( $code == "freeshipping" ) )): ?>
  37. <dt><?php echo $this->getCarrierName($code) ?></dt>
  38. <dd>
  39. <ul>
  40. <?php foreach ($_rates as $_rate): ?>
  41. <li>
  42. <?php if ($_rate->getErrorMessage()): ?>
  43. <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
  44. <?php else: ?>
  45. <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod() || $freeOnly == True ) echo ' checked="checked"' ?> />
  46. <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
  47. <strong>
  48. <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
  49. <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
  50.  
  51. <?php echo $_excl; ?>
  52. <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
  53. (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
  54. <?php endif; ?>
  55. </strong>
  56. </label>
  57. <?php endif ?>
  58. </li>
  59. <?php endforeach; ?>
  60. </ul>
  61. </dd>
  62. <?php endif ?>
  63. <?php endforeach; ?>
  64. </dl>
  65. <?php endif; ?>

La explicación de esto básicamente se reduce a realizar un bucle, mirar los métodos de envío disponibles y si aparece el método de envío gratuito desabilitamos el resto. NOTA: este método sirve para aquellos que uséis onepage checkout. El código original lo podéis encontrar aquí.
Compartir:
  • Print
  • Facebook
  • Twitter
  • Meneame
  • Google Bookmarks
  • del.icio.us
  • Digg

PROYECTOS RELACIONADOS


COMENTARIOS

Gracias por la aportación. Felicidades de nuevo por los contenidos y ánimo!


PARTICIPA EN LA CONVERSACIÓN

Introduce tu información personal o utiliza tu cuenta de twitter o facebook para acceder

   



CATEGORÍAS


C\ Trafalgar 13
46930 Quart de Poblet - Valencia - España

  • (+34) 961 139 313
  • info@onestic.com
  • (+34) 963 023 041
  • (+34) 622 858 391

HABLEMOS...

No dudes en ponerte en contacto con nosotros. Hablamos tranquilamente, te damos nuestra opinión sobre tu proyecto y decidimos cómo te podemos ayudar.

CONTACTO



SIGUÉNOSEN: