Version Notes
This version does not remove some links like "change shippment method" even if there is nothing to change.
This behaviour is kept as original on purpose - to avoid complicated changes in template files and thus escape from any involvement into the store design process.
Download this release
Release Info
| Developer | Michael Zakharov |
| Extension | PTech_CheckoutPatch |
| Version | 1.1.0 |
| Comparing to | |
| See all releases | |
Version 1.1.0
- app/code/community/PTech/CheckoutPatch/Block/Onepage/Shipping/Method.php +51 -0
- app/code/community/PTech/CheckoutPatch/Helper/Data.php +49 -0
- app/code/community/PTech/CheckoutPatch/controllers/Checkout/MultishippingController.php +78 -0
- app/code/community/PTech/CheckoutPatch/controllers/Checkout/OnepageController.php +204 -0
- app/code/community/PTech/CheckoutPatch/etc/config.xml +67 -0
- app/etc/modules/PTech_CheckoutPatch.xml +9 -0
- package.xml +29 -0
app/code/community/PTech/CheckoutPatch/Block/Onepage/Shipping/Method.php
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Posting Technically
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is available at http://opensource.org/licenses/osl-3.0.php
|
| 9 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
| 10 |
+
* to info@posting-technically.com so we can send you a copy immediately.
|
| 11 |
+
*
|
| 12 |
+
* @category PTech
|
| 13 |
+
* @package PTech_CheckoutPatch
|
| 14 |
+
* @copyright Copyright (c) 2011 Posting Technically. (http://www.posting-technically.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Extend Mage_Checkout_Block_Onepage_Shipping_Method functionality
|
| 20 |
+
* Shipment method selection step is not created in openpage checkout if isShow returns false
|
| 21 |
+
* @see Mage_Checkout_Block_Onepage_Shipping_Method
|
| 22 |
+
*/
|
| 23 |
+
class PTech_CheckoutPatch_Block_Onepage_Shipping_Method extends Mage_Checkout_Block_Onepage_Shipping_Method
|
| 24 |
+
{
|
| 25 |
+
/**
|
| 26 |
+
* Retrieve is allow and show block
|
| 27 |
+
* Return true iff the store has at least one active paid shipping method
|
| 28 |
+
* @return bool
|
| 29 |
+
*/
|
| 30 |
+
public function isShow()
|
| 31 |
+
{
|
| 32 |
+
// googlecheckout is a "virtual" shipping method that is always active
|
| 33 |
+
// regardless of configuration. Magento CE has no means to switch it off without
|
| 34 |
+
// system.xml tweaking.
|
| 35 |
+
$freeNames = array('freeshipping', 'googlecheckout');
|
| 36 |
+
|
| 37 |
+
if (parent::isShow()) {
|
| 38 |
+
$allCarriers = Mage::getStoreConfig('carriers');
|
| 39 |
+
foreach ($allCarriers as $name => $carrier) {
|
| 40 |
+
if(in_array($name, $freeNames)) {
|
| 41 |
+
continue;
|
| 42 |
+
}
|
| 43 |
+
if($carrier['active']) {
|
| 44 |
+
return true;
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
return false;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
}
|
app/code/community/PTech/CheckoutPatch/Helper/Data.php
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Posting Technically
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is available at http://opensource.org/licenses/osl-3.0.php
|
| 9 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
| 10 |
+
* to info@posting-technically.com so we can send you a copy immediately.
|
| 11 |
+
*
|
| 12 |
+
* @category PTech
|
| 13 |
+
* @package PTech_CheckoutPatch
|
| 14 |
+
* @copyright Copyright (c) 2011 Posting Technically. (http://www.posting-technically.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Checkout patch default helper
|
| 20 |
+
*
|
| 21 |
+
* @author Michael Zakharov <trapman.hunt@gmail.com>
|
| 22 |
+
*/
|
| 23 |
+
class PTech_CheckoutPatch_Helper_Data extends Mage_Checkout_Helper_Data
|
| 24 |
+
{
|
| 25 |
+
/**
|
| 26 |
+
* Check if address has a shipping method and the method is free shipping
|
| 27 |
+
* @param \Mage_Sales_Model_Quote_Address $address
|
| 28 |
+
* @return bool
|
| 29 |
+
*/
|
| 30 |
+
public function hasFreeShippingOnly(Mage_Sales_Model_Quote_Address $address)
|
| 31 |
+
{
|
| 32 |
+
if(empty($address)) {
|
| 33 |
+
return false;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
$rates = $address->getAllShippingRates();
|
| 37 |
+
if(empty($rates)) { // Does not have any shipment methods, let original code handle it.
|
| 38 |
+
return false;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
foreach ($rates as $rate) {
|
| 42 |
+
if ($rate['carrier'] != 'freeshipping') {
|
| 43 |
+
return false;
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
return true;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
}
|
app/code/community/PTech/CheckoutPatch/controllers/Checkout/MultishippingController.php
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Posting Technically
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is available at http://opensource.org/licenses/osl-3.0.php
|
| 9 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
| 10 |
+
* to info@posting-technically.com so we can send you a copy immediately.
|
| 11 |
+
*
|
| 12 |
+
* @category PTech
|
| 13 |
+
* @package PTech_CheckoutPatch
|
| 14 |
+
* @copyright Copyright (c) 2011 Posting Technically. (http://www.posting-technically.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
require_once 'Mage/Checkout/controllers/MultishippingController.php';
|
| 19 |
+
/**
|
| 20 |
+
* Fix for standard controller: bypass shipment step if it may not be displayed
|
| 21 |
+
* for non-virtual products.
|
| 22 |
+
* The step is skipped iff:
|
| 23 |
+
* - a store has only free shipment method allowed
|
| 24 |
+
* - all shipment addresses are eligible for the free shipment delivery
|
| 25 |
+
*/
|
| 26 |
+
class PTech_CheckoutPatch_Checkout_MultishippingController extends Mage_Checkout_MultishippingController
|
| 27 |
+
{
|
| 28 |
+
/**
|
| 29 |
+
* Multishipping checkout shipping information page
|
| 30 |
+
*/
|
| 31 |
+
public function shippingAction()
|
| 32 |
+
{
|
| 33 |
+
// parent copy paste - need it because of the returns in the middle
|
| 34 |
+
if (!$this->_validateMinimumAmount()) {
|
| 35 |
+
return;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
if (!$this->_getState()->getCompleteStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_SELECT_ADDRESSES)) {
|
| 39 |
+
$this->_redirect('*/*/addresses');
|
| 40 |
+
return $this;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
$this->_getState()->setActiveStep(
|
| 44 |
+
Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
|
| 45 |
+
);
|
| 46 |
+
$this->loadLayout();
|
| 47 |
+
$this->_initLayoutMessages('customer/session');
|
| 48 |
+
$this->_initLayoutMessages('checkout/session');
|
| 49 |
+
$this->renderLayout();
|
| 50 |
+
// end of parent copy paste
|
| 51 |
+
|
| 52 |
+
$addresses = $this->_getCheckout()->getQuote()->getAllShippingAddresses();
|
| 53 |
+
$freeMethods = $this->_getFreeCarrierMethods($addresses);
|
| 54 |
+
|
| 55 |
+
if(count($addresses) == count($freeMethods)) { // All addresses are eligible for free shipment
|
| 56 |
+
$this->getRequest()->setPost('shipping_method', $freeMethods);
|
| 57 |
+
$this->shippingPostAction();
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* Return null if at least one non-free shipment method is available
|
| 64 |
+
* @param $addreses
|
| 65 |
+
* @return array
|
| 66 |
+
*/
|
| 67 |
+
private function _getFreeCarrierMethods($addreses)
|
| 68 |
+
{
|
| 69 |
+
$methods = array();
|
| 70 |
+
foreach ($addreses as $address) {
|
| 71 |
+
if(Mage::helper('ptech_checkout')->hasFreeShippingOnly($address)) {
|
| 72 |
+
$methods[$address->getId()] = 'freeshipping_freeshipping';
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
return $methods;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
}
|
app/code/community/PTech/CheckoutPatch/controllers/Checkout/OnepageController.php
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Posting Technically
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is available at http://opensource.org/licenses/osl-3.0.php
|
| 9 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
| 10 |
+
* to info@posting-technically.com so we can send you a copy immediately.
|
| 11 |
+
*
|
| 12 |
+
* @category PTech
|
| 13 |
+
* @package PTech_CheckoutPatch
|
| 14 |
+
* @copyright Copyright (c) 2011 Posting Technically. (http://www.posting-technically.com)
|
| 15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
require_once 'Mage/Checkout/controllers/OnepageController.php';
|
| 19 |
+
/**
|
| 20 |
+
* Fix for standard controller: bypass shipment step if it may not be displayed
|
| 21 |
+
* for non-virtual products.
|
| 22 |
+
* The step is skipped iff:
|
| 23 |
+
* - a store has only free shipment method allowed
|
| 24 |
+
* - the shipment address is eligible for the free shipment delivery
|
| 25 |
+
* If address is not eligible a message box will be displayed
|
| 26 |
+
* @see PTech_CheckoutPatch_Block_Onepage_Shipping_Method
|
| 27 |
+
*/
|
| 28 |
+
class PTech_CheckoutPatch_Checkout_OnepageController extends Mage_Checkout_OnepageController
|
| 29 |
+
{
|
| 30 |
+
/**
|
| 31 |
+
* save checkout billing address
|
| 32 |
+
*/
|
| 33 |
+
public function saveBillingAction()
|
| 34 |
+
{
|
| 35 |
+
if ($this->_expireAjax()) {
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
if ($this->getRequest()->isPost()) {
|
| 39 |
+
// $postData = $this->getRequest()->getPost('billing', array());
|
| 40 |
+
// $data = $this->_filterPostData($postData);
|
| 41 |
+
$data = $this->getRequest()->getPost('billing', array());
|
| 42 |
+
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
|
| 43 |
+
|
| 44 |
+
if (isset($data['email'])) {
|
| 45 |
+
$data['email'] = trim($data['email']);
|
| 46 |
+
}
|
| 47 |
+
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);
|
| 48 |
+
|
| 49 |
+
if (!isset($result['error'])) {
|
| 50 |
+
/* check quote for virtual */
|
| 51 |
+
if ($this->getOnepage()->getQuote()->isVirtual()) {
|
| 52 |
+
$result['goto_section'] = 'payment';
|
| 53 |
+
$result['update_section'] = array(
|
| 54 |
+
'name' => 'payment-method',
|
| 55 |
+
'html' => $this->_getPaymentMethodsHtml()
|
| 56 |
+
);
|
| 57 |
+
} elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
|
| 58 |
+
// Fix
|
| 59 |
+
$result = $this->_fixForFreeShipment($result);
|
| 60 |
+
// end of fix
|
| 61 |
+
if (!isset($result['error'])) {
|
| 62 |
+
$result['allow_sections'] = array('shipping');
|
| 63 |
+
$result['duplicateBillingInfo'] = 'true';
|
| 64 |
+
}
|
| 65 |
+
} else {
|
| 66 |
+
$result['goto_section'] = 'shipping';
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Shipping address save action
|
| 76 |
+
*/
|
| 77 |
+
public function saveShippingAction()
|
| 78 |
+
{
|
| 79 |
+
if ($this->_expireAjax()) {
|
| 80 |
+
return;
|
| 81 |
+
}
|
| 82 |
+
if ($this->getRequest()->isPost()) {
|
| 83 |
+
$data = $this->getRequest()->getPost('shipping', array());
|
| 84 |
+
$customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
|
| 85 |
+
$result = $this->getOnepage()->saveShipping($data, $customerAddressId);
|
| 86 |
+
|
| 87 |
+
if (!isset($result['error'])) {
|
| 88 |
+
/**
|
| 89 |
+
* Fix: goto shipment method selection step if it is visible
|
| 90 |
+
*/
|
| 91 |
+
$result = $this->_fixForFreeShipment($result);
|
| 92 |
+
}
|
| 93 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* Shipping method save action
|
| 99 |
+
*/
|
| 100 |
+
public function saveShippingMethodAction()
|
| 101 |
+
{
|
| 102 |
+
if ($this->_expireAjax()) {
|
| 103 |
+
return;
|
| 104 |
+
}
|
| 105 |
+
if ($this->getRequest()->isPost()) {
|
| 106 |
+
/**
|
| 107 |
+
* Fix: set shipping method even if step is skipped
|
| 108 |
+
*/
|
| 109 |
+
if ($this->_hasFreeShippingOnly()) {
|
| 110 |
+
$data = $this->getRequest()->getPost('shipping_method', 'freeshipping_freeshipping');
|
| 111 |
+
} else {
|
| 112 |
+
$data = $this->getRequest()->getPost('shipping_method', '');
|
| 113 |
+
}
|
| 114 |
+
/**
|
| 115 |
+
* End of fix
|
| 116 |
+
*/
|
| 117 |
+
$result = $this->getOnepage()->saveShippingMethod($data);
|
| 118 |
+
/*
|
| 119 |
+
$result will have error data if shipping method is empty
|
| 120 |
+
*/
|
| 121 |
+
if(!$result) {
|
| 122 |
+
Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method',
|
| 123 |
+
array('request'=>$this->getRequest(),
|
| 124 |
+
'quote'=>$this->getOnepage()->getQuote()));
|
| 125 |
+
$this->getOnepage()->getQuote()->collectTotals();
|
| 126 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
| 127 |
+
|
| 128 |
+
$result['goto_section'] = 'payment';
|
| 129 |
+
$result['update_section'] = array(
|
| 130 |
+
'name' => 'payment-method',
|
| 131 |
+
'html' => $this->_getPaymentMethodsHtml()
|
| 132 |
+
);
|
| 133 |
+
}
|
| 134 |
+
$this->getOnepage()->getQuote()->collectTotals()->save();
|
| 135 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* Create order action
|
| 141 |
+
*/
|
| 142 |
+
public function saveOrderAction()
|
| 143 |
+
{
|
| 144 |
+
if ($this->_expireAjax()) {
|
| 145 |
+
return;
|
| 146 |
+
}
|
| 147 |
+
/**
|
| 148 |
+
* Fix: set shipping method in the quote even if step is skipped
|
| 149 |
+
*/
|
| 150 |
+
if ($this->_hasFreeShippingOnly()) {
|
| 151 |
+
$this->saveShippingMethodAction();
|
| 152 |
+
}
|
| 153 |
+
/**
|
| 154 |
+
* End of fix
|
| 155 |
+
*/
|
| 156 |
+
parent::saveOrderAction();
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* Check if shipment to quote address is freeshipping only
|
| 161 |
+
* @return bool
|
| 162 |
+
*/
|
| 163 |
+
private function _hasFreeShippingOnly()
|
| 164 |
+
{
|
| 165 |
+
$rates = $this->getOnepage()->getQuote()->getShippingAddress()->getAllShippingRates();
|
| 166 |
+
return (count($rates) == 1) && ($rates[0]->getCarrier() == 'freeshipping');
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* Fix: goto shipment method selection step if it is visible
|
| 171 |
+
* Note: If a shop has free shipment only, the shipping method block may be invisible.
|
| 172 |
+
* Thus, if we have no shipping methods available at this point (e.g. shipping address does not
|
| 173 |
+
* qualify) we have no place to notify customer about this problem and message box will be used instead
|
| 174 |
+
* @param $result
|
| 175 |
+
* @return array
|
| 176 |
+
*/
|
| 177 |
+
private function _fixForFreeShipment($result)
|
| 178 |
+
{
|
| 179 |
+
$shipRates = $this->getOnepage()->getQuote()->getShippingAddress()->getAllShippingRates();
|
| 180 |
+
if(empty($shipRates)) {
|
| 181 |
+
$result = array('error' => 1,
|
| 182 |
+
'message' => Mage::helper('checkout')->__('Shipping selection is not applicable.')
|
| 183 |
+
);
|
| 184 |
+
return $result;
|
| 185 |
+
}
|
| 186 |
+
if ((count($shipRates) == 1) && ($shipRates[0]->getCarrier() == 'freeshipping')) { // Shipment is invisible, goto payment step
|
| 187 |
+
$this->saveShippingMethodAction();
|
| 188 |
+
$result['goto_section'] = 'payment';
|
| 189 |
+
$result['update_section'] = array(
|
| 190 |
+
'name' => 'payment-method',
|
| 191 |
+
'html' => $this->_getPaymentMethodsHtml()
|
| 192 |
+
);
|
| 193 |
+
return $result;
|
| 194 |
+
} else {
|
| 195 |
+
$result['goto_section'] = 'shipping_method';
|
| 196 |
+
$result['update_section'] = array(
|
| 197 |
+
'name' => 'shipping-method',
|
| 198 |
+
'html' => $this->_getShippingMethodsHtml()
|
| 199 |
+
);
|
| 200 |
+
return $result;
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
}
|
app/code/community/PTech/CheckoutPatch/etc/config.xml
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Posting Technically
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is available at http://opensource.org/licenses/osl-3.0.php
|
| 10 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
| 11 |
+
* to info@posting-technically.com so we can send you a copy immediately.
|
| 12 |
+
*
|
| 13 |
+
* @category PTech
|
| 14 |
+
* @package PTech_CheckoutPatch
|
| 15 |
+
* @copyright Copyright (c) 2011 Posting Technically. (http://www.posting-technically.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
-->
|
| 19 |
+
<config>
|
| 20 |
+
<modules>
|
| 21 |
+
<PTech_CheckoutPatch>
|
| 22 |
+
<version>1.1.0</version>
|
| 23 |
+
</PTech_CheckoutPatch>
|
| 24 |
+
</modules>
|
| 25 |
+
<global>
|
| 26 |
+
<blocks>
|
| 27 |
+
<checkout>
|
| 28 |
+
<rewrite>
|
| 29 |
+
<onepage_shipping_method>PTech_CheckoutPatch_Block_Onepage_Shipping_Method</onepage_shipping_method>
|
| 30 |
+
</rewrite>
|
| 31 |
+
</checkout>
|
| 32 |
+
</blocks>
|
| 33 |
+
<helpers>
|
| 34 |
+
<ptech_checkout>
|
| 35 |
+
<class>PTech_CheckoutPatch_Helper</class>
|
| 36 |
+
</ptech_checkout>
|
| 37 |
+
</helpers>
|
| 38 |
+
<rewrite>
|
| 39 |
+
<PTech_CheckoutPatch_checkout_onepage>
|
| 40 |
+
<from><![CDATA[#^/checkout/onepage/#]]>
|
| 41 |
+
</from>
|
| 42 |
+
<to>/checkoutpatch/checkout_onepage/</to>
|
| 43 |
+
</PTech_CheckoutPatch_checkout_onepage>
|
| 44 |
+
<PTech_CheckoutPatch_checkout_multishipping>
|
| 45 |
+
<from><![CDATA[#^/checkout/multishipping/#]]>
|
| 46 |
+
</from>
|
| 47 |
+
<to>/checkoutpatch/checkout_multishipping/</to>
|
| 48 |
+
</PTech_CheckoutPatch_checkout_multishipping>
|
| 49 |
+
</rewrite>
|
| 50 |
+
<helpers>
|
| 51 |
+
<ptech_checkoutpatch>
|
| 52 |
+
<class>PTech_CheckoutPatch_Helper</class>
|
| 53 |
+
</ptech_checkoutpatch>
|
| 54 |
+
</helpers>
|
| 55 |
+
</global>
|
| 56 |
+
<frontend>
|
| 57 |
+
<routers>
|
| 58 |
+
<checkoutpatch>
|
| 59 |
+
<use>standard</use>
|
| 60 |
+
<args>
|
| 61 |
+
<module>PTech_CheckoutPatch</module>
|
| 62 |
+
<frontName>checkoutpatch</frontName>
|
| 63 |
+
</args>
|
| 64 |
+
</checkoutpatch>
|
| 65 |
+
</routers>
|
| 66 |
+
</frontend>
|
| 67 |
+
</config>
|
app/etc/modules/PTech_CheckoutPatch.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<PTech_CheckoutPatch>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</PTech_CheckoutPatch>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>PTech_CheckoutPatch</name>
|
| 4 |
+
<version>1.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL v 3.0)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>This extension modifies checkout process to step over shipment method selection if free shipment method is the only one available and valid. 
|
| 10 |
+
Both onepage and multishipping processes are affected.</summary>
|
| 11 |
+
<description>Extension modifies checkout process in the following way:
|
| 12 |
+

|
| 13 |
+
if free shipping is the only method avaliable in the store configuration, it removes shipment method selection step completely.
|
| 14 |
+

|
| 15 |
+
it finds all shipment methods that are avaliable for the selected shipment address and steps over shippment method selection if free shippment is the only method avaliable. 
|
| 16 |
+

|
| 17 |
+
For multishipping checkout this must be true for all addresses in checkout.
|
| 18 |
+

|
| 19 |
+
If free shipment is the only configured method and shipment address is not eligible for the free delivery, extension notifies the customer using a message box. </description>
|
| 20 |
+
<notes>This version does not remove some links like "change shippment method" even if there is nothing to change.
|
| 21 |
+
This behaviour is kept as original on purpose - to avoid complicated changes in template files and thus escape from any involvement into the store design process.
|
| 22 |
+
</notes>
|
| 23 |
+
<authors><author><name>Michael Zakharov</name><user>tms320c</user><email>trapman.hunt@gmail.com</email></author></authors>
|
| 24 |
+
<date>2011-11-16</date>
|
| 25 |
+
<time>10:12:26</time>
|
| 26 |
+
<contents><target name="magecommunity"><dir name="PTech"><dir name="CheckoutPatch"><dir name="Block"><dir name="Onepage"><dir name="Shipping"><file name="Method.php" hash="fb9b20c4562a9199a9585821769cc30b"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="627b69a44b673f51cf1e62594e1c5ee7"/></dir><dir name="controllers"><dir name="Checkout"><file name="MultishippingController.php" hash="886935b47232e1162e45fe4ca54f8412"/><file name="OnepageController.php" hash="330169980b559ae0a5c559a8b8a42a45"/></dir></dir><dir name="etc"><file name="config.xml" hash="890c09e291f7a9cab726e03d9b892f2f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PTech_CheckoutPatch.xml" hash="143dd08691743a1c512d2e76a7003324"/></dir></target></contents>
|
| 27 |
+
<compatible/>
|
| 28 |
+
<dependencies><required><php><min>5.2.0</min><max>5.3.8</max></php></required></dependencies>
|
| 29 |
+
</package>
|
