Skip to content

Instantly share code, notes, and snippets.

@coderbyheart
Created April 3, 2013 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderbyheart/5299787 to your computer and use it in GitHub Desktop.
Save coderbyheart/5299787 to your computer and use it in GitHub Desktop.
Idev OneStepCheckout 4.0.7 bug fixes

The patch fixes two bugs in Idev OneStepCheckout 4.0.7

Email address reported invalid for logged in users

If a user is logged in and no email address has been assigned to the billing address already, an error will be reported.

Optional regions not working for existing addresses

If an existing user selects one of his adresses, which has been created without a region the Mage_Sales_Model_Service_Quote will raise this as an error as regions cannot be made optional in the core.

--- app/code/local/Idev/OneStepCheckout/Block/Checkout.php.orig 2013-04-02 16:11:32.993889731 +0200
+++ app/code/local/Idev/OneStepCheckout/Block/Checkout.php 2013-04-02 16:11:37.447302998 +0200
@@ -364,6 +364,8 @@
if(isset($billing_data['email'])) {
$this->email = $billing_data['email'];
+ } else { // if no email adresse present use the email of the logged in user -- Markus Tacker <m@coderbyheart.de>
+ $billing_data['email'] = $this->email;
}
if(!$this->_isLoggedIn()){
@@ -402,6 +404,22 @@
$billingAddressId = $this->getRequest()->getPost('billing_address_id');
$customerAddressId = (!empty($billingAddressId)) ? $billingAddressId : false ;
+ // Region may be optional!
+ // If an existing user selects one of his adresses, which has been created without a region
+ // the Mage_Sales_Model_Service_Quote will raise this as an error as regions cannot be made
+ // optional in the core.
+ // Therefore we forcefull set a dummy region on adresses without a region
+ // @author Markus Tacker <m@coderbyheart.de>
+ foreach($this->getQuote()->getCustomer()->getAddressesCollection() as $a) {
+ if ($a->getId() != $billingAddressId) continue;
+ $regionId = $a->getRegionId();
+ if (empty($regionId)) {
+ $a->setRegionId(1);
+ $a->setRegion('-');
+ $a->save();
+ }
+ }
+
if($this->_isLoggedIn()){
$this->getQuote()->getBillingAddress()->setSaveInAddressBook(empty($billing_data['save_in_address_book']) ? 0 : 1);
$this->getQuote()->getShippingAddress()->setSaveInAddressBook(empty($shipping_data['save_in_address_book']) ? 0 : 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment