Swift_Checkout - Version 1.0.0

Version Notes

First Stable Release

Download this release

Release Info

Developer Team php
Extension Swift_Checkout
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (52) hide show
  1. app/code/community/Swift/OnepageCheckout/Adminhtml/Model/System/Config/Source/AddressOptions.php +14 -0
  2. app/code/community/Swift/OnepageCheckout/Adminhtml/Model/System/Config/Source/AgreementOptions.php +13 -0
  3. app/code/community/Swift/OnepageCheckout/Block/Agreements.php +20 -0
  4. app/code/community/Swift/OnepageCheckout/Block/Links.php +17 -0
  5. app/code/community/Swift/OnepageCheckout/Block/Onepage/Billship.php +101 -0
  6. app/code/community/Swift/OnepageCheckout/Block/Onepage/Link.php +20 -0
  7. app/code/community/Swift/OnepageCheckout/Block/Widget/Dob.php +10 -0
  8. app/code/community/Swift/OnepageCheckout/Block/Widget/Gender.php +9 -0
  9. app/code/community/Swift/OnepageCheckout/Block/Widget/Name.php +9 -0
  10. app/code/community/Swift/OnepageCheckout/Block/Widget/Taxvat.php +9 -0
  11. app/code/community/Swift/OnepageCheckout/Helper/Data.php +67 -0
  12. app/code/community/Swift/OnepageCheckout/Helper/Url.php +8 -0
  13. app/code/community/Swift/OnepageCheckout/Model/Observer.php +29 -0
  14. app/code/community/Swift/OnepageCheckout/Model/Service/Quote.php +30 -0
  15. app/code/community/Swift/OnepageCheckout/Model/Type/Opcheckout.php +933 -0
  16. app/code/community/Swift/OnepageCheckout/controllers/IndexController.php +669 -0
  17. app/code/community/Swift/OnepageCheckout/etc/adminhtml.xml +22 -0
  18. app/code/community/Swift/OnepageCheckout/etc/config.xml +156 -0
  19. app/code/community/Swift/OnepageCheckout/etc/system.xml +140 -0
  20. app/design/frontend/base/default/layout/onepagecheckout.xml +99 -0
  21. app/design/frontend/base/default/template/onepagecheckout/cart/noItems.phtml +10 -0
  22. app/design/frontend/base/default/template/onepagecheckout/forgotpassword.phtml +40 -0
  23. app/design/frontend/base/default/template/onepagecheckout/login.phtml +48 -0
  24. app/design/frontend/base/default/template/onepagecheckout/onepage/agreements.phtml +36 -0
  25. app/design/frontend/base/default/template/onepagecheckout/onepage/billing.phtml +301 -0
  26. app/design/frontend/base/default/template/onepagecheckout/onepage/coupon.phtml +60 -0
  27. app/design/frontend/base/default/template/onepagecheckout/onepage/link.phtml +5 -0
  28. app/design/frontend/base/default/template/onepagecheckout/onepage/payment.phtml +33 -0
  29. app/design/frontend/base/default/template/onepagecheckout/onepage/payment/methods.phtml +27 -0
  30. app/design/frontend/base/default/template/onepagecheckout/onepage/review.phtml +15 -0
  31. app/design/frontend/base/default/template/onepagecheckout/onepage/review/info.phtml +34 -0
  32. app/design/frontend/base/default/template/onepagecheckout/onepage/review/item.phtml +117 -0
  33. app/design/frontend/base/default/template/onepagecheckout/onepage/review/totals.phtml +17 -0
  34. app/design/frontend/base/default/template/onepagecheckout/onepage/shipping.phtml +209 -0
  35. app/design/frontend/base/default/template/onepagecheckout/onepage/shipping_method.phtml +15 -0
  36. app/design/frontend/base/default/template/onepagecheckout/onepagecheckout.phtml +98 -0
  37. app/design/frontend/base/default/template/onepagecheckout/widget/dob.phtml +40 -0
  38. app/design/frontend/base/default/template/onepagecheckout/widget/gender.phtml +13 -0
  39. app/design/frontend/base/default/template/onepagecheckout/widget/name.phtml +66 -0
  40. app/design/frontend/base/default/template/onepagecheckout/widget/taxvat.phtml +7 -0
  41. app/etc/modules/Swift_OnepageCheckout.xml +9 -0
  42. package.xml +18 -0
  43. skin/frontend/base/default/css/onepagecheckout.css +183 -0
  44. skin/frontend/base/default/images/onepagecheckout/buttonbg.gif +0 -0
  45. skin/frontend/base/default/images/onepagecheckout/buttonbgsmall.gif +0 -0
  46. skin/frontend/base/default/images/onepagecheckout/cancel.png +0 -0
  47. skin/frontend/base/default/images/onepagecheckout/cancel_round.png +0 -0
  48. skin/frontend/base/default/images/onepagecheckout/close.png +0 -0
  49. skin/frontend/base/default/images/onepagecheckout/loader.gif +0 -0
  50. skin/frontend/base/default/images/onepagecheckout/place-order.jpg +0 -0
  51. skin/frontend/base/default/images/onepagecheckout/shd-medium.png +0 -0
  52. skin/frontend/base/default/js/onepagecheckout.js +728 -0
app/code/community/Swift/OnepageCheckout/Adminhtml/Model/System/Config/Source/AddressOptions.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Adminhtml_Model_System_Config_Source_AddressOptions
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ $help_obj = Mage::helper('onepagecheckout');
7
+ $options = array(
8
+ array('value' => 'optional','label' => $help_obj->__('Optional')),
9
+ array('value' => 'required','label' => $help_obj->__('Required')),
10
+ array('value' => 'hidden', 'label' => $help_obj->__('Hidden'))
11
+ );
12
+ return $options;
13
+ }
14
+ }
app/code/community/Swift/OnepageCheckout/Adminhtml/Model/System/Config/Source/AgreementOptions.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Adminhtml_Model_System_Config_Source_AgreementOptions
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ $help_obj = Mage::helper('onepagecheckout');
7
+ $options = array(
8
+ array('value' => 'standard','label' => $help_obj->__('Standard')),
9
+ array('value' => 'minimal', 'label' => $help_obj->__('Minimal'))
10
+ );
11
+ return $options;
12
+ }
13
+ }
app/code/community/Swift/OnepageCheckout/Block/Agreements.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Block_Agreements extends Mage_Core_Block_Template
3
+ {
4
+ public function getAgreements()
5
+ {
6
+ if (!$this->hasAgreements())
7
+ {
8
+ $agre = array();
9
+ if (Mage::getStoreConfigFlag('onepagecheckout/agreements/enabled'))
10
+ {
11
+ $agre = Mage::getModel('checkout/agreement')->getCollection()
12
+ ->addStoreFilter(Mage::app()->getStore()->getId())
13
+ ->addFieldToFilter('is_active', 1);
14
+
15
+ }
16
+ $this->setAgreements($agre);
17
+ }
18
+ return $this->getData('agreements');
19
+ }
20
+ }
app/code/community/Swift/OnepageCheckout/Block/Links.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Block_Links extends Mage_Checkout_Block_Links
3
+ {
4
+ public function addCheckoutLink()
5
+ {
6
+ if ($this->helper('onepagecheckout')->isOnepageCheckoutEnabled())
7
+ {
8
+ $parent = $this->getParentBlock();
9
+ if ($parent)
10
+ $parent->addLink($this->helper('checkout')->__('Checkout'), 'onepagecheckout', $this->helper('checkout')->__('Checkout'), true, array('_secure'=> true), 60, null, 'class="top-link-checkout"');
11
+
12
+ return $this;
13
+ }
14
+ else
15
+ return parent::addCheckoutLink();
16
+ }
17
+ }
app/code/community/Swift/OnepageCheckout/Block/Onepage/Billship.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Swift_OnepageCheckout_Block_Onepage_Billship extends Mage_Checkout_Block_Onepage_Billing
4
+ {
5
+ public function getBillAddress()
6
+ {
7
+ return $this->getQuote()->getBillingAddress();
8
+ }
9
+
10
+ public function getShipAddress()
11
+ {
12
+ return $this->getQuote()->getShippingAddress();
13
+ }
14
+
15
+ public function getCustomerBillAddr()
16
+ {
17
+ return $this->buildCustomerAddress('billing');
18
+ }
19
+
20
+ public function getBillingCountriesSelectBox()
21
+ {
22
+ return $this->buildCountriesSelectBox('billing');
23
+ }
24
+
25
+ public function getCustomerShipAddr()
26
+ {
27
+ return $this->buildCustomerAddress('shipping');
28
+ }
29
+
30
+ public function getShippingCountriesSelectBox()
31
+ {
32
+ return $this->buildCountriesSelectBox('shipping');
33
+ }
34
+
35
+ public function buildCustomerAddress($addr_type)
36
+ {
37
+ if ($this->isCustomerLoggedIn()) {
38
+ $options = array();
39
+ foreach ($this->getCustomer()->getAddresses() as $address) {
40
+ $options[] = array(
41
+ 'value'=>$address->getId(),
42
+ 'label'=>$address->format('oneline')
43
+ );
44
+ }
45
+
46
+ switch($addr_type)
47
+ {
48
+ case 'billing':
49
+ $address = $this->getCustomer()->getPrimaryBillingAddress();
50
+ break;
51
+ case 'shipping':
52
+ $address = $this->getCustomer()->getPrimaryShippingAddress();
53
+ break;
54
+ }
55
+
56
+ if ($address) {
57
+ $addressId = $address->getId();
58
+ } else {
59
+ if($addr_type == 'billing')
60
+ $obj = $this->getBillAddress();
61
+ else
62
+ $obj = $this->getShipAddress();
63
+
64
+ $addressId = $obj->getId();
65
+ }
66
+
67
+ $select = $this->getLayout()->createBlock('core/html_select')
68
+ ->setId("{$addr_type}_customer_address")->setName("{$addr_type}_address_id")
69
+ ->setValue($addressId)->setOptions($options)
70
+ ->setExtraParams('onchange="'.$addr_type.'.newAddress(!this.value)"')
71
+ ->setClass('customer_address');
72
+
73
+ $select->addOption('', Mage::helper('checkout')->__('New Address'));
74
+ return $select->getHtml();
75
+ }
76
+ return '';
77
+ }
78
+
79
+ public function buildCountriesSelectBox($addr_type)
80
+ {
81
+ if($addr_type == 'billing')
82
+ $obj = $this->getBillAddress();
83
+ else
84
+ $obj = $this->getShipAddress();
85
+
86
+ $countryId = $obj->getCountryId();
87
+ if (is_null($countryId)) {
88
+ $countryId = Mage::getStoreConfig('general/country/default');
89
+ }
90
+ $select = $this->getLayout()->createBlock('core/html_select')
91
+ ->setId("{$addr_type}:country_id")->setName("{$addr_type}[country_id]")
92
+ ->setValue($countryId)->setOptions($this->getCountryOptions())
93
+ ->setTitle(Mage::helper('checkout')->__('Country'))
94
+ ->setClass('validate-select');
95
+
96
+ if($addr_type == 'shipping')
97
+ $select->setExtraParams('onchange="shipping.setSameAsBilling(false);"');
98
+
99
+ return $select->getHtml();
100
+ }
101
+ }
app/code/community/Swift/OnepageCheckout/Block/Onepage/Link.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Swift_OnepageCheckout_Block_Onepage_Link extends Mage_Core_Block_Template
4
+ {
5
+ public function isOnepageCheckoutAllowed()
6
+ {
7
+ return $this->helper('onepagecheckout')->isOnepageCheckoutEnabled();
8
+ }
9
+
10
+ public function checkEnable()
11
+ {
12
+ return Mage::getSingleton('checkout/session')->getQuote()->validateMinimumAmount();
13
+ }
14
+
15
+ public function getOnepageCheckoutUrl()
16
+ {
17
+ $url = $this->getUrl('onepagecheckout', array('_secure' => true));
18
+ return $url;
19
+ }
20
+ }
app/code/community/Swift/OnepageCheckout/Block/Widget/Dob.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Block_Widget_Dob extends Mage_Customer_Block_Widget_Dob
3
+ {
4
+ protected $_dateInputs = array();
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('onepagecheckout/widget/dob.phtml');
9
+ }
10
+ }
app/code/community/Swift/OnepageCheckout/Block/Widget/Gender.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Block_Widget_Gender extends Mage_Customer_Block_Widget_Gender
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('onepagecheckout/widget/gender.phtml');
8
+ }
9
+ }
app/code/community/Swift/OnepageCheckout/Block/Widget/Name.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Block_Widget_Name extends Mage_Customer_Block_Widget_Name
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('onepagecheckout/widget/name.phtml');
8
+ }
9
+ }
app/code/community/Swift/OnepageCheckout/Block/Widget/Taxvat.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Block_Widget_Taxvat extends Mage_Customer_Block_Widget_Taxvat
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('onepagecheckout/widget/taxvat.phtml');
8
+ }
9
+ }
app/code/community/Swift/OnepageCheckout/Helper/Data.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Swift_OnepageCheckout_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ protected $_agree = null;
6
+
7
+ public function isOnepageCheckoutEnabled()
8
+ {
9
+ return (bool)Mage::getStoreConfig('onepagecheckout/general/enabled');
10
+ }
11
+
12
+ public function isGuestCheckoutAllowed()
13
+ {
14
+ return Mage::getStoreConfig('onepagecheckout/general/guest_checkout');
15
+ }
16
+
17
+ public function isShippingAddressAllowed()
18
+ {
19
+ return Mage::getStoreConfig('onepagecheckout/general/shipping_address');
20
+ }
21
+
22
+ public function getAgreeIds()
23
+ {
24
+ if (is_null($this->_agree))
25
+ {
26
+ if (Mage::getStoreConfigFlag('onepagecheckout/agreements/enabled'))
27
+ {
28
+ $this->_agree = Mage::getModel('checkout/agreement')->getCollection()
29
+ ->addStoreFilter(Mage::app()->getStore()->getId())
30
+ ->addFieldToFilter('is_active', 1)
31
+ ->getAllIds();
32
+ }
33
+ else
34
+ $this->_agree = array();
35
+ }
36
+ return $this->_agree;
37
+ }
38
+
39
+ public function isSubscribeNewAllowed()
40
+ {
41
+ if (!Mage::getStoreConfig('onepagecheckout/general/newsletter_checkbox'))
42
+ return false;
43
+
44
+ $cust_sess = Mage::getSingleton('customer/session');
45
+ if (!$cust_sess->isLoggedIn() && !Mage::getStoreConfig('newsletter/subscription/allow_guest_subscribe'))
46
+ return false;
47
+
48
+ $subscribed = $this->getIsSubscribed();
49
+ if($subscribed)
50
+ return false;
51
+ else
52
+ return true;
53
+ }
54
+
55
+ public function getIsSubscribed()
56
+ {
57
+ $cust_sess = Mage::getSingleton('customer/session');
58
+ if (!$cust_sess->isLoggedIn())
59
+ return false;
60
+
61
+ return Mage::getModel('newsletter/subscriber')->getCollection()
62
+ ->useOnlySubscribed()
63
+ ->addStoreFilter(Mage::app()->getStore()->getId())
64
+ ->addFieldToFilter('subscriber_email', $cust_sess->getCustomer()->getEmail())
65
+ ->getAllIds();
66
+ }
67
+ }
app/code/community/Swift/OnepageCheckout/Helper/Url.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Helper_Url extends Mage_Checkout_Helper_Url
3
+ {
4
+ public function getCheckoutUrl()
5
+ {
6
+ return $this->_getUrl('onepagecheckout', array('_secure'=>true));
7
+ }
8
+ }
app/code/community/Swift/OnepageCheckout/Model/Observer.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Model_Observer
3
+ {
4
+ public function addHistoryComment($data)
5
+ {
6
+ $comment = Mage::getSingleton('customer/session')->getOrderCustomerComment();
7
+ $comment = trim($comment);
8
+ if (!empty($comment))
9
+ $data['order']->addStatusHistoryComment($comment)->setIsVisibleOnFront(true)->setIsCustomerNotified(false);
10
+ }
11
+
12
+ public function removeHistoryComment()
13
+ {
14
+ Mage::getSingleton('customer/session')->setOrderCustomerComment(null);
15
+ }
16
+
17
+ public function setEmptyCartTemplate()
18
+ {
19
+ if (Mage::helper('onepagecheckout')->isOnepageCheckoutEnabled())
20
+ {
21
+ $cartHelper = Mage::helper('checkout/cart');
22
+ $layout = Mage::getSingleton('core/layout');
23
+
24
+ if (!$cartHelper->getItemsCount()){
25
+ $layout->getBlock('checkout.cart')->setTemplate('onepagecheckout/cart/noItems.phtml');
26
+ }
27
+ }
28
+ }
29
+ }
app/code/community/Swift/OnepageCheckout/Model/Service/Quote.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_Model_Service_Quote extends Mage_Sales_Model_Service_Quote
3
+ {
4
+ protected function _validate()
5
+ {
6
+ $helper = Mage::helper('sales');
7
+ if (!$this->getQuote()->isVirtual())
8
+ {
9
+ $address = $this->getQuote()->getShippingAddress();
10
+ $addrValidator = Mage::getSingleton('onepagecheckout/type_opcheckout')->validateAddress($address);
11
+ if ($addrValidator !== true)
12
+ Mage::throwException($helper->__('Please check shipping address information. %s', implode(' ', $addrValidator)));
13
+
14
+ $ship_method = $address->getShippingMethod();
15
+ $rate = $address->getShippingRateByCode($ship_method);
16
+ if (!$this->getQuote()->isVirtual() && (!$ship_method || !$rate))
17
+ Mage::throwException($helper->__('Please specify a shipping method.'));
18
+ }
19
+
20
+ $addrValidator = Mage::getSingleton('onepagecheckout/type_opcheckout')->validateAddress($this->getQuote()->getBillingAddress());
21
+
22
+ if ($addrValidator !== true)
23
+ Mage::throwException($helper->__('Please check billing address information. %s', implode(' ', $addrValidator)));
24
+
25
+ if (!($this->getQuote()->getPayment()->getMethod()))
26
+ Mage::throwException($helper->__('Please select a valid payment method.'));
27
+
28
+ return $this;
29
+ }
30
+ }
app/code/community/Swift/OnepageCheckout/Model/Type/Opcheckout.php ADDED
@@ -0,0 +1,933 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Swift_OnepageCheckout_Model_Type_Opcheckout
4
+ {
5
+ const CUSTOMER = 'customer';
6
+ const GUEST = 'guest';
7
+ const REGISTER = 'register';
8
+
9
+ protected $_help_obj;
10
+ protected $_quote_obj;
11
+ private $_em_ex_msg = '';
12
+ protected $_cust_sess;
13
+ protected $_check_sess;
14
+
15
+ public function __construct()
16
+ {
17
+ $this->_help_obj = Mage::helper('checkout');
18
+ $this->_em_ex_msg = $this->_help_obj->__('This email adress is already registered. Please enter another email to register account or login using this email.');
19
+ $this->_check_sess = Mage::getSingleton('checkout/session');
20
+ $this->_quote_obj = $this->_check_sess->getQuote();
21
+
22
+ $this->_cust_sess = Mage::getSingleton('customer/session');
23
+ }
24
+
25
+ public function getQuote()
26
+ {
27
+ return $this->_quote_obj;
28
+ }
29
+
30
+ public function getCustomerSession()
31
+ {
32
+ return $this->_cust_sess;
33
+ }
34
+
35
+ public function getCheckout()
36
+ {
37
+ return $this->_check_sess;
38
+ }
39
+
40
+ protected function _PaymentMethodAllowed($pmnt_method)
41
+ {
42
+ if ($pmnt_method->canUseForCountry($this->getQuote()->getBillingAddress()->getCountry()))
43
+ {
44
+ $grand_total= $this->getQuote()->getBaseGrandTotal();
45
+ $min = $pmnt_method->getConfigData('min_order_total');
46
+ $max = $pmnt_method->getConfigData('max_order_total');
47
+
48
+ if((!empty($max) && ($grand_total > $max)) || (!empty($min) && ($grand_total < $min)))
49
+ return false;
50
+
51
+ return true;
52
+ }
53
+ else
54
+ return false;
55
+ }
56
+
57
+ public function initDefaultData()
58
+ {
59
+ $base_info = $this->_baseData();
60
+
61
+ if (!$this->getQuote()->getBillingAddress()->getCountryId())
62
+ {
63
+ $result = $this->saveBilling(array(
64
+ 'country_id' => $base_info['billing']['country_id'],
65
+ 'region_id' => $base_info['billing']['region_id'],
66
+ 'city' => $base_info['billing']['city'],
67
+ 'postcode' => $base_info['billing']['postcode'],
68
+ 'use_for_shipping' => $base_info['equal'],
69
+ 'register_account' => 0
70
+ ), false, false);
71
+ }
72
+
73
+ if (!$this->getQuote()->getShippingAddress()->getCountryId()) {
74
+ if (!$base_info['equal']) {
75
+ $result = $this->saveShipping(array(
76
+ 'country_id' => $base_info['shipping']['country_id'],
77
+ 'region_id' => $base_info['shipping']['region_id'],
78
+ 'city' => $base_info['shipping']['city'],
79
+ 'postcode' => $base_info['shipping']['postcode']
80
+ ), false, false);
81
+ }
82
+ }
83
+
84
+ $this->getQuote()->collectTotals()->save();
85
+
86
+ $this->usePayment();
87
+ $this->useShipping();
88
+
89
+ return $this;
90
+ }
91
+
92
+ private function _baseData()
93
+ {
94
+ $result = array(
95
+ 'shipping' => array(
96
+ 'country_id' => null,
97
+ 'city' => null,
98
+ 'region_id' => null,
99
+ 'postcode' => null
100
+ ),
101
+ 'billing' => array(
102
+ 'country_id' => null,
103
+ 'city' => null,
104
+ 'region_id' => null,
105
+ 'postcode' => null
106
+ ),
107
+ 'equal' => true
108
+ );
109
+
110
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
111
+ $addresses = $customer->getAddresses();
112
+
113
+ if (!$customer || !$addresses)
114
+ {
115
+ $result['equal'] = true;
116
+
117
+ /*if (Mage::getStoreConfig('onepagecheckout/geo_ip/country'))
118
+ {
119
+ $geoip = geoip_open(Mage::getBaseDir('lib').DS.'MaxMind/GeoIP/data/'.Mage::getStoreConfig('onepagecheckout/geo_ip/country_file'),GEOIP_STANDARD);
120
+ $country_id = geoip_country_code_by_addr($geoip, Mage::helper('core/http')->getRemoteAddr());
121
+ $result['shipping']['country_id'] = $country_id;
122
+ $result['billing']['country_id'] = $country_id;
123
+ geoip_close($geoip);
124
+ }
125
+
126
+ if (Mage::getStoreConfig('onepagecheckout/geo_ip/city'))
127
+ {
128
+ $geoip = geoip_open(Mage::getBaseDir('lib').DS.'MaxMind/GeoIP/data/'.Mage::getStoreConfig('onepagecheckout/geo_ip/city_file'),GEOIP_STANDARD);
129
+ $record = geoip_record_by_addr($geoip, Mage::helper('core/http')->getRemoteAddr());
130
+ $result['shipping']['city'] = $record->city;
131
+ $result['billing']['city'] = $record->city;
132
+ $result['shipping']['postcode'] = $record->postal_code;
133
+ $result['billing']['postcode'] = $record->postal_code;
134
+ geoip_close($geoip);
135
+ }*/
136
+
137
+ if (empty($result['shipping']['country_id']))
138
+ {
139
+ $country_id = Mage::getStoreConfig('onepagecheckout/general/country');
140
+ $result['shipping']['country_id'] = $country_id;
141
+ $result['billing']['country_id'] = $country_id;
142
+ }
143
+ }
144
+ else
145
+ {
146
+ $bill_addr = $customer->getPrimaryBillingAddress();
147
+ if (!$bill_addr)
148
+ {
149
+ foreach ($addresses as $address) {
150
+ $bill_addr = $address;
151
+ break;
152
+ }
153
+ }
154
+
155
+ $ship_addr = $customer->getPrimaryShippingAddress();
156
+ if (!$ship_addr)
157
+ {
158
+ foreach ($addresses as $address)
159
+ {
160
+ $ship_addr = $address;
161
+ break;
162
+ }
163
+ }
164
+
165
+ $result['shipping']['country_id'] = $ship_addr->getCountryId();
166
+ $result['billing']['country_id'] = $bill_addr->getCountryId();
167
+ $eq = false;
168
+ if($ship_addr->getId() === $bill_addr->getId())
169
+ $eq = true;
170
+ $result['equal'] = $eq;
171
+ }
172
+
173
+ return $result;
174
+ }
175
+
176
+ public function initCheckout()
177
+ {
178
+ $checkout = $this->getCheckout();
179
+ $cust_sess = $this->getCustomerSession();
180
+
181
+ if ($this->getQuote()->getIsMultiShipping()) {
182
+ $this->getQuote()->setIsMultiShipping(false);
183
+ $this->getQuote()->save();
184
+ }
185
+
186
+ $customer = $cust_sess->getCustomer();
187
+ if ($customer)
188
+ $this->getQuote()->assignCustomer($customer);
189
+
190
+ return $this;
191
+ }
192
+
193
+ public function usePayment($method_code = null)
194
+ {
195
+ $store = null;
196
+ if($this->getQuote())
197
+ $store = $this->getQuote()->getStoreId();
198
+
199
+ $methods = Mage::helper('payment')->getStoreMethods($store, $this->getQuote());
200
+
201
+ $payments = array();
202
+ foreach ($methods as $method)
203
+ {
204
+ if ($this->_PaymentMethodAllowed($method))
205
+ $payments[] = $method;
206
+ }
207
+
208
+ $cp = count($payments);
209
+ if ($cp == 0)
210
+ {
211
+ $this->getQuote()->removePayment();
212
+ }
213
+ elseif ($cp == 1)
214
+ {
215
+ $payment = $this->getQuote()->getPayment();
216
+ $payment->setMethod($payments[0]->getCode());
217
+ $method = $payment->getMethodInstance();
218
+ $method->assignData(array('method' => $payments[0]->getCode()));
219
+ }
220
+ else
221
+ {
222
+ $exist = false;
223
+ if (!$method_code)
224
+ {
225
+ if ($this->getQuote()->isVirtual())
226
+ $method_code = $this->getQuote()->getBillingAddress()->getPaymentMethod();
227
+ else
228
+ $method_code = $this->getQuote()->getShippingAddress()->getPaymentMethod();
229
+ }
230
+
231
+ if($method_code)
232
+ {
233
+ foreach ($payments as $payment)
234
+ {
235
+ if ($method_code !== $payment->getCode())
236
+ continue;
237
+
238
+ $payment = $this->getQuote()->getPayment();
239
+ $payment->setMethod($method_code);
240
+ $method = $payment->getMethodInstance();
241
+ $method->assignData(array('method' => $method_code));
242
+ $exist = true;
243
+ break;
244
+ }
245
+ }
246
+ if (!$method_code || !$exist)
247
+ {
248
+ $method_code = Mage::getStoreConfig('onepagecheckout/general/payment_method');
249
+ foreach ($payments as $payment)
250
+ {
251
+ if ($method_code !== $payment->getCode())
252
+ continue;
253
+
254
+ $payment = $this->getQuote()->getPayment();
255
+ $payment->setMethod($method_code);
256
+ $method = $payment->getMethodInstance();
257
+ $method->assignData(array('method' => $method_code));
258
+ $exist = true;
259
+ break;
260
+ }
261
+ }
262
+ if (!$exist)
263
+ $this->getQuote()->removePayment();
264
+ }
265
+
266
+ return $this;
267
+ }
268
+
269
+ public function useShipping($method_code = null)
270
+ {
271
+ $rates = Mage::getModel('sales/quote_address_rate')->getCollection()->setAddressFilter($this->getQuote()->getShippingAddress()->getId())->toArray();
272
+
273
+ $cr = count($rates['items']);
274
+ if (!$cr)
275
+ {
276
+ $this->getQuote()->getShippingAddress()->setShippingMethod(false);
277
+ }
278
+ elseif ($cr == 1)
279
+ {
280
+ $this->getQuote()->getShippingAddress()->setShippingMethod($rates['items'][0]['code']);
281
+ }
282
+ else
283
+ {
284
+ $exist = false;
285
+ if (!$method_code)
286
+ $method_code = $this->getQuote()->getShippingAddress()->getShippingMethod();
287
+
288
+ if ($method_code)
289
+ {
290
+ foreach ($rates['items'] as $rate)
291
+ {
292
+ if ($method_code === $rate['code'])
293
+ {
294
+ $this->getQuote()->getShippingAddress()->setShippingMethod($method_code);
295
+ $exist = true;
296
+ break;
297
+ }
298
+ }
299
+ }
300
+
301
+ if (!$exist || !$method_code)
302
+ {
303
+ $method_code = Mage::getStoreConfig('onepagecheckout/general/shipping_method');
304
+ foreach ($rates['items'] as $rate)
305
+ {
306
+ if ($method_code === $rate['code'])
307
+ {
308
+ $this->getQuote()->getShippingAddress()->setShippingMethod($method_code);
309
+ $exist = true;
310
+ break;
311
+ }
312
+ }
313
+ }
314
+ if (!$exist)
315
+ $this->getQuote()->getShippingAddress()->setShippingMethod(false);
316
+ }
317
+ return $this;
318
+ }
319
+
320
+ public function getAddress($addr_id)
321
+ {
322
+ $address = Mage::getModel('customer/address')->load((int)$addr_id);
323
+ $address->explodeStreetAddress();
324
+ if ($address->getRegionId())
325
+ $address->setRegion($address->getRegionId());
326
+ return $address;
327
+ }
328
+
329
+ public function getCheckoutMethod()
330
+ {
331
+ if ($this->getCustomerSession()->isLoggedIn())
332
+ return self::CUSTOMER;
333
+
334
+ if (!$this->getQuote()->getCheckoutMethod())
335
+ {
336
+ if (Mage::helper('onepagecheckout')->isGuestCheckoutAllowed())
337
+ $this->getQuote()->setCheckoutMethod(self::GUEST);
338
+ else
339
+ $this->getQuote()->setCheckoutMethod(self::REGISTER);
340
+ }
341
+ return $this->getQuote()->getCheckoutMethod();
342
+ }
343
+
344
+ public function saveCheckoutMethod($method)
345
+ {
346
+ if (empty($method))
347
+ return array('error' => -1, 'message' => $this->_help_obj->__('Invalid data.'));
348
+
349
+ $this->getQuote()->setCheckoutMethod($method)->save();
350
+ return array();
351
+ }
352
+
353
+ public function saveShippingMethod($ship_method)
354
+ {
355
+ if (empty($ship_method))
356
+ return array( 'message' => $this->_help_obj->__('Invalid shipping method.'), 'error' => -1);
357
+
358
+ $rate = $this->getQuote()->getShippingAddress()->getShippingRateByCode($ship_method);
359
+ if (!$rate)
360
+ return array('message' => $this->_help_obj->__('Invalid shipping method.'), 'error' => -1);
361
+
362
+ $this->getQuote()->getShippingAddress()->setShippingMethod($ship_method);
363
+ $this->getQuote()->collectTotals()->save();
364
+ return array();
365
+ }
366
+
367
+ public function saveBilling($data, $cust_addr_id, $validate = true, $skip_save = false)
368
+ {
369
+ if (empty($data))
370
+ return array('error' => -1, 'message' => $this->_help_obj->__('Invalid data.'));
371
+
372
+ $address = $this->getQuote()->getBillingAddress();
373
+ if (!empty($cust_addr_id))
374
+ {
375
+ $cust_addr = Mage::getModel('customer/address')->load($cust_addr_id);
376
+ if ($cust_addr->getId())
377
+ {
378
+ if ($cust_addr->getCustomerId() != $this->getQuote()->getCustomerId())
379
+ return array('error' => 1, 'message' => $this->_help_obj->__('Customer Address is not valid.'));
380
+
381
+ $address->importCustomerAddress($cust_addr);
382
+ }
383
+ }
384
+ else
385
+ {
386
+ unset($data['address_id']);
387
+ $address->addData($data);
388
+ }
389
+
390
+ if($validate)
391
+ {
392
+ $val_results = $this->validateAddress($address);
393
+ if ($val_results !== true)
394
+ return array('error' => 1, 'message' => $val_results);
395
+ }
396
+
397
+ if (isset($data['register_account']) && $data['register_account'])
398
+ $this->getQuote()->setCheckoutMethod(self::REGISTER);
399
+ else if ($this->getCustomerSession()->isLoggedIn())
400
+ $this->getQuote()->setCheckoutMethod(self::CUSTOMER);
401
+ else
402
+ $this->getQuote()->setCheckoutMethod(self::GUEST);
403
+
404
+ if($skip_save){
405
+ if (true !== ($result = $this->_validateCustomerData($data))) {
406
+ return $result;
407
+ }
408
+ }
409
+
410
+ if($validate)
411
+ {
412
+ if (!$this->getQuote()->getCustomerId() && (self::REGISTER == $this->getQuote()->getCheckoutMethod()))
413
+ {
414
+ if ($this->_customerEmailExists($address->getEmail(), Mage::app()->getWebsite()->getId()))
415
+ return array('error' => 1, 'message' => $this->_em_ex_msg);
416
+ }
417
+ }
418
+
419
+ $address->implodeStreetAddress();
420
+
421
+ if (!$this->getQuote()->isVirtual())
422
+ {
423
+ $ufs = 0;
424
+ if(isset($data['use_for_shipping']))
425
+ $ufs = (int) $data['use_for_shipping'];
426
+
427
+ switch($ufs)
428
+ {
429
+ case 0:
430
+ $ship = $this->getQuote()->getShippingAddress();
431
+ $ship->setSameAsBilling(0);
432
+ break;
433
+ case 1:
434
+ $bill = clone $address;
435
+ $bill->unsAddressId()->unsAddressType();
436
+ $ship = $this->getQuote()->getShippingAddress();
437
+ $ship_method = $ship->getShippingMethod();
438
+ $ship->addData($bill->getData());
439
+ $ship->setSameAsBilling(1)->setShippingMethod($ship_method)->setCollectShippingRates(true);
440
+ break;
441
+ }
442
+ }
443
+
444
+ if ($validate){
445
+ $result = $this->_processValidateCustomer($address);
446
+ if($result !== true)
447
+ return $result;
448
+ }
449
+
450
+ // fixed by Alex Calko for saving data to define property shipping method
451
+ if(!$skip_save)
452
+ $this->getQuote()->collectTotals()->save();
453
+
454
+ return array();
455
+ }
456
+
457
+ public function saveShipping($data, $cust_addr_id, $validate = true, $skip_save = false)
458
+ {
459
+ if (empty($data))
460
+ return array('message' => $this->_help_obj->__('Invalid data.'), 'error' => -1);
461
+
462
+ $address = $this->getQuote()->getShippingAddress();
463
+
464
+ if (empty($cust_addr_id))
465
+ {
466
+ unset($data['address_id']);
467
+ $address->addData($data);
468
+ }
469
+ else
470
+ {
471
+ $cust_addr = Mage::getModel('customer/address')->load($cust_addr_id);
472
+ if ($cust_addr->getId())
473
+ {
474
+ if ($this->getQuote()->getCustomerId() != $cust_addr->getCustomerId())
475
+ return array('message' => $this->_help_obj->__('Customer Address is not valid.'), 'error' => 1);
476
+
477
+ $address->importCustomerAddress($cust_addr);
478
+ }
479
+ }
480
+
481
+ $address->implodeStreetAddress();
482
+ $address->setCollectShippingRates(true);
483
+
484
+ if ($validate)
485
+ {
486
+ $val_result = $this->validateAddress($address);
487
+ if($val_result !== true)
488
+ return array('message' => $val_result, 'error' => 1);
489
+ }
490
+
491
+ // fixed by Alex Calko for saving data to define property shipping method
492
+ if(!$skip_save)
493
+ $this->getQuote()->collectTotals()->save();
494
+
495
+ return array();
496
+ }
497
+
498
+ public function savePayment($data)
499
+ {
500
+ if (empty($data))
501
+ return array('message' => $this->_help_obj->__('Invalid data.'), 'error' => -1);
502
+
503
+ if (!$this->getQuote()->isVirtual())
504
+ $this->getQuote()->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
505
+ else
506
+ $this->getQuote()->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
507
+
508
+ $payment = $this->getQuote()->getPayment();
509
+ $payment->importData($data);
510
+
511
+ $this->getQuote()->save();
512
+
513
+ return array();
514
+ }
515
+
516
+ /**
517
+ * Validate customer data and set some its data for further usage in quote
518
+ * Will return either true or array with error messages
519
+ *
520
+ * @param array $data
521
+ * @return true|array
522
+ */
523
+ protected function _validateCustomerData(array $data)
524
+ {
525
+ /** @var $customerForm Mage_Customer_Model_Form */
526
+ $customerForm = Mage::getModel('customer/form');
527
+ $customerForm->setFormCode('checkout_register')
528
+ ->setIsAjaxRequest(Mage::app()->getRequest()->isAjax());
529
+
530
+ $quote = $this->getQuote();
531
+ if ($quote->getCustomerId()) {
532
+ $customer = $quote->getCustomer();
533
+ $customerForm->setEntity($customer);
534
+ $customerData = $quote->getCustomer()->getData();
535
+ } else {
536
+ /* @var $customer Mage_Customer_Model_Customer */
537
+ $customer = Mage::getModel('customer/customer');
538
+ $customerForm->setEntity($customer);
539
+ $customerRequest = $customerForm->prepareRequest($data);
540
+ $customerData = $customerForm->extractData($customerRequest);
541
+ }
542
+
543
+ $customerErrors = $customerForm->validateData($customerData);
544
+ if ($customerErrors !== true) {
545
+ return array(
546
+ 'error' => -1,
547
+ 'message' => implode(', ', $customerErrors)
548
+ );
549
+ }
550
+
551
+ if ($quote->getCustomerId()) {
552
+ return true;
553
+ }
554
+
555
+ $customerForm->compactData($customerData);
556
+
557
+ if ($quote->getCheckoutMethod() == self::REGISTER) {
558
+ // set customer password
559
+ $customer->setPassword($customerRequest->getParam('customer_password'));
560
+ $customer->setConfirmation($customerRequest->getParam('confirm_password'));
561
+ } else {
562
+ // spoof customer password for guest
563
+ $password = $customer->generatePassword();
564
+ $customer->setPassword($password);
565
+ $customer->setConfirmation($password);
566
+ // set NOT LOGGED IN group id explicitly,
567
+ // otherwise copyFieldset('customer_account', 'to_quote') will fill it with default group id value
568
+ $customer->setGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
569
+ }
570
+
571
+ $result = $customer->validate();
572
+ if (true !== $result && is_array($result)) {
573
+ return array(
574
+ 'error' => -1,
575
+ 'message' => implode(', ', $result)
576
+ );
577
+ }
578
+
579
+ if ($quote->getCheckoutMethod() == self::REGISTER) {
580
+ // save customer encrypted password in quote
581
+ $quote->setPasswordHash($customer->encryptPassword($customer->getPassword()));
582
+ }
583
+
584
+ // copy customer/guest email to address
585
+ $quote->getBillingAddress()->setEmail($customer->getEmail());
586
+
587
+ // copy customer data to quote
588
+ Mage::helper('core')->copyFieldset('customer_account', 'to_quote', $customer, $quote);
589
+
590
+ return true;
591
+ }
592
+
593
+ protected function _processValidateCustomer(Mage_Sales_Model_Quote_Address $address)
594
+ {
595
+ if ($address->getGender())
596
+ $this->getQuote()->setCustomerGender($address->getGender());
597
+
598
+ $dob = '';
599
+ if ($address->getDob()) {
600
+ $dob = Mage::app()->getLocale()->date($address->getDob(), null, null, false)->toString('yyyy-MM-dd');
601
+ $this->getQuote()->setCustomerDob($dob);
602
+ }
603
+
604
+ if ($address->getTaxvat())
605
+ $this->getQuote()->setCustomerTaxvat($address->getTaxvat());
606
+
607
+ if ($this->getQuote()->getCheckoutMethod() == self::REGISTER)
608
+ {
609
+ $customer = Mage::getModel('customer/customer');
610
+ $this->getQuote()->setPasswordHash($customer->encryptPassword($address->getCustomerPassword()));
611
+
612
+ $cust_data = array(
613
+ 'email' => 'email',
614
+ 'password' => 'customer_password',
615
+ 'confirmation' => 'confirm_password',
616
+ 'firstname' => 'firstname',
617
+ 'lastname' => 'lastname',
618
+ 'gender' => 'gender',
619
+ 'taxvat' => 'taxvat');
620
+
621
+ foreach ($cust_data as $key => $value)
622
+ $customer->setData($key, $address->getData($value));
623
+
624
+ if ($dob)
625
+ $customer->setDob($dob);
626
+
627
+ $val_result = $customer->validate();
628
+ if ($val_result !== true && is_array($val_result))
629
+ return array('message' => implode(', ', $val_result), 'error' => -1);
630
+ }
631
+ elseif($this->getQuote()->getCheckoutMethod() == self::GUEST)
632
+ {
633
+ $email = $address->getData('email');
634
+ if (!Zend_Validate::is($email, 'EmailAddress'))
635
+ return array('message' => $this->_help_obj->__('Invalid email address "%s"', $email), 'error' => -1);
636
+ }
637
+
638
+ return true;
639
+ }
640
+
641
+ public function validate()
642
+ {
643
+ $quote = $this->getQuote();
644
+ if ($quote->getIsMultiShipping())
645
+ Mage::throwException($this->_help_obj->__('Invalid checkout type.'));
646
+
647
+ if (!Mage::helper('onepagecheckout')->isGuestCheckoutAllowed() && $quote->getCheckoutMethod() == self::GUEST)
648
+ Mage::throwException($this->_help_obj->__('Sorry, guest checkout is not allowed, please contact support.'));
649
+ }
650
+
651
+ public function saveOrder()
652
+ {
653
+ $info = Mage::getVersionInfo();
654
+ $version = "{$info['major']}.{$info['minor']}.{$info['revision']}.{$info['patch']}";
655
+
656
+ $this->validate();
657
+ $newCustomer = false;
658
+
659
+ switch ($this->getCheckoutMethod())
660
+ {
661
+ case self::GUEST:
662
+ $this->_prepareGuestQuote();
663
+ break;
664
+ case self::REGISTER:
665
+ $this->_prepareNewCustomerQuote();
666
+ $newCustomer = true;
667
+ break;
668
+ default:
669
+ $this->_prepareCustomerQuote();
670
+ break;
671
+ }
672
+
673
+ $service_quote = Mage::getModel('onepagecheckout/service_quote', $this->getQuote());
674
+ if($version == '1.4.0.1')
675
+ $order = $service_quote->submit();
676
+ else
677
+ {
678
+ $order = $service_quote->submitAll();
679
+ $order = $service_quote->getOrder();
680
+ }
681
+
682
+ if ($newCustomer)
683
+ {
684
+ try {
685
+ $this->_involveNewCustomer();
686
+ } catch (Exception $e) {
687
+ Mage::logException($e);
688
+ }
689
+ }
690
+
691
+ if($version != '1.4.0.1')
692
+ {
693
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId())
694
+ ->setLastSuccessQuoteId($this->getQuote()->getId())
695
+ ->clearHelperData();
696
+ }
697
+
698
+ if ($order)
699
+ {
700
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
701
+ $r_url = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
702
+ if(!$r_url)
703
+ {
704
+ try {
705
+ $order->sendNewOrderEmail();
706
+ } catch (Exception $e) {
707
+ Mage::logException($e);
708
+ }
709
+ }
710
+
711
+ if($version == '1.4.0.1')
712
+ {
713
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId())->setLastOrderId($order->getId())->setLastRealOrderId($order->getIncrementId())->setRedirectUrl($r_url)->setLastSuccessQuoteId($this->getQuote()->getId());
714
+ }
715
+ else
716
+ {
717
+ $this->getCheckout()->setLastOrderId($order->getId())->setRedirectUrl($r_url)->setLastRealOrderId($order->getIncrementId());
718
+
719
+ $agree = $order->getPayment()->getBillingAgreement();
720
+ if ($agree)
721
+ $this->getCheckout()->setLastBillingAgreementId($agree->getId());
722
+ }
723
+ }
724
+
725
+ if($version != '1.4.0.1')
726
+ {
727
+ $profiles = $service_quote->getRecurringPaymentProfiles();
728
+ if ($profiles)
729
+ {
730
+ $ids = array();
731
+ foreach($profiles as $profile)
732
+ $ids[] = $profile->getId();
733
+
734
+ $this->getCheckout()->setLastRecurringProfileIds($ids);
735
+ }
736
+ }
737
+
738
+ return $this;
739
+ }
740
+
741
+ protected function validateOrder()
742
+ {
743
+ if ($this->getQuote()->getIsMultiShipping())
744
+ Mage::throwException($this->_help_obj->__('Invalid checkout type.'));
745
+
746
+ if (!$this->getQuote()->isVirtual())
747
+ {
748
+ $address = $this->getQuote()->getShippingAddress();
749
+ $addrVal = $this->validateAddress($address);
750
+ if ($addrVal !== true)
751
+ Mage::throwException($this->_help_obj->__('Please check shipping address.'));
752
+
753
+ $method= $address->getShippingMethod();
754
+ $rate = $address->getShippingRateByCode($method);
755
+ if (!$this->getQuote()->isVirtual() && (!$method || !$rate))
756
+ Mage::throwException($this->_help_obj->__('Please specify shipping method.'));
757
+ }
758
+
759
+ $addrVal = $this->validateAddress($this->getQuote()->getBillingAddress());
760
+ if ($addrVal !== true)
761
+ Mage::throwException($this->_help_obj->__('Please check billing address.'));
762
+
763
+ if (!($this->getQuote()->getPayment()->getMethod()))
764
+ Mage::throwException($this->_help_obj->__('Please select valid payment method.'));
765
+ }
766
+
767
+ public function getLastOrderId()
768
+ {
769
+ $lo = $this->getCheckout()->getLastOrderId();
770
+ $order_id = false;
771
+ if ($lo)
772
+ {
773
+ $order = Mage::getModel('sales/order');
774
+ $order->load($lo);
775
+ $order_id = $order->getIncrementId();
776
+ }
777
+ return $order_id;
778
+ }
779
+
780
+ public function validateAddress($address)
781
+ {
782
+ $errors = array();
783
+ $helper = Mage::helper('customer');
784
+ $address->implodeStreetAddress();
785
+ $a_form = Mage::getStoreConfig('onepagecheckout/address_form');
786
+
787
+ if (!Zend_Validate::is($address->getFirstname(), 'NotEmpty'))
788
+ $errors[] = $helper->__('Please enter the first name.');
789
+
790
+ if (!Zend_Validate::is($address->getLastname(), 'NotEmpty'))
791
+ $errors[] = $helper->__('Please enter the last name.');
792
+
793
+ if ($a_form['company'] === 'required' && !Zend_Validate::is($address->getCompany(), 'NotEmpty'))
794
+ $errors[] = $helper->__('Please enter the company.');
795
+
796
+ if ($a_form['state'] === 'required' && $address->getCountryModel()->getRegionCollection()->getSize() && !Zend_Validate::is($address->getRegionId(), 'NotEmpty'))
797
+ $errors[] = $helper->__('Please enter the state/province.');
798
+
799
+ if ($a_form['address'] === 'required' && !Zend_Validate::is($address->getStreet(1), 'NotEmpty'))
800
+ $errors[] = $helper->__('Please enter the street.');
801
+
802
+ if ($a_form['city'] === 'required' && !Zend_Validate::is($address->getCity(), 'NotEmpty'))
803
+ $errors[] = $helper->__('Please enter the city.');
804
+
805
+ $_opt_zip = Mage::helper('directory')->getCountriesWithOptionalZip();
806
+ if ($a_form['zip'] === 'required' && !in_array($address->getCountryId(), $_opt_zip) && !Zend_Validate::is($address->getPostcode(), 'NotEmpty'))
807
+ $errors[] = $helper->__('Please enter the zip code.');
808
+
809
+ if ($a_form['phone'] === 'required' && !Zend_Validate::is($address->getTelephone(), 'NotEmpty'))
810
+ $errors[] = $helper->__('Please enter the phone number.');
811
+
812
+ if ($a_form['fax'] === 'required' && !Zend_Validate::is($address->getFax(), 'NotEmpty'))
813
+ $errors[] = $helper->__('Please enter the fax.');
814
+
815
+ if ($a_form['country'] === 'required' && !Zend_Validate::is($address->getCountryId(), 'NotEmpty'))
816
+ $errors[] = $helper->__('Please choose the country.');
817
+
818
+ if (empty($errors) || $address->getShouldIgnoreValidation())
819
+ return true;
820
+
821
+ return $errors;
822
+ }
823
+
824
+ protected function _prepareNewCustomerQuote()
825
+ {
826
+ $bill = $this->getQuote()->getBillingAddress();
827
+ $ship = null;
828
+ if(!$this->getQuote()->isVirtual())
829
+ $ship = $this->getQuote()->getShippingAddress();
830
+
831
+ $customer = $this->getQuote()->getCustomer();
832
+ $cust_bill = $bill->exportCustomerAddress();
833
+ $customer->addAddress($cust_bill);
834
+ $bill->setCustomerAddress($cust_bill);
835
+ $cust_bill->setIsDefaultBilling(true);
836
+ if($ship)
837
+ {
838
+ if(!$ship->getSameAsBilling())
839
+ {
840
+ $cust_ship = $ship->exportCustomerAddress();
841
+ $customer->addAddress($cust_ship);
842
+ $ship->setCustomerAddress($cust_ship);
843
+ $cust_ship->setIsDefaultShipping(true);
844
+ }
845
+ else
846
+ $cust_bill->setIsDefaultShipping(true);
847
+ }
848
+
849
+ if (!$bill->getCustomerGender() && $this->getQuote()->getCustomerGender())
850
+ $bill->setCustomerGender($this->getQuote()->getCustomerGender());
851
+
852
+ if (!$bill->getCustomerDob() && $this->getQuote()->getCustomerDob())
853
+ $bill->setCustomerDob($this->getQuote()->getCustomerDob());
854
+
855
+ if (!$bill->getCustomerTaxvat() && $this->getQuote()->getCustomerTaxvat())
856
+ $bill->setCustomerTaxvat($this->getQuote()->getCustomerTaxvat());
857
+
858
+ Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $bill, $customer);
859
+
860
+ $customer->setPassword($customer->decryptPassword($this->getQuote()->getPasswordHash()));
861
+ $customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
862
+ $this->getQuote()->setCustomer($customer)->setCustomerId(true);
863
+ }
864
+
865
+ protected function _prepareCustomerQuote()
866
+ {
867
+ $bill = $this->getQuote()->getBillingAddress();
868
+ $ship = null;
869
+ if(!$this->getQuote()->isVirtual())
870
+ $ship = $this->getQuote()->getShippingAddress();
871
+
872
+ $customer = $this->getCustomerSession()->getCustomer();
873
+ if (!$bill->getCustomerId() || $bill->getSaveInAddressBook())
874
+ {
875
+ $cust_bill = $bill->exportCustomerAddress();
876
+ $customer->addAddress($cust_bill);
877
+ $bill->setCustomerAddress($cust_bill);
878
+ }
879
+ if ($ship && (($ship->getSaveInAddressBook() && !$ship->getSameAsBilling()) || (!$ship->getSameAsBilling() && !$ship->getCustomerId())))
880
+ {
881
+ $cust_ship = $ship->exportCustomerAddress();
882
+ $customer->addAddress($cust_ship);
883
+ $ship->setCustomerAddress($cust_ship);
884
+ }
885
+
886
+ if (isset($cust_bill) && !$customer->getDefaultBilling())
887
+ $cust_bill->setIsDefaultBilling(true);
888
+
889
+ if ($ship && isset($cust_ship) && !$customer->getDefaultShipping())
890
+ $cust_ship->setIsDefaultShipping(true);
891
+ elseif (isset($cust_bill) && !$customer->getDefaultShipping())
892
+ $cust_bill->setIsDefaultShipping(true);
893
+
894
+ $this->getQuote()->setCustomer($customer);
895
+ }
896
+
897
+ protected function _prepareGuestQuote()
898
+ {
899
+ $quote = $this->getQuote();
900
+ $quote->setCustomerId(null)->setCustomerEmail($quote->getBillingAddress()->getEmail())->setCustomerIsGuest(true)->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
901
+ return $this;
902
+ }
903
+
904
+ protected function _involveNewCustomer()
905
+ {
906
+ $customer = $this->getQuote()->getCustomer();
907
+ if ($customer->isConfirmationRequired())
908
+ {
909
+ $customer->sendNewAccountEmail('confirmation');
910
+ $url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
911
+ $this->getCustomerSession()->addSuccess(Mage::helper('customer')->__('Account confirmation is required. Please, check your email for confirmation link. <a href="%s">Click here</a> to resend confirmation email.', $url));
912
+ }
913
+ else
914
+ {
915
+ $customer->sendNewAccountEmail();
916
+ $this->getCustomerSession()->loginById($customer->getId());
917
+ }
918
+ return $this;
919
+ }
920
+
921
+ protected function _customerEmailExists($email, $web_id = null)
922
+ {
923
+ $customer = Mage::getModel('customer/customer');
924
+ if ($web_id)
925
+ $customer->setWebsiteId($web_id);
926
+
927
+ $customer->loadByEmail($email);
928
+ if ($customer->getId())
929
+ return $customer;
930
+
931
+ return false;
932
+ }
933
+ }
app/code/community/Swift/OnepageCheckout/controllers/IndexController.php ADDED
@@ -0,0 +1,669 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Swift_OnepageCheckout_IndexController extends Mage_Checkout_Controller_Action
3
+ {
4
+ private $_current_layout = null;
5
+
6
+ protected $_sectionUpdateFunctions = array(
7
+ 'review' => '_getReviewHtml',
8
+ 'shipping-method' => '_getShippingMethodsHtml',
9
+ 'payment-method' => '_getPaymentMethodsHtml',
10
+ );
11
+
12
+ public function preDispatch()
13
+ {
14
+ parent::preDispatch();
15
+ $this->_preDispatchValidateCustomer();
16
+ return $this;
17
+ }
18
+
19
+ protected function _ajaxRedirectResponse()
20
+ {
21
+ $this->getResponse()
22
+ ->setHeader('HTTP/1.1', '403 Session Expired')
23
+ ->setHeader('Login-Required', 'true')
24
+ ->sendResponse();
25
+ return $this;
26
+ }
27
+
28
+ protected function _expireAjax()
29
+ {
30
+ if (!$this->getOnepagecheckout()->getQuote()->hasItems()
31
+ || $this->getOnepagecheckout()->getQuote()->getHasError()
32
+ || $this->getOnepagecheckout()->getQuote()->getIsMultiShipping()) {
33
+ $this->_ajaxRedirectResponse();
34
+ return true;
35
+ }
36
+ $action = $this->getRequest()->getActionName();
37
+ if (Mage::getSingleton('checkout/session')->getCartWasUpdated(true)
38
+ && !in_array($action, array('index', 'progress'))) {
39
+ $this->_ajaxRedirectResponse();
40
+ return true;
41
+ }
42
+
43
+ return false;
44
+ }
45
+
46
+ protected function _getUpdatedLayout()
47
+ {$this->_initLayoutMessages('checkout/session');
48
+ if ($this->_current_layout === null)
49
+ {
50
+ $layout = $this->getLayout();
51
+ $update = $layout->getUpdate();
52
+ $update->load('onepagecheckout_index_updatecheckout');
53
+
54
+ $layout->generateXml();
55
+ $layout->generateBlocks();
56
+ $this->_current_layout = $layout;
57
+ }
58
+
59
+ return $this->_current_layout;
60
+ }
61
+
62
+ protected function _getShippingMethodsHtml()
63
+ {
64
+ $layout = $this->_getUpdatedLayout();
65
+ return $layout->getBlock('checkout.shipping.method')->toHtml();
66
+ }
67
+
68
+ protected function _getPaymentMethodsHtml()
69
+ {
70
+ $layout = $this->_getUpdatedLayout();
71
+ return $layout->getBlock('checkout.payment.method')->toHtml();
72
+ }
73
+
74
+ protected function _getCouponDiscountHtml()
75
+ {
76
+ $layout = $this->_getUpdatedLayout();
77
+ return $layout->getBlock('checkout.cart.coupon')->toHtml();
78
+ }
79
+
80
+ protected function _getReviewHtml()
81
+ {
82
+ $layout = $this->_getUpdatedLayout();
83
+ return $layout->getBlock('checkout.review')->toHtml();
84
+ }
85
+
86
+ public function getOnepagecheckout()
87
+ {
88
+ return Mage::getSingleton('onepagecheckout/type_opcheckout');
89
+ }
90
+
91
+ public function indexAction()
92
+ {
93
+ if (!Mage::helper('onepagecheckout')->isOnepageCheckoutEnabled())
94
+ {
95
+ Mage::getSingleton('checkout/session')->addError($this->__('The one page checkout is disabled.'));
96
+ $this->_redirect('checkout/cart');
97
+ return;
98
+ }
99
+
100
+ $quote = $this->getOnepagecheckout()->getQuote();
101
+ if (!$quote->hasItems() || $quote->getHasError()) {
102
+ $this->_redirect('checkout/cart');
103
+ return;
104
+ }
105
+ if (!$quote->validateMinimumAmount()) {
106
+ $error = Mage::getStoreConfig('sales/minimum_order/error_message');
107
+ Mage::getSingleton('checkout/session')->addError($error);
108
+ $this->_redirect('checkout/cart');
109
+ return;
110
+ }
111
+
112
+ Mage::getSingleton('checkout/session')->setCartWasUpdated(false);
113
+ Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_secure'=>true)));
114
+
115
+ $this->getOnepagecheckout()->initDefaultData()->initCheckout();
116
+ $this->loadLayout();
117
+ $this->_initLayoutMessages('customer/session');
118
+ $title = Mage::getStoreConfig('onepagecheckout/general/title');
119
+ $this->getLayout()->getBlock('head')->setTitle($title);
120
+ $this->renderLayout();
121
+ }
122
+
123
+ public function successAction()
124
+ {
125
+ $notallowed = $this->getRequest()->getParam('na', false);
126
+ if($notallowed)
127
+ {
128
+ $this->_redirect('checkout/onepage');
129
+ return;
130
+ }
131
+
132
+ $session = $this->getOnepagecheckout()->getCheckout();
133
+ if (!$session->getLastSuccessQuoteId()) {
134
+ $this->_redirect('checkout/cart');
135
+ return;
136
+ }
137
+
138
+ $lastQuoteId = $session->getLastQuoteId();
139
+ $lastOrderId = $session->getLastOrderId();
140
+ $lastRecurringProfiles = $session->getLastRecurringProfileIds();
141
+ if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
142
+ $this->_redirect('checkout/cart');
143
+ return;
144
+ }
145
+
146
+ $session->clear();
147
+ /* clear cart */
148
+ $cart = Mage::getSingleton('checkout/cart');
149
+ foreach( $this->getOnepagecheckout()->getQuote()->getItemsCollection() as $item ){
150
+ $cart->removeItem( $item->getId() );
151
+ }
152
+ $cart->save();
153
+ /* clear cart */
154
+ $this->loadLayout();
155
+ $this->_initLayoutMessages('checkout/session');
156
+ Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
157
+ $this->renderLayout();
158
+ }
159
+
160
+ public function failureAction()
161
+ {
162
+ $lastQuoteId = $this->getOnepagecheckout()->getCheckout()->getLastQuoteId();
163
+ $lastOrderId = $this->getOnepagecheckout()->getCheckout()->getLastOrderId();
164
+
165
+ if (!$lastQuoteId || !$lastOrderId) {
166
+ $this->_redirect('checkout/cart');
167
+ return;
168
+ }
169
+
170
+ $this->loadLayout();
171
+ $this->renderLayout();
172
+ }
173
+
174
+ public function getAddressAction()
175
+ {
176
+ if ($this->_expireAjax()) {
177
+ return;
178
+ }
179
+ $addressId = $this->getRequest()->getParam('address', false);
180
+ if ($addressId) {
181
+ $address = $this->getOnepagecheckout()->getAddress($addressId);
182
+
183
+ if (Mage::getSingleton('customer/session')->getCustomer()->getId() == $address->getCustomerId()) {
184
+ $this->getResponse()->setHeader('Content-type', 'application/x-json');
185
+ $this->getResponse()->setBody($address->toJson());
186
+ } else {
187
+ $this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
188
+ }
189
+ }
190
+ }
191
+
192
+ public function updateCheckoutAction()
193
+ {
194
+ if ($this->_expireAjax() || !$this->getRequest()->isPost()) {
195
+ return;
196
+ }
197
+ /*********** DISCOUNT CODES **********/
198
+
199
+ $quote = $this->getOnepagecheckout()->getQuote();
200
+ $couponData = $this->getRequest()->getPost('coupon', array());
201
+ $processCoupon = $this->getRequest()->getPost('process_coupon', false);
202
+
203
+ $couponChanged = false;
204
+ if ($couponData && $processCoupon) {
205
+ if (!empty($couponData['remove'])) {
206
+ $couponData['code'] = '';
207
+
208
+ }
209
+ $oldCouponCode = $quote->getCouponCode();
210
+ if ($oldCouponCode != $couponData['code']) {
211
+ try {
212
+ $quote->setCouponCode(
213
+ strlen($couponData['code']) ? $couponData['code'] : ''
214
+ );
215
+ $this->getRequest()->setPost('payment-method', true);
216
+ $this->getRequest()->setPost('shipping-method', true);
217
+ if ($couponData['code']) {
218
+ $couponChanged = true;
219
+ } else {
220
+ $couponChanged = true;
221
+ Mage::getSingleton('checkout/session')->addSuccess($this->__('Coupon code was canceled.'));
222
+ }
223
+ } catch (Mage_Core_Exception $e) {
224
+ $couponChanged = true;
225
+ Mage::getSingleton('checkout/session')->addError($e->getMessage());
226
+ } catch (Exception $e) {
227
+ $couponChanged = true;
228
+ Mage::getSingleton('checkout/session')->addError($this->__('Cannot apply the coupon code.'));
229
+ }
230
+
231
+ }
232
+ }
233
+
234
+ /***********************************/
235
+
236
+ $bill_data = $this->getRequest()->getPost('billing', array());
237
+ $bill_data = $this->_filterPostData($bill_data);
238
+ $bill_addr_id = $this->getRequest()->getPost('billing_address_id', false);
239
+ $result = array();
240
+ $ship_updated = false;
241
+
242
+ if ($this->_checkChangedAddress($bill_data, 'Billing', $bill_addr_id) || $this->getRequest()->getPost('payment-method', false))
243
+ {
244
+ if (isset($bill_data['email']))
245
+ {
246
+ $bill_data['email'] = trim($bill_data['email']);
247
+ }
248
+
249
+ $bill_result = $this->getOnepagecheckout()->saveBilling($bill_data, $bill_addr_id, false);
250
+
251
+ if (!isset($bill_result['error']))
252
+ {
253
+ $pmnt_data = $this->getRequest()->getPost('payment', array());
254
+ $this->getOnepagecheckout()->usePayment(isset($pmnt_data['method']) ? $pmnt_data['method'] : null);
255
+
256
+ $result['update_section']['payment-method'] = $this->_getPaymentMethodsHtml();
257
+
258
+ if (isset($bill_data['use_for_shipping']) && $bill_data['use_for_shipping'] == 1 && !$this->getOnepagecheckout()->getQuote()->isVirtual())
259
+ {
260
+ $result['update_section']['shipping-method'] = $this->_getShippingMethodsHtml();
261
+ $result['duplicateBillingInfo'] = 'true';
262
+
263
+ $ship_updated = true;
264
+ }
265
+ }
266
+ else
267
+ {
268
+ $result['error_messages'] = $bill_result['message'];
269
+ }
270
+ }
271
+
272
+ $ship_data = $this->getRequest()->getPost('shipping', array());
273
+ $ship_addr_id = $this->getRequest()->getPost('shipping_address_id', false);
274
+ $ship_method = $this->getRequest()->getPost('shipping_method', false);
275
+
276
+ if (!$ship_updated && !$this->getOnepagecheckout()->getQuote()->isVirtual())
277
+ {
278
+ if ($this->_checkChangedAddress($ship_data, 'Shipping', $ship_addr_id) || $ship_method)
279
+ {
280
+ $ship_result = $this->getOnepagecheckout()->saveShipping($ship_data, $ship_addr_id, false);
281
+
282
+ if (!isset($ship_result['error']))
283
+ {
284
+ $result['update_section']['shipping-method'] = $this->_getShippingMethodsHtml();
285
+ }
286
+ }
287
+ }
288
+
289
+ $check_shipping_diff = false;
290
+
291
+ // check how many shipping methods exist
292
+ $rates = Mage::getModel('sales/quote_address_rate')->getCollection()->setAddressFilter($this->getOnepagecheckout()->getQuote()->getShippingAddress()->getId())->toArray();
293
+ if(count($rates['items'])==1)
294
+ {
295
+ if($rates['items'][0]['code']!=$ship_method)
296
+ {
297
+ $check_shipping_diff = true;
298
+
299
+ $result['reload_totals'] = 'true';
300
+ }
301
+ }
302
+ else
303
+ $check_shipping_diff = true;
304
+
305
+ // get prev shipping method
306
+ if($check_shipping_diff){
307
+ $shipping = $this->getOnepagecheckout()->getQuote()->getShippingAddress();
308
+ $shippingMethod_before = $shipping->getShippingMethod();
309
+ }
310
+
311
+ $this->getOnepagecheckout()->useShipping($ship_method);
312
+
313
+ $this->getOnepagecheckout()->getQuote()->collectTotals()->save();
314
+
315
+ if($check_shipping_diff){
316
+ $shipping = $this->getOnepagecheckout()->getQuote()->getShippingAddress();
317
+ $shippingMethod_after = $shipping->getShippingMethod();
318
+
319
+ if($shippingMethod_before != $shippingMethod_after)
320
+ {
321
+ $result['update_section']['shipping-method'] = $this->_getShippingMethodsHtml();
322
+ $result['reload_totals'] = 'true';
323
+ }
324
+ else
325
+ unset($result['reload_totals']);
326
+ }
327
+ ///////////////
328
+
329
+ $result['update_section']['review'] = $this->_getReviewHtml();
330
+
331
+
332
+ /*********** DISCOUNT CODES **********/
333
+ if ($couponChanged) {
334
+ if ($couponData['code'] == $quote->getCouponCode()) {
335
+ Mage::getSingleton('checkout/session')->addSuccess(
336
+ $this->__('Coupon code "%s" was applied.', Mage::helper('core')->htmlEscape($couponData['code']))
337
+ );
338
+ } else {
339
+ Mage::getSingleton('checkout/session')->addError(
340
+ $this->__('Coupon code "%s" is not valid.', Mage::helper('core')->htmlEscape($couponData['code']))
341
+ );
342
+ }
343
+ $method = str_replace(' ', '', ucwords(str_replace('-', ' ', 'coupon-discount')));
344
+ $result['update_section']['coupon-discount'] = $this->{'_get' . $method . 'Html'}();
345
+
346
+ }
347
+ /************************************/
348
+
349
+
350
+
351
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
352
+ }
353
+
354
+ public function forgotpasswordAction()
355
+ {
356
+ $session = Mage::getSingleton('customer/session');
357
+
358
+ if ($this->_expireAjax() || $session->isLoggedIn()) {
359
+ return;
360
+ }
361
+
362
+ $email = $this->getRequest()->getPost('email');
363
+ $result = array('success' => false);
364
+
365
+ if (!$email)
366
+ {
367
+ $result['error'] = Mage::helper('customer')->__('Please enter your email.');
368
+ }
369
+ else
370
+ {
371
+ if (!Zend_Validate::is($email, 'EmailAddress'))
372
+ {
373
+ $session->setForgottenEmail($email);
374
+ $result['error'] = Mage::helper('checkout')->__('Invalid email address.');
375
+ }
376
+ else
377
+ {
378
+ $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
379
+ if(!$customer->getId())
380
+ {
381
+ $session->setForgottenEmail($email);
382
+ $result['error'] = Mage::helper('customer')->__('This email address was not found in our records.');
383
+ }
384
+ else
385
+ {
386
+ try
387
+ {
388
+ $new_pass = $customer->generatePassword();
389
+ $customer->changePassword($new_pass, false);
390
+ $customer->sendPasswordReminderEmail();
391
+ $result['success'] = true;
392
+ $result['message'] = Mage::helper('customer')->__('A new password has been sent.');
393
+ }
394
+ catch (Exception $e)
395
+ {
396
+ $result['error'] = $e->getMessage();
397
+ }
398
+ }
399
+ }
400
+ }
401
+
402
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
403
+ }
404
+
405
+ public function loginAction()
406
+ {
407
+ $session = Mage::getSingleton('customer/session');
408
+ if ($this->_expireAjax() || $session->isLoggedIn()) {
409
+ return;
410
+ }
411
+
412
+ $result = array('success' => false);
413
+
414
+ if ($this->getRequest()->isPost())
415
+ {
416
+ $login_data = $this->getRequest()->getPost('login');
417
+ if (empty($login_data['username']) || empty($login_data['password'])) {
418
+ $result['error'] = Mage::helper('customer')->__('Login and password are required.');
419
+ }
420
+ else
421
+ {
422
+ try
423
+ {
424
+ $session->login($login_data['username'], $login_data['password']);
425
+ $result['success'] = true;
426
+ $result['redirect'] = Mage::getUrl('*/*/index');
427
+ }
428
+ catch (Mage_Core_Exception $e)
429
+ {
430
+ switch ($e->getCode()) {
431
+ case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
432
+ $message = Mage::helper('customer')->__('Email is not confirmed. <a href="%s">Resend confirmation email.</a>', Mage::helper('customer')->getEmailConfirmationUrl($login_data['username']));
433
+ break;
434
+ default:
435
+ $message = $e->getMessage();
436
+ }
437
+ $result['error'] = $message;
438
+ $session->setUsername($login_data['username']);
439
+ }
440
+ }
441
+ }
442
+
443
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
444
+ }
445
+
446
+ public function saveOrderAction()
447
+ {
448
+ if ($this->_expireAjax()) {
449
+ return;
450
+ }
451
+
452
+ $result = array();
453
+ try {
454
+ $bill_data = $this->_filterPostData($this->getRequest()->getPost('billing', array()));
455
+
456
+ // $result = $this->getOnepagecheckout()->saveBilling($bill_data,$this->getRequest()->getPost('billing_address_id', false));
457
+ $result = $this->getOnepagecheckout()->saveBilling($bill_data,$this->getRequest()->getPost('billing_address_id', false),true,true);
458
+ if ($result)
459
+ {
460
+ $result['error_messages'] = $result['message'];
461
+ $result['error'] = true;
462
+ $result['success'] = false;
463
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
464
+ return;
465
+ }
466
+
467
+ if ((!$bill_data['use_for_shipping'] || !isset($bill_data['use_for_shipping'])) && !$this->getOnepagecheckout()->getQuote()->isVirtual())
468
+ {
469
+ // $result = $this->getOnepagecheckout()->saveShipping($this->_filterPostData($this->getRequest()->getPost('shipping', array())),$this->getRequest()->getPost('shipping_address_id', false));
470
+ $result = $this->getOnepagecheckout()->saveShipping($this->_filterPostData($this->getRequest()->getPost('shipping', array())),$this->getRequest()->getPost('shipping_address_id', false), true, true);
471
+ if ($result)
472
+ {
473
+ $result['error_messages'] = $result['message'];
474
+ $result['error'] = true;
475
+ $result['success'] = false;
476
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
477
+ return;
478
+ }
479
+ }
480
+
481
+ $agreements = Mage::helper('onepagecheckout')->getAgreeIds();
482
+ if($agreements)
483
+ {
484
+ $post_agree = array_keys($this->getRequest()->getPost('agreement', array()));
485
+ $is_different = array_diff($agreements, $post_agree);
486
+ if ($is_different)
487
+ {
488
+ $result['error_messages'] = Mage::helper('checkout')->__('Please agree to all the terms and conditions.');
489
+ $result['error'] = true;
490
+ $result['success'] = false;
491
+
492
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
493
+ return;
494
+ }
495
+ }
496
+
497
+ $result = $this->_saveOrderPurchase();
498
+
499
+ if($result && !isset($result['redirect']))
500
+ {
501
+ $result['error_messages'] = $result['error'];
502
+ }
503
+
504
+ if(!isset($result['error']))
505
+ {
506
+ Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request'=>$this->getRequest(), 'quote'=>$this->getOnepagecheckout()->getQuote()));
507
+ $this->_subscribeNews();
508
+ }
509
+
510
+ Mage::getSingleton('customer/session')->setOrderCustomerComment($this->getRequest()->getPost('order-comment'));
511
+
512
+ if (!isset($result['redirect']) && !isset($result['error']))
513
+ {
514
+ $pmnt_data = $this->getRequest()->getPost('payment', false);
515
+ if ($pmnt_data)
516
+ $this->getOnepagecheckout()->getQuote()->getPayment()->importData($pmnt_data);
517
+
518
+ $this->getOnepagecheckout()->saveOrder();
519
+ $redirectUrl = $this->getOnepagecheckout()->getCheckout()->getRedirectUrl();
520
+
521
+ $result['success'] = true;
522
+ $result['error'] = false;
523
+ $result['order_created'] = true;
524
+ }
525
+ }
526
+ catch (Mage_Core_Exception $e)
527
+ {
528
+ Mage::logException($e);
529
+ Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepagecheckout()->getQuote(), $e->getMessage());
530
+
531
+ $result['error_messages'] = $e->getMessage();
532
+ $result['error'] = true;
533
+ $result['success'] = false;
534
+
535
+ $goto_section = $this->getOnepagecheckout()->getCheckout()->getGotoSection();
536
+ if ($goto_section)
537
+ {
538
+ $this->getOnepagecheckout()->getCheckout()->setGotoSection(null);
539
+ $result['goto_section'] = $goto_section;
540
+ }
541
+
542
+ $update_section = $this->getOnepagecheckout()->getCheckout()->getUpdateSection();
543
+ if ($update_section)
544
+ {
545
+ if (isset($this->_sectionUpdateFunctions[$update_section]))
546
+ {
547
+ $layout = $this->_getUpdatedLayout();
548
+
549
+ $updateSectionFunction = $this->_sectionUpdateFunctions[$update_section];
550
+ $result['update_section'] = array(
551
+ 'name' => $update_section,
552
+ 'html' => $this->$updateSectionFunction()
553
+ );
554
+ }
555
+ $this->getOnepagecheckout()->getCheckout()->setUpdateSection(null);
556
+ }
557
+
558
+ $this->getOnepagecheckout()->getQuote()->save();
559
+ }
560
+ catch (Exception $e)
561
+ {
562
+ Mage::logException($e);
563
+ Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepagecheckout()->getQuote(), $e->getMessage());
564
+ $result['error_messages'] = Mage::helper('checkout')->__('There was an error processing your order. Please contact support or try again later.');
565
+ $result['error'] = true;
566
+ $result['success'] = false;
567
+
568
+ $this->getOnepagecheckout()->getQuote()->save();
569
+ }
570
+
571
+ if (isset($redirectUrl)) {
572
+ $result['redirect'] = $redirectUrl;
573
+ }
574
+
575
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
576
+ }
577
+
578
+ protected function _saveOrderPurchase()
579
+ {
580
+ $result = array();
581
+
582
+ try
583
+ {
584
+ $pmnt_data = $this->getRequest()->getPost('payment', array());
585
+ $result = $this->getOnepagecheckout()->savePayment($pmnt_data);
586
+
587
+ $redirectUrl = $this->getOnepagecheckout()->getQuote()->getPayment()->getCheckoutRedirectUrl();
588
+ if ($redirectUrl)
589
+ {
590
+ $result['redirect'] = $redirectUrl;
591
+ }
592
+ }
593
+ catch (Mage_Payment_Exception $e)
594
+ {
595
+ if ($e->getFields()) {
596
+ $result['fields'] = $e->getFields();
597
+ }
598
+ $result['error'] = $e->getMessage();
599
+ }
600
+ catch (Mage_Core_Exception $e)
601
+ {
602
+ $result['error'] = $e->getMessage();
603
+ }
604
+ catch (Exception $e)
605
+ {
606
+ Mage::logException($e);
607
+ $result['error'] = Mage::helper('checkout')->__('Unable to set Payment Method.');
608
+ }
609
+ return $result;
610
+ }
611
+
612
+ protected function _subscribeNews()
613
+ {
614
+ if ($this->getRequest()->isPost() && $this->getRequest()->getPost('newsletter'))
615
+ {
616
+ $customerSession = Mage::getSingleton('customer/session');
617
+
618
+ if($customerSession->isLoggedIn())
619
+ $email = $customerSession->getCustomer()->getEmail();
620
+ else
621
+ {
622
+ $bill_data = $this->getRequest()->getPost('billing');
623
+ $email = $bill_data['email'];
624
+ }
625
+
626
+ try {
627
+ if (!$customerSession->isLoggedIn() && Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1)
628
+ Mage::throwException(Mage::helper('newsletter')->__('Sorry, subscription for guests is not allowed. Please <a href="%s">register</a>.', Mage::getUrl('customer/account/create/')));
629
+
630
+ $ownerId = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email)->getId();
631
+
632
+ if ($ownerId !== null && $ownerId != $customerSession->getId())
633
+ Mage::throwException(Mage::helper('newsletter')->__('Sorry, you are trying to subscribe email assigned to another user.'));
634
+
635
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
636
+ }
637
+ catch (Mage_Core_Exception $e) {
638
+ }
639
+ catch (Exception $e) {
640
+ }
641
+ }
642
+ }
643
+
644
+ protected function _filterPostData($data)
645
+ {
646
+ $data = $this->_filterDates($data, array('dob'));
647
+ return $data;
648
+ }
649
+
650
+ protected function _checkChangedAddress($data, $addr_type = 'Billing', $addr_id = false)
651
+ {
652
+ $method = "get{$addr_type}Address";
653
+ $address = $this->getOnepagecheckout()->getQuote()->{$method}();
654
+
655
+ if(!$addr_id)
656
+ {
657
+ if(($address->getRegionId() != $data['region_id']) || ($address->getPostcode() != $data['postcode']) || ($address->getCountryId() != $data['country_id']))
658
+ return true;
659
+ else
660
+ return false;
661
+ }
662
+ else{
663
+ if($addr_id != $address->getCustomerAddressId())
664
+ return true;
665
+ else
666
+ return false;
667
+ }
668
+ }
669
+ }
app/code/community/Swift/OnepageCheckout/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <onepagecheckout translate="title" module="onepagecheckout">
12
+ <title>One Page Checkout Section</title>
13
+ </onepagecheckout>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Swift/OnepageCheckout/etc/config.xml ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <modules>
4
+ <Swift_OnepageCheckout>
5
+ <version>1.0.0</version>
6
+ </Swift_OnepageCheckout>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <onepagecheckout>
12
+ <class>Swift_OnepageCheckout_Model</class>
13
+ </onepagecheckout>
14
+ <onepagecheckout_adminhtml>
15
+ <class>Swift_OnepageCheckout_Adminhtml_Model</class>
16
+ </onepagecheckout_adminhtml>
17
+ </models>
18
+ <blocks>
19
+ <checkout>
20
+ <rewrite>
21
+ <links>Swift_OnepageCheckout_Block_Links</links>
22
+ </rewrite>
23
+ </checkout>
24
+ <onepagecheckout>
25
+ <class>Swift_OnepageCheckout_Block</class>
26
+ </onepagecheckout>
27
+ </blocks>
28
+ <helpers>
29
+ <checkout>
30
+ <rewrite>
31
+ <url>Swift_OnepageCheckout_Helper_Url</url>
32
+ </rewrite>
33
+ </checkout>
34
+ <onepagecheckout>
35
+ <class>Swift_OnepageCheckout_Helper</class>
36
+ </onepagecheckout>
37
+ </helpers>
38
+ </global>
39
+
40
+ <frontend>
41
+ <routers>
42
+ <onepagecheckout>
43
+ <use>standard</use>
44
+ <args>
45
+ <module>Swift_OnepageCheckout</module>
46
+ <frontName>onepagecheckout</frontName>
47
+ </args>
48
+ </onepagecheckout>
49
+ </routers>
50
+ <translate>
51
+ <modules>
52
+ <Swift_OnepageCheckout>
53
+ <files>
54
+ <default>Swift_OnepageCheckout.csv</default>
55
+ </files>
56
+ </Swift_OnepageCheckout>
57
+ </modules>
58
+ </translate>
59
+ <layout>
60
+ <updates>
61
+ <onepagecheckout>
62
+ <file>onepagecheckout.xml</file>
63
+ </onepagecheckout>
64
+ </updates>
65
+ </layout>
66
+ <events>
67
+ <sales_model_service_quote_submit_after>
68
+ <observers>
69
+ <onepagecheckout>
70
+ <type>model</type>
71
+ <class>onepagecheckout/observer</class>
72
+ <method>removeHistoryComment</method>
73
+ </onepagecheckout>
74
+ </observers>
75
+ </sales_model_service_quote_submit_after>
76
+ <sales_model_service_quote_submit_before>
77
+ <observers>
78
+ <onepagecheckout>
79
+ <type>model</type>
80
+ <class>onepagecheckout/observer</class>
81
+ <method>addHistoryComment</method>
82
+ </onepagecheckout>
83
+ </observers>
84
+ </sales_model_service_quote_submit_before>
85
+
86
+ <controller_action_layout_render_before_checkout_cart_index>
87
+ <observers>
88
+ <onepagecheckout>
89
+ <class>onepagecheckout/observer</class>
90
+ <method>setEmptyCartTemplate</method>
91
+ </onepagecheckout>
92
+ </observers>
93
+ </controller_action_layout_render_before_checkout_cart_index>
94
+
95
+ </events>
96
+ </frontend>
97
+
98
+ <adminhtml>
99
+ <translate>
100
+ <modules>
101
+ <Swift_OnepageCheckout>
102
+ <files>
103
+ <default>Swift_OnepageCheckout.csv</default>
104
+ </files>
105
+ </Swift_OnepageCheckout>
106
+ </modules>
107
+ </translate>
108
+ <acl>
109
+ <resources>
110
+ <admin>
111
+ <children>
112
+ <system>
113
+ <children>
114
+ <config>
115
+ <children>
116
+ <onepagecheckout translate="title" module="onepagecheckout">
117
+ <title>One Page Checkout Section</title>
118
+ </onepagecheckout>
119
+ </children>
120
+ </config>
121
+ </children>
122
+ </system>
123
+ </children>
124
+ </admin>
125
+ </resources>
126
+ </acl>
127
+ </adminhtml>
128
+
129
+ <default>
130
+ <onepagecheckout>
131
+ <general>
132
+ <enabled>0</enabled>
133
+ <title>One Page Checkout</title>
134
+
135
+ <payment_method>paypal_express</payment_method>
136
+ <country>US</country>
137
+ <guest_checkout>1</guest_checkout>
138
+ <shipping_address>1</shipping_address>
139
+ <newsletter_checkbox>1</newsletter_checkbox>
140
+ <comment>0</comment>
141
+ </general>
142
+
143
+ </onepagecheckout>
144
+ </default>
145
+ <admin>
146
+ <routers>
147
+ <onepagecheckout>
148
+ <use>admin</use>
149
+ <args>
150
+ <module>Swift_OnepageCheckout</module>
151
+ <frontName>onepagecheckout</frontName>
152
+ </args>
153
+ </onepagecheckout>
154
+ </routers>
155
+ </admin>
156
+ </config>
app/code/community/Swift/OnepageCheckout/etc/system.xml ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <swift>
5
+ <label>Swift</label>
6
+ <sort_order>200</sort_order>
7
+ </swift>
8
+ </tabs>
9
+ <sections>
10
+ <onepagecheckout translate="label" module="onepagecheckout">
11
+ <label>Swift Checkout</label>
12
+ <tab>swift</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>10</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <general translate="label" module="core">
20
+ <label>General</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <enabled translate="label" module="core">
28
+ <label>Enabled</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </enabled>
36
+ <title translate="label" module="cms">
37
+ <label>Page Title</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>10</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </title>
44
+ <!-- shipping_method translate="label" module="onepagecheckout">
45
+ <label>Default Shipping Method</label>
46
+ <frontend_type>select</frontend_type>
47
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
48
+ <sort_order>20</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ </shipping_method -->
53
+ <payment_method translate="label" module="onepagecheckout">
54
+ <label>Default Payment Method</label>
55
+ <frontend_type>select</frontend_type>
56
+ <source_model>adminhtml/system_config_source_payment_allmethods</source_model>
57
+ <sort_order>30</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ </payment_method>
62
+ <country translate="label" module="onepagecheckout">
63
+ <label>Default Country</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_country</source_model>
66
+ <sort_order>40</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </country>
71
+ <guest_checkout translate="label" module="checkout">
72
+ <label>Allow Guest Checkout</label>
73
+ <frontend_type>select</frontend_type>
74
+ <source_model>adminhtml/system_config_source_yesno</source_model>
75
+ <sort_order>60</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ </guest_checkout>
80
+ <shipping_address translate="label" module="onepagecheckout">
81
+ <label>Show Shipping Address Form</label>
82
+ <frontend_type>select</frontend_type>
83
+ <source_model>adminhtml/system_config_source_yesno</source_model>
84
+ <sort_order>70</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </shipping_address>
89
+ <newsletter_checkbox translate="label" module="onepagecheckout">
90
+ <label>Show Subscribe to Newsletter Checkbox</label>
91
+ <frontend_type>select</frontend_type>
92
+ <source_model>adminhtml/system_config_source_yesno</source_model>
93
+ <sort_order>80</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ </newsletter_checkbox>
98
+ <comment translate="label" module="onepagecheckout">
99
+ <label>Show Comment Field</label>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>90</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ </comment>
107
+ </fields>
108
+ </general>
109
+ <!-- <agreements translate="label" module="checkout">
110
+ <label>Terms and Conditions</label>
111
+ <frontend_type>text</frontend_type>
112
+ <sort_order>40</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ <fields>
117
+ <enabled translate="label">
118
+ <label>Enable Terms and Conditions</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>adminhtml/system_config_source_yesno</source_model>
121
+ <sort_order>10</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ </enabled>
126
+ <output translate="label" module="onepagecheckout">
127
+ <label>Output Type</label>
128
+ <frontend_type>select</frontend_type>
129
+ <source_model>onepagecheckout_adminhtml/system_config_source_agreementOptions</source_model>
130
+ <sort_order>20</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ </output>
135
+ </fields>
136
+ </agreements> -->
137
+ </groups>
138
+ </onepagecheckout>
139
+ </sections>
140
+ </config>
app/design/frontend/base/default/layout/onepagecheckout.xml ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+
4
+ <onepagecheckout_index_index translate="label">
5
+ <label>Swift Checkout</label>
6
+ <remove name="left"/>
7
+ <remove name="right"/>
8
+ <reference name="root">
9
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
10
+ </reference>
11
+ <reference name="head">
12
+ <action method="addItem" ifconfig="onepagecheckout/general/enabled"><type>skin_css</type><name>css/onepagecheckout.css</name></action>
13
+ </reference>
14
+ <reference name="content">
15
+ <block type="checkout/onepage" name="onepagecheckout" template="onepagecheckout/onepagecheckout.phtml">
16
+ <block type="customer/form_login" name="customer.login" template="onepagecheckout/login.phtml"/>
17
+ <block type="customer/account_forgotpassword" name="customer.forgot" template="onepagecheckout/forgotpassword.phtml"/>
18
+
19
+ <block type="onepagecheckout/onepage_billship" name="checkout.onepage.billing" as="billing.address" template="onepagecheckout/onepage/billing.phtml"/>
20
+ <block type="onepagecheckout/onepage_billship" name="checkout.onepage.shipping" as="shipping.address" template="onepagecheckout/onepage/shipping.phtml"/>
21
+
22
+ <block type="checkout/onepage_shipping_method" name="checkout.onepage.shipping_method" as="shipping.method" template="onepagecheckout/onepage/shipping_method.phtml">
23
+ <block type="checkout/onepage_shipping_method_available" name="checkout.onepage.shipping_method.available" as="available" template="checkout/onepage/shipping_method/available.phtml"/>
24
+ <block type="checkout/onepage_shipping_method_additional" name="checkout.onepage.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
25
+ </block>
26
+
27
+ <block type="checkout/onepage_payment" name="checkout.onepage.payment" as="payment.method" template="onepagecheckout/onepage/payment.phtml">
28
+ <block type="checkout/onepage_payment_methods" name="checkout.payment.methods" as="methods" template="onepagecheckout/onepage/payment/methods.phtml">
29
+ <action method="setMethodFormTemplate"><method>purchaseorder</method><template>payment/form/purchaseorder.phtml</template></action>
30
+ </block>
31
+ </block>
32
+
33
+ <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="onepagecheckout/onepage/coupon.phtml"/>
34
+
35
+
36
+ <block type="checkout/onepage_review" name="checkout.onepage.review" as="review" template="onepagecheckout/onepage/review.phtml">
37
+ <block type="onepagecheckout/agreements" name="checkout.onepage.agreements" as="agreements" template="onepagecheckout/onepage/agreements.phtml"/>
38
+ <block type="checkout/onepage_review_info" name="info" template="onepagecheckout/onepage/review/info.phtml">
39
+ <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>onepagecheckout/onepage/review/item.phtml</template></action>
40
+ <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>onepagecheckout/onepage/review/item.phtml</template></action>
41
+ <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>onepagecheckout/onepage/review/item.phtml</template></action>
42
+ <block type="checkout/cart_totals" name="checkout.onepage.review.info.totals" as="totals" template="onepagecheckout/onepage/review/totals.phtml"/>
43
+ <block type="core/text_list" name="checkout.onepage.review.info.items.before" as="items_before"/>
44
+ </block>
45
+ </block>
46
+ </block>
47
+ </reference>
48
+ </onepagecheckout_index_index>
49
+
50
+ <checkout_cart_index>
51
+ <reference name="checkout.cart.top_methods">
52
+ <action method="unsetChild" ifconfig="onepagecheckout/general/enabled"><name>checkout.cart.methods.onepage</name></action>
53
+ </reference>
54
+ <reference name="checkout.cart.methods">
55
+ <action method="unsetChild" ifconfig="onepagecheckout/general/enabled"><name>checkout.cart.methods.onepage</name></action>
56
+ </reference>
57
+ <reference name="checkout.cart.top_methods">
58
+ <block type="onepagecheckout/onepage_link" name="checkout.cart.methods.fire" template="onepagecheckout/onepage/link.phtml"/>
59
+ </reference>
60
+ <reference name="checkout.cart.methods">
61
+ <block type="onepagecheckout/onepage_link" name="checkout.cart.methods.fire" template="onepagecheckout/onepage/link.phtml" before="checkout.cart.methods.multishipping"/>
62
+ </reference>
63
+ </checkout_cart_index>
64
+
65
+ <onepagecheckout_index_updatecheckout>
66
+ <remove name="right"/>
67
+ <remove name="left"/>
68
+ <block type="checkout/onepage_payment_methods" name="checkout.payment.method" template="onepagecheckout/onepage/payment/methods.phtml">
69
+ <action method="setMethodFormTemplate"><method>purchaseorder</method><template>payment/form/purchaseorder.phtml</template></action>
70
+ </block>
71
+ <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="onepagecheckout/onepage/coupon.phtml"/>
72
+ <block type="checkout/onepage_shipping_method_available" name="checkout.shipping.method" template="checkout/onepage/shipping_method/available.phtml"/>
73
+ <block type="checkout/onepage_review_info" name="checkout.review" template="onepagecheckout/onepage/review/info.phtml">
74
+ <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>onepagecheckout/onepage/review/item.phtml</template></action>
75
+ <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>onepagecheckout/onepage/review/item.phtml</template></action>
76
+ <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>onepagecheckout/onepage/review/item.phtml</template></action>
77
+ <block type="checkout/cart_totals" name="checkout.onepage.review.info.totals" as="totals" template="onepagecheckout/onepage/review/totals.phtml"/>
78
+ <block type="core/text_list" name="checkout.onepage.review.info.items.before" as="items_before"/>
79
+ </block>
80
+ </onepagecheckout_index_updatecheckout>
81
+
82
+ <onepagecheckout_index_success translate="label">
83
+ <reference name="root">
84
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
85
+ </reference>
86
+ <reference name="content">
87
+ <block type="checkout/onepage_success" name="checkout.success" template="checkout/success.phtml"/>
88
+ </reference>
89
+ </onepagecheckout_index_success>
90
+
91
+ <onepagecheckout_index_failure translate="label">
92
+ <reference name="root">
93
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
94
+ </reference>
95
+ <reference name="content">
96
+ <block type="checkout/onepage_failure" name="checkout.failure" template="checkout/onepage/failure.phtml"/>
97
+ </reference>
98
+ </onepagecheckout_index_failure>
99
+ </layout>
app/design/frontend/base/default/template/onepagecheckout/cart/noItems.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <div class="page-title">
2
+ <h1><?php echo $this->__('Shopping Cart is Empty') ?></h1>
3
+ </div>
4
+ <div class="cart-empty">
5
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
6
+ <?php echo $this->getChildHtml('checkout_cart_empty_widget'); ?>
7
+ <p><?php echo $this->__('You have no items in your shopping cart.') ?></p>
8
+ <p><?php echo $this->__('Click <a href="%s">here</a> to continue shopping.', $this->getContinueShoppingUrl()) ?></p>
9
+ <?php echo $this->getChildHtml('shopping.cart.table.after'); ?>
10
+ </div>
app/design/frontend/base/default/template/onepagecheckout/forgotpassword.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!Mage::getSingleton('customer/session')->isLoggedIn()){?>
2
+ <div id="onepagecheckout_forgotbox" style="display: none;" class='op_login_area'>
3
+ <div class='close_la' onclick='close_login();'></div>
4
+ <div class="page-title">
5
+ <span><?php echo $this->__('Forgot Password?') ?></span>
6
+ </div>
7
+ <?php
8
+ $forgot_url = $this->getUrl('*/*/forgotpassword', array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on')));
9
+ $http_mode = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on');
10
+ if($http_mode)
11
+ $forgot_url = str_replace('http:', 'https:', $forgot_url);
12
+ ?>
13
+ <form action="<?php echo $forgot_url ?>" method="post" id="forgot-password-form">
14
+ <div class="boxcontent form_fields">
15
+ <p><?php echo $this->__('Please enter your email id') ?></p>
16
+ <div class='full'>
17
+ <label>
18
+ <?php echo $this->__('Email') ?>
19
+ </label>
20
+ <sup>*</sup>
21
+ <div class="data_area">
22
+ <input type="text" name="email" alt="email" id="email_address" class="input-text required-entry validate-email" value="<?php echo $this->htmlEscape($this->getEmailValue()) ?>" />
23
+ </div>
24
+ </div>
25
+ </div>
26
+ <div class="buttons-set">
27
+ <p class="back-link"><a href="javascript:void(0)" class="onepagecheckout_loginlink" onclick='open_login();'><small>&laquo; </small><?php echo $this->__('Back to Login') ?></a></p>
28
+ <button type="submit" title="<?php echo $this->__('Submit') ?>" id="btn-forgot" class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
29
+ <span class="please-wait" id="forgot-please-wait" style="display:none;">
30
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" class="v-middle" alt=""/>
31
+ </span>
32
+ </div>
33
+ </form>
34
+ <script type="text/javascript">
35
+ //<![CDATA[
36
+ var forgotForm = new VarienForm('forgot-password-form', true);
37
+ //]]>
38
+ </script>
39
+ </div>
40
+ <?php }?>
app/design/frontend/base/default/template/onepagecheckout/login.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!Mage::getSingleton('customer/session')->isLoggedIn()){?>
2
+ <div id="onepagecheckout_loginbox" style="display: none;" class='op_login_area'>
3
+ <div class='close_la' onclick='close_login();'></div>
4
+ <div class="page-title">
5
+ <span><?php echo $this->__('Login to your Account') ?></span>
6
+ </div>
7
+ <?php
8
+ $login_url = $this->getUrl('*/*/login', array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on')));
9
+ $http_mode = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on');
10
+ if($http_mode)
11
+ $login_url = str_replace('http:', 'https:', $login_url);
12
+ ?>
13
+ <form method="post" id="login-form" action="<?php echo $login_url ?>">
14
+ <div class="boxcontent form_fields">
15
+ <div class='full'>
16
+ <label>
17
+ <?php echo $this->__('Email Address') ?>
18
+ </label>
19
+ <sup>*</sup>
20
+ <div class="data_area">
21
+ <input type="text" name="login[username]" value="<?php echo $this->htmlEscape($this->getUsername()) ?>" id="email" class="input-text required-entry validate-email" title="<?php echo $this->__('Email Address') ?>" />
22
+ </div>
23
+ </div>
24
+ <div class='full'>
25
+ <label>
26
+ <?php echo $this->__('Password') ?>
27
+ </label>
28
+ <sup>*</sup>
29
+ <div class="input-box">
30
+ <input type="password" name="login[password]" class="input-text required-entry validate-password" id="pass" title="<?php echo $this->__('Password') ?>" />
31
+ </div>
32
+ </div>
33
+ </div>
34
+ <div class="buttons-set">
35
+ <a href="javascript:void(0);" class="f-left onepagecheckout_forgotlink" onclick='open_forgot();'><?php echo $this->__('Forgot Your Password?') ?></a>
36
+ <button type="submit" class="button" title="<?php echo $this->__('Login') ?>" name="send" id="send2"><span><span><?php echo $this->__('Login') ?></span></span></button>
37
+ <span class="please-wait" id="login-please-wait" style="display:none;">
38
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" class="v-middle" alt=""/>
39
+ </span>
40
+ </div>
41
+ </form>
42
+ <script type="text/javascript">
43
+ //<![CDATA[
44
+ var loginForm = new VarienForm('login-form', true);
45
+ //]]>
46
+ </script>
47
+ </div>
48
+ <?php }?>
app/design/frontend/base/default/template/onepagecheckout/onepage/agreements.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!$_agree = $this->getAgreements()) return; ?>
2
+ <ol class="checkout-agreements">
3
+ <?php $_i = 0; foreach ($_agree as $_a): ?>
4
+ <li<?php echo ++$_i === count($_agree) ? ' class="last"' : ''?>>
5
+ <div id="onepagecheckout-agreement-<?php echo $_a->getId() ?>-window"
6
+ class="agreement-content"
7
+ style="<?php echo ($_a->getContentHeight() ? 'height:' . $_a->getContentHeight() : '') ?> <?php echo ('minimal' === Mage::getStoreConfig('onepagecheckout/agreements/output')) ? 'display: none' : '' ?>"
8
+ >
9
+ <?php if ('minimal' === Mage::getStoreConfig('onepagecheckout/agreements/output')) : ?>
10
+ <div class="page-title">
11
+ <span><?php echo $this->htmlEscape($_a->getName()) ?></span>
12
+ </div>
13
+ <?php endif; ?>
14
+ <?php if ($_a->getIsHtml()):?>
15
+ <?php echo $_a->getContent() ?>
16
+ <?php else:?>
17
+ <?php echo nl2br($this->htmlEscape($_a->getContent())) ?>
18
+ <?php endif; ?>
19
+ </div>
20
+ <p class="agree">
21
+ <input type="checkbox" id="agreement-<?php echo $_a->getId()?>" name="agreement[<?php echo $_a->getId()?>]" value="1" title="<?php echo $this->htmlEscape($_a->getCheckboxText()) ?>" class="checkbox" />
22
+ <?php if ('minimal' === Mage::getStoreConfig('onepagecheckout/agreements/output')) : ?>
23
+ <label for="agreement-<?php echo $_a->getId()?>">
24
+ <a href="javascript:void(0)" class="onepagecheckout-agreement-<?php echo $_a->getId() ?>">
25
+ <?php echo $this->htmlEscape($_a->getCheckboxText()) ?>
26
+ </a>
27
+ </label>
28
+ <?php else: ?>
29
+ <label for="agreement-<?php echo $_a->getId()?>">
30
+ <?php echo $this->htmlEscape($_a->getCheckboxText()) ?>
31
+ </label>
32
+ <?php endif; ?>
33
+ </p>
34
+ </li>
35
+ <?php endforeach ?>
36
+ </ol>
app/design/frontend/base/default/template/onepagecheckout/onepage/billing.phtml ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $logged = $this->isCustomerLoggedIn();
3
+ $has_addr = $this->customerHasAddresses();
4
+ ?>
5
+ <div class="onepagecheckout_block">
6
+ <div class="op_block_title">
7
+ <?php echo $this->__('Name & Address'); ?>
8
+ </div>
9
+ <div class="form_fields">
10
+ <?php if ($has_addr){ ?>
11
+ <div class="full">
12
+ <label for="billing_cutomer_address">
13
+ <?php echo $this->__('Select a billing address from your address book or enter a new address.') ?>
14
+ </label>
15
+ <div class="data_area">
16
+ <?php echo $this->getCustomerBillAddr() ?>
17
+ </div>
18
+ </div>
19
+ <?php } ?>
20
+ <div id="bill_form"<?php if ($has_addr) {echo ' style="display:none;" ';} ?>>
21
+ <input type="hidden" name="billing[address_id]" id="billing:address_id" value="<?php echo $this->getBillAddress()->getId() ?>" />
22
+ <div class="two_fields">
23
+ <?php echo $this->getLayout()->createBlock('onepagecheckout/widget_name')->setObject($this->getBillAddress())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
24
+ </div>
25
+ <div class='clr'></div>
26
+ <?php if (!$logged) : ?>
27
+ <div class="full">
28
+ <label for="billing:email" class="required">
29
+ <?php echo $this->__('Email Address') ?>
30
+ </label>
31
+ <sup>*</sup>
32
+ <div class="data_area">
33
+ <input type="text" name="billing[email]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="t1 validate-email required-entry" />
34
+ </div>
35
+ </div>
36
+ <?php endif;
37
+
38
+ $cr = Mage::getStoreConfig('onepagecheckout/address_form/company');
39
+ if ($cr !== 'hidden') : ?>
40
+ <div class="full">
41
+ <label for="billing:company" <?php if ( $cr === 'required' ){ echo 'class="required"'; }?> >
42
+ <?php echo $this->__('Company') ?>
43
+ </label>
44
+ <?php if ($cr === 'required'){echo "<sup>*</sup'>";}?>
45
+ <div class="data_area">
46
+ <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="t1<?php if($cr === 'required'){ echo ' required-entry';} ?>" />
47
+ </div>
48
+ </div>
49
+ <?php endif;
50
+
51
+ $ar = Mage::getStoreConfig('onepagecheckout/address_form/address');
52
+ if ($ar !== 'hidden') :
53
+ ?>
54
+ <div class="full">
55
+ <label for="billing:street1"<?php if($ar === 'required'){echo ' class="required" ';}?> >
56
+ <?php echo $this->__('Address') ?>
57
+ </label>
58
+ <?php if($ar === 'required'){echo '<sup>*</sup>';}?>
59
+ <div class="data_area">
60
+ <input type="text" title="<?php echo $this->__('Street Address') ?>" name="billing[street][]" id="billing:street1" value="<?php echo $this->htmlEscape($this->getBillAddress()->getStreet(1)) ?>" class="t1<?php if($ar === 'required'){echo ' required-entry';}?>" />
61
+ </div>
62
+ </div>
63
+ <?php
64
+ $csl = $this->helper('customer/address')->getStreetLines();
65
+ for ($i = 2; $i <= $csl; $i++){
66
+ ?>
67
+ <div class="full">
68
+ <div class="data_area">
69
+ <input type="text" name="billing[street][]" id="billing:street<?php echo $i?>" title="<?php echo $this->__('Street Address %s', $i) ?>" value="<?php echo $this->htmlEscape($this->getBillAddress()->getStreet($i)) ?>" class="t1" />
70
+ </div>
71
+ </div>
72
+ <?php
73
+ }
74
+
75
+ endif;
76
+
77
+ $city_r = Mage::getStoreConfig('onepagecheckout/address_form/city');
78
+ $state_r= Mage::getStoreConfig('onepagecheckout/address_form/state');
79
+ ?>
80
+ <div class="two_fields"<?php if(($city_r === 'hidden' && $state_r === 'hidden')){echo ' style="display:none"';}?> >
81
+ <?php if ($city_r !== 'hidden') : ?>
82
+ <div class="short">
83
+ <label for="billing:city"<?php if ($city_r === 'required'){ echo ' class="required" ';}?>>
84
+ <?php echo $this->__('City') ?>
85
+ </label>
86
+ <?php if ($city_r === 'required'){ echo ' <sup>*</sup> ';}?>
87
+ <div class="data_area">
88
+ <input type="text" title="<?php echo $this->__('City') ?>" name="billing[city]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getCity()) ?>" class="t1<?php if ($city_r === 'required'){ echo ' required-entry ';}?>" id="billing:city" />
89
+ </div>
90
+ </div>
91
+ <?php endif; ?>
92
+ <div class="short"<?php if($state_r === 'hidden'){ echo ' style="display:none" ';}?>>
93
+ <label for="billing:region_id"<?php if($state_r === 'required'){ echo ' class="required" ';}?>>
94
+ <?php echo $this->__('State / Province') ?>
95
+ </label>
96
+ <?php if($state_r === 'required'){ echo ' <sup>*</sup> ';}?>
97
+ <div class="data_area">
98
+ <select id="billing:region_id" name="billing[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select<?php if($state_r === 'required') { echo ' required-entry';}?>" style="display:none;">
99
+ <option value=""><?php echo $this->__('Select One') ?></option>
100
+ </select>
101
+ <script type="text/javascript">
102
+ //<![CDATA[
103
+ $('billing:region_id').setAttribute('defaultValue', "<?php echo $this->getBillAddress()->getRegionId() ?>");
104
+ //]]>
105
+ </script>
106
+ <input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="t1<?php if($state_r === 'required'){ echo ' required-entry';}?>" style="display:none;" />
107
+ </div>
108
+ </div>
109
+ </div>
110
+ <div class='clr'></div>
111
+ <?php
112
+ $zip_r = Mage::getStoreConfig('onepagecheckout/address_form/zip');
113
+ $phone_r= Mage::getStoreConfig('onepagecheckout/address_form/phone');
114
+ if ($zip_r !== 'hidden' || $phone_r !== 'hidden') :
115
+ ?>
116
+ <div class="two_fields">
117
+ <?php if ($zip_r !== 'hidden') : ?>
118
+ <div class="short">
119
+ <label for="billing:postcode"<?php if($zip_r === 'required'){echo ' class="required" ';}?>>
120
+ <?php echo $this->__('Zip Code') ?>
121
+ </label>
122
+ <?php if($zip_r === 'required'){echo ' <sup>*</sup>';}?>
123
+ <div class="data_area">
124
+ <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getBillAddress()->getPostcode()) ?>" class="t1 validate-zip-international<?php if($zip_r === 'required'){echo ' required-entry ';}?>" />
125
+ </div>
126
+ </div>
127
+ <?php endif; ?>
128
+ <?php if ($phone_r !== 'hidden') : ?>
129
+ <div class="short">
130
+ <label for="billing:telephone"<?php if($phone_r === 'required') { echo ' class="required" ';}?>>
131
+ <?php echo $this->__('Telephone') ?>
132
+ </label>
133
+ <?php if($phone_r === 'required') { echo ' <sup>*</sup> ';}?>
134
+ <div class="data_area">
135
+ <input type="text" name="billing[telephone]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="t1<?php if($phone_r === 'required') { echo ' required-entry ';}?>" id="billing:telephone" />
136
+ </div>
137
+ </div>
138
+ <?php endif; ?>
139
+ </div>
140
+ <div class='clr'></div>
141
+ <?php endif ?>
142
+
143
+ <?php
144
+ $country_r = Mage::getStoreConfig('onepagecheckout/address_form/country');
145
+ ?>
146
+ <div class="full"<?php if($country_r === 'hidden'){ echo ' style="display:none" ';}?>>
147
+ <label for="billing:country_id"<?php if($country_r === 'required') { echo ' class="required" ';}?>>
148
+ <?php echo $this->__('Country') ?>
149
+ </label>
150
+ <?php if($country_r === 'required') { echo ' <sup>*</sup> ';}?>
151
+ <div class="data_area">
152
+ <?php echo $this->getBillingCountriesSelectBox() ?>
153
+ </div>
154
+ </div>
155
+
156
+ <?php
157
+ $fax_r = Mage::getStoreConfig('onepagecheckout/address_form/fax');
158
+ if ($fax_r !== 'hidden') :
159
+ ?>
160
+ <div lang="two_fields">
161
+ <div class="short">
162
+ <label for="billing:fax"<?php if($fax_r === 'required') {echo ' class="required" ';}?>>
163
+ <?php echo $this->__('Fax') ?>
164
+ </label>
165
+ <?php if($fax_r === 'required') {echo ' <sup>*</sup> ';}?>
166
+ <div class="data_area">
167
+ <input type="text" name="billing[fax]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="t1<?php if($fax_r === 'required') {echo ' required-entry ';}?>" id="billing:fax" />
168
+ </div>
169
+ </div>
170
+ </div>
171
+ <div class='clr'></div>
172
+ <?php
173
+ endif;
174
+
175
+ if (!$logged) :
176
+
177
+ $dob = $this->getLayout()->createBlock('onepagecheckout/widget_dob');
178
+ $gender = $this->getLayout()->createBlock('onepagecheckout/widget_gender');
179
+ $taxvat = $this->getLayout()->createBlock('onepagecheckout/widget_taxvat');
180
+
181
+ if ($dob->isEnabled() || $gender->isEnabled()){ ?>
182
+ <div class="two_fields">
183
+ <?php if ($dob->isEnabled()): ?>
184
+ <div class="short">
185
+ <?php
186
+ echo $dob->setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml();
187
+ ?>
188
+ </div>
189
+ <?php endif; ?>
190
+ <?php if ($gender->isEnabled()): ?>
191
+ <div class="short">
192
+ <?php
193
+ echo $gender->setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml();
194
+ ?>
195
+ </div>
196
+ <?php endif ?>
197
+ </div>
198
+ <div class='clr'></div>
199
+ <?php
200
+ }
201
+
202
+ if ($taxvat->isEnabled()){ ?>
203
+ <div class='full'>
204
+ <?php
205
+ echo $taxvat->setTaxvat($this->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml();
206
+ ?>
207
+ </div>
208
+ <?php
209
+ }
210
+ $agc = Mage::helper('onepagecheckout')->isGuestCheckoutAllowed();
211
+ if ($agc)
212
+ {
213
+ ?>
214
+ <ul>
215
+ <li class="options">
216
+ <input type="checkbox" name="billing[register_account]" value="1" title="<?php echo $this->__('Create an account for later use') ?>" id="billing:register_account" onclick="if(window.billing) billing.setCreateAccount(this.checked);"<?php if ($this->getBillAddress()->getRegisterAccount()):?> checked="checked"<?php endif;?> class="checkbox" />
217
+ <label for="billing:register_account">
218
+ <?php echo $this->__('Create an account for later use') ?>
219
+ </label>
220
+ </li>
221
+ </ul>
222
+ <?php
223
+ }
224
+ else
225
+ {
226
+ ?>
227
+ <input type="hidden" name="billing[register_account]" value="1"/>
228
+ <?php
229
+ }
230
+ ?>
231
+ <div class="two_fields" id="register-customer-password" <?php if ($agc) { echo ' style="display: none;" '; } ?>>
232
+ <div class="short">
233
+ <label for="billing:customer_password" class="required">
234
+ <?php echo $this->__('Password') ?>
235
+ </label>
236
+ <sup>*</sup>
237
+ <div class="data_area">
238
+ <input type="password" name="billing[customer_password]" id="billing:customer_password" title="<?php echo $this->__('Password') ?>" class="t1 required-entry validate-password" />
239
+ </div>
240
+ </div>
241
+ <div class="short">
242
+ <label for="billing:confirm_password" class="required">
243
+ <?php echo $this->__('Confirm Password') ?>
244
+ </label>
245
+ <sup>*</sup>
246
+ <div class="data_area">
247
+ <input type="password" name="billing[confirm_password]" title="<?php echo $this->__('Confirm Password') ?>" id="billing:confirm_password" class="t1 required-entry validate-cpassword" />
248
+ </div>
249
+ </div>
250
+ <div class='clr'></div>
251
+ </div>
252
+ <div class='clr'></div>
253
+ <?php
254
+ endif;
255
+ ?>
256
+ <ul>
257
+ <?php
258
+ if ($logged && $has_addr){
259
+ ?>
260
+ <li class="options">
261
+ <input type="checkbox" class="checkbox" name="billing[save_in_address_book]" id="billing:save_in_address_book" value="1" title="<?php echo $this->__('Save in address book') ?>" <?php if ($this->getBillAddress()->getSaveInAddressBook()){ echo ' checked="checked" ';}?> />
262
+ <label>
263
+ <?php echo $this->__('Save in address book'); ?>
264
+ </label>
265
+ </li>
266
+ <?php
267
+ }
268
+ else
269
+ {
270
+ ?>
271
+ <li class="no-display">
272
+ <input type="hidden" value="1" name="billing[save_in_address_book]" />
273
+ </li>
274
+ <?php
275
+ }
276
+ ?>
277
+ </ul>
278
+ </div>
279
+
280
+ <?php
281
+ if (Mage::helper('onepagecheckout')->isShippingAddressAllowed() && $this->canShip()){
282
+ ?>
283
+ <input type="hidden" name="billing[use_for_shipping]" id="billing:use_for_shipping" value="<?php echo ($this->isUseBillingAddressForShipping())?'1':'0'; ?>" />
284
+ <?php
285
+ }else{
286
+ ?>
287
+ <input type="hidden" name="billing[use_for_shipping]" value="1" />
288
+ <?php
289
+ }
290
+ ?>
291
+ </div>
292
+ </div>
293
+
294
+ <script type="text/javascript">
295
+ //<![CDATA[
296
+ var billing = new BillingAddress();
297
+ RegionUpdater.prototype.setMarkDisplay = function(){};
298
+ ZipUpdater.prototype._setPostcodeOptional = function(){};
299
+ var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', countryRegions, undefined, 'billing:postcode');
300
+ //]]>
301
+ </script>
app/design/frontend/base/default/template/onepagecheckout/onepage/coupon.phtml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="coupon-discount">
2
+ <div class="discount">
3
+ <div class="op_block_title"><?php echo $this->__('Discount Codes') ?></div>
4
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
5
+ <div class="discount-form">
6
+ <label for="coupon_code"><?php echo $this->__('Enter your coupon code if you have one.') ?></label>
7
+ <input type="hidden" name="process_coupon" id="process_coupon" value="0" />
8
+ <input type="hidden" name="coupon[remove]" id="coupon-remove" value="0" />
9
+ <div class="input-box">
10
+ <input class="input-text" id="coupon-code" name="coupon[code]" value="<?php echo $this->htmlEscape($this->getCouponCode()) ?>" />
11
+ </div>
12
+ <div class="buttons-set">
13
+
14
+ <?php if(strlen($this->getCouponCode())): ?>
15
+ &nbsp; <button type="button" title="<?php echo $this->__('Cancel Coupon') ?>" class="button left" value="<?php echo $this->__('Cancel Coupon') ?>" id="coupon-cancel"><span><span><?php echo $this->__('Cancel Coupon') ?></span></span></button>
16
+ <?php endif;?>
17
+ <button type="button" title="<?php echo $this->__('Apply Coupon') ?>" class="button left" value="<?php echo $this->__('Apply Coupon') ?>" id="coupon-apply"><span><span><?php echo $this->__('Apply Coupon') ?></span></span></button>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </div>
22
+
23
+ <script type="text/javascript">
24
+ //<![CDATA[
25
+ $('coupon-apply') && $('coupon-apply').observe('click', function(e) {
26
+ $('process_coupon').value = "1";
27
+ if (!$('coupon-code').value.length) {
28
+ $('coupon-code').addClassName('validation-failed');
29
+ return;
30
+ }
31
+ $('coupon-remove').value = "0";
32
+ checkout.update({
33
+ 'process_coupon': 1,
34
+ 'review': 1
35
+ });
36
+ });
37
+ $('coupon-cancel') && $('coupon-cancel').observe('click', function(e) {
38
+ $('coupon-remove').value = "1";
39
+ $('process_coupon').value = "1";
40
+ checkout.update({
41
+ 'process_coupon': 1,
42
+ 'review': 1
43
+ });
44
+ });
45
+
46
+ /*
47
+ $('coupon-code').observe('change', function(e) {
48
+ if (!$(this).value.length) {
49
+ $('coupon-remove').value = "1";
50
+ } else {
51
+ $('coupon-remove').value = "0";
52
+ }
53
+ checkout.update({
54
+ 'process_coupon': 1,
55
+ 'review': 1
56
+ });
57
+ });
58
+ */
59
+ //]]>
60
+ </script>
app/design/frontend/base/default/template/onepagecheckout/onepage/link.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php if ($this->isOnepageCheckoutAllowed()):?>
2
+ <button type="button" title="<?php echo $this->__('Proceed to Checkout') ?>" class="button btn-checkout<?php if (!$this->checkEnable()){ echo 'no-checkout'; }?>"<?php if (!$this->checkEnable()){ echo ' disabled="disabled" ';} ?> onclick="window.location='<?php echo $this->getOnepageCheckoutUrl() ?>';">
3
+ <span><span><?php echo $this->__('Proceed to Checkout') ?></span></span>
4
+ </button>
5
+ <?php endif?>
app/design/frontend/base/default/template/onepagecheckout/onepage/payment.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="payment-method" class="onepagecheckout_block">
2
+ <div class="op_block_title"><?php echo $this->__('Payment Method') ?></div>
3
+ <div class="tool-tip" id="payment-tool-tip" style="display:none;">
4
+ <div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
5
+ <div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" title="<?php echo $this->__('Card Verification Number Visual Reference') ?>" /></div>
6
+ </div>
7
+ <script type="text/javascript">
8
+ //<![CDATA[
9
+ function toggleToolTip(event){
10
+ if($('payment-tool-tip')){
11
+ $('payment-tool-tip').setStyle({
12
+ top: (Event.pointerY(event)-300)+'px',
13
+ left: (Event.pointerX(event)-200)+'px'
14
+ });
15
+ $('payment-tool-tip').toggle();
16
+ }
17
+ Event.stop(event);
18
+ }
19
+ if($('payment-tool-tip-close')){
20
+ Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
21
+ }
22
+ var payment = new Payment('payment-method');
23
+ //]]>
24
+ </script>
25
+ <div id="checkout-payment-method-load">
26
+ <?php echo $this->getChildHtml('methods') ?>
27
+ </div>
28
+ <script type="text/javascript">
29
+ //<![CDATA[
30
+ payment.currentMethod = "<?php echo $this->getChild('methods')->getSelectedMethodCode() ?>";
31
+ //]]>
32
+ </script>
33
+ </div>
app/design/frontend/base/default/template/onepagecheckout/onepage/payment/methods.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!$methods = $this->getMethods()) : ?>
2
+ <p><?php echo $this->helper('checkout')->__('Sorry, no quotes are available for this order at this time.') ?></p>
3
+ <?php else : ?>
4
+ <dl class="sp-methods">
5
+ <?php foreach ($this->getMethods() as $_method): $_code = $_method->getCode() ?>
6
+ <dt>
7
+ <?php if( sizeof($this->getMethods()) > 1 ): ?>
8
+ <input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
9
+ <?php else: ?>
10
+ <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>
11
+ <?php endif; ?>
12
+ <label for="p_method_<?php echo $_code ?>"><?php echo $this->htmlEscape($_method->getTitle()) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
13
+ </dt>
14
+ <?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
15
+ <dd>
16
+ <?php echo $html; ?>
17
+ </dd>
18
+ <?php endif; ?>
19
+ <?php endforeach; ?>
20
+ </dl>
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ <?php echo $this->getChildChildHtml('scripts'); ?>
24
+ payment.init();
25
+ //]]>
26
+ </script>
27
+ <?php endif; ?>
app/design/frontend/base/default/template/onepagecheckout/onepage/review.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="checkout-review" class="onepagecheckout_block">
2
+ <div class="op_block_title"><?php echo $this->__('Review Your Order') ?></div>
3
+ <div id="checkout-review-load">
4
+ <?php echo $this->getChildHtml('info') ?>
5
+ </div>
6
+ <div id="checkout-review-submit">
7
+ <?php echo $this->getChildHtml('agreements') ?>
8
+ <div class="buttons-set" id="review-buttons-container">
9
+ <button type="submit" title="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" onclick="checkout.save(); return false;"><?php echo $this->__('Place Order') ?></button>
10
+ <span class="please-wait" id="review-please-wait" style="display:none;">
11
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Submitting order information...') ?>" title="<?php echo $this->__('Submitting order information...') ?>" class="v-middle" /> <?php echo $this->__('Submitting order information...') ?>
12
+ </span>
13
+ </div>
14
+ </div>
15
+ </div>
app/design/frontend/base/default/template/onepagecheckout/onepage/review/info.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php echo $this->getChildHtml('items_before'); ?>
2
+ <div id="checkout-review-table-wrapper">
3
+ <table class="order-products-table" id="checkout-review-table">
4
+ <col />
5
+ <col width="1" />
6
+ <col width="1" />
7
+ <?php
8
+ $colspan = 1;
9
+ if ($this->helper('tax')->displayCartBothPrices()):
10
+ $colspan = 2;
11
+ ?>
12
+ <col width="1" />
13
+ <?php endif; ?>
14
+ <thead>
15
+ <tr>
16
+ <th><?php echo $this->__('Product Name') ?></th>
17
+ <th class="a-center"><?php echo $this->__('Qty') ?></th>
18
+ <th class="a-right" colspan="<?php echo $colspan ?>"><?php echo $this->__('Subtotal') ?></th>
19
+ </tr>
20
+ </thead>
21
+ <?php echo $this->getChildHtml('totals'); ?>
22
+ <tbody>
23
+ <?php foreach($this->getItems() as $_item): ?>
24
+ <?php echo $this->getItemHtml($_item)?>
25
+ <?php endforeach ?>
26
+ </tbody>
27
+ </table>
28
+ </div>
29
+ <script type="text/javascript">
30
+ //<![CDATA[
31
+ decorateTable('checkout-review-table');
32
+ truncateOptions();
33
+ //]]>
34
+ </script>
app/design/frontend/base/default/template/onepagecheckout/onepage/review/item.phtml ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_item = $this->getItem()?>
2
+ <tr>
3
+ <td><h3 class="product-name"><?php echo $this->htmlEscape($this->getProductName()) ?></h3>
4
+ <?php if ($_options = $this->getOptionList()):?>
5
+ <dl class="item-options">
6
+ <?php foreach ($_options as $_option) : ?>
7
+ <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
8
+ <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
9
+ <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
10
+ <?php if (isset($_formatedOptionValue['full_view'])): ?>
11
+ <div class="truncated_full_value">
12
+ <dl class="item-options">
13
+ <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
14
+ <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
15
+ </dl>
16
+ </div>
17
+ <?php endif; ?>
18
+ </dd>
19
+ <?php endforeach; ?>
20
+ </dl>
21
+ <?php endif;?>
22
+ </td>
23
+ <td class="a-center"><?php echo $_item->getQty() ?></td>
24
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
25
+ <td class="a-right">
26
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
27
+ <span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
28
+ <?php else: ?>
29
+ <span class="cart-price">
30
+ <?php endif; ?>
31
+
32
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
33
+ <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
34
+ <?php else: ?>
35
+ <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()) ?>
36
+ <?php endif; ?>
37
+
38
+ </span>
39
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
40
+
41
+ <div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
42
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
43
+ <small>
44
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
45
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span><br />
46
+ <?php endforeach; ?>
47
+ </small>
48
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
49
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
50
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br />
51
+ <?php endforeach; ?>
52
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
53
+ <small>
54
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
55
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br />
56
+ <?php endforeach; ?>
57
+ </small>
58
+ <?php endif; ?>
59
+ </div>
60
+
61
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
62
+ <div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
63
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
64
+ </div>
65
+ <?php endif; ?>
66
+ <?php endif; ?>
67
+ </td>
68
+ <?php endif; ?>
69
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
70
+ <td class="a-right">
71
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
72
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
73
+ <span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
74
+ <?php else: ?>
75
+ <span class="cart-price">
76
+ <?php endif; ?>
77
+
78
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
79
+ <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
80
+ <?php else: ?>
81
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
82
+ <?php endif; ?>
83
+
84
+ </span>
85
+
86
+
87
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
88
+
89
+ <div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
90
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
91
+ <small>
92
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
93
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span><br />
94
+ <?php endforeach; ?>
95
+ </small>
96
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
97
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
98
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br />
99
+ <?php endforeach; ?>
100
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
101
+ <small>
102
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
103
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br />
104
+ <?php endforeach; ?>
105
+ </small>
106
+ <?php endif; ?>
107
+ </div>
108
+
109
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
110
+ <div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
111
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span>
112
+ </div>
113
+ <?php endif; ?>
114
+ <?php endif; ?>
115
+ </td>
116
+ <?php endif; ?>
117
+ </tr>
app/design/frontend/base/default/template/onepagecheckout/onepage/review/totals.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->getTotals()): ?>
2
+ <tfoot>
3
+ <?php $_colspan = $this->helper('tax')->displayCartBothPrices() ? 3 : 2; ?>
4
+ <?php echo $this->renderTotals(null, $_colspan); ?>
5
+ <?php echo $this->renderTotals('footer', $_colspan); ?>
6
+ <?php if ($this->needDisplayBaseGrandtotal()):?>
7
+ <tr>
8
+ <td class="a-right" colspan="<?php echo $_colspan; ?>">
9
+ <small><?php echo $this->helper('sales')->__('Your credit card will be charged for') ?></small>
10
+ </td>
11
+ <td class="a-right">
12
+ <small><?php echo $this->displayBaseGrandtotal() ?></small>
13
+ </td>
14
+ </tr>
15
+ <?php endif?>
16
+ </tfoot>
17
+ <?php endif; ?>
app/design/frontend/base/default/template/onepagecheckout/onepage/shipping.phtml ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $logged = $this->isCustomerLoggedIn();
3
+ $has_addr = $this->customerHasAddresses();
4
+
5
+ if (!$this->getQuote()->isVirtual() && Mage::helper('onepagecheckout')->isShippingAddressAllowed())
6
+ {
7
+ ?>
8
+ <ul>
9
+ <li class="options">
10
+ <input type="checkbox" class="checkbox" name="shipping[same_as_billing]" id="shipping:same_as_billing" value="1"<?php if($this->getShipAddress()->getSameAsBilling()){echo ' checked="checked" ';} ?> title="<?php echo $this->__('Ship to this address') ?>" onclick="shipping.setSameAsBilling(this.checked)" />
11
+ <label>
12
+ <?php echo $this->__('Ship to this address') ?>
13
+ </label>
14
+ </li>
15
+ </ul>
16
+ <div id="ship_address_block" class="onepagecheckout_block"<?php if($this->getShipAddress()->getSameAsBilling()){echo 'style="display: none;"';}?>>
17
+ <div class="op_block_title">
18
+ <?php echo $this->__('New Shipping Address') ?>
19
+ </div>
20
+ <div class="form_fields">
21
+ <?php if ($has_addr){ ?>
22
+ <div class="full">
23
+ <label>
24
+ <?php echo $this->__('Select a shipping address from your address book or enter a new address.') ?>
25
+ </label>
26
+ <div class="data_area">
27
+ <?php echo $this->getCustomerShipAddr() ?>
28
+ </div>
29
+ </div>
30
+ <?php } ?>
31
+ <div id="ship_form"<?php if ($has_addr){ echo ' style="display:none;" ';}?>>
32
+ <input type="hidden" name="shipping[address_id]" id="shipping:address_id" value="<?php echo $this->getShipAddress()->getId() ?>" />
33
+ <div class="two_fields">
34
+ <?php echo $this->getLayout()->createBlock('onepagecheckout/widget_name')->setObject($this->getShipAddress())->setFieldIdFormat('shipping:%s')->setFieldNameFormat('shipping[%s]')->setFieldParams('onchange="shipping.setSameAsBilling(false)"')->toHtml() ?>
35
+ </div>
36
+ <div class='clr'></div>
37
+ <?php
38
+ $cr = Mage::getStoreConfig('onepagecheckout/address_form/company');
39
+ if ($cr !== 'hidden') : ?>
40
+ <div class="full">
41
+ <label>
42
+ <?php echo $this->__('Company') ?>
43
+ </label>
44
+ <?php if ( $cr === 'required' ){echo ' <sup>*<sup> ';} ?>
45
+ <div class="data_area">
46
+ <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->htmlEscape($this->getShipAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="t1<?php if( $cr === 'required' ){ echo ' required-entry ';} ?>" onchange="shipping.setSameAsBilling(false);" />
47
+ </div>
48
+ </div>
49
+ <?php endif;
50
+
51
+ $ar = Mage::getStoreConfig('onepagecheckout/address_form/address');
52
+ if ($ar !== 'hidden') :
53
+ ?>
54
+ <div class="full">
55
+ <label>
56
+ <?php echo $this->__('Address') ?>
57
+ </label>
58
+ <?php if($ar === 'required'){echo '<sup>*</sup>';}?>
59
+ <div class="data_area">
60
+ <input type="text" title="<?php echo $this->__('Street Address') ?>" name="shipping[street][]" id="shipping:street1" value="<?php echo $this->htmlEscape($this->getShipAddress()->getStreet(1)) ?>" class="t1<?php if($ar === 'required'){echo ' required-entry';}?>" onchange="shipping.setSameAsBilling(false);" />
61
+ </div>
62
+ </div>
63
+ <?php
64
+ $csl = $this->helper('customer/address')->getStreetLines();
65
+ for ($i = 2; $i <= $csl; $i++){
66
+ ?>
67
+ <div class="full">
68
+ <div class="data_area">
69
+ <input type="text" name="shipping[street][]" id="shipping:street<?php echo $i?>" title="<?php echo $this->__('Street Address %s', $i) ?>" value="<?php echo $this->htmlEscape($this->getShipAddress()->getStreet($i)) ?>" class="t1" onchange="shipping.setSameAsBilling(false);" />
70
+ </div>
71
+ </div>
72
+ <?php
73
+ }
74
+
75
+ endif;
76
+
77
+ $city_r = Mage::getStoreConfig('onepagecheckout/address_form/city');
78
+ $state_r= Mage::getStoreConfig('onepagecheckout/address_form/state');
79
+ ?>
80
+ <div class="two_fields"<?php if(($city_r === 'hidden' && $state_r === 'hidden')){echo ' style="display:none"';}?> >
81
+ <?php if ($city_r !== 'hidden') : ?>
82
+ <div class="short">
83
+ <label>
84
+ <?php echo $this->__('City') ?>
85
+ </label>
86
+ <?php if ($city_r === 'required'){ echo ' <sup>*</sup> ';}?>
87
+
88
+ <div class="data_area">
89
+ <input type="text" name="shipping[city]" id="shipping:city" title="<?php echo $this->__('City') ?>" value="<?php echo $this->htmlEscape($this->getShipAddress()->getCity()) ?>" class="t1<?php if ($city_r === 'required'){ echo ' required-entry ';}?>" onchange="shipping.setSameAsBilling(false);" />
90
+ </div>
91
+ </div>
92
+ <?php endif; ?>
93
+ <div class="short"<?php if($state_r === 'hidden'){ echo ' style="display:none" ';}?>>
94
+ <label>
95
+ <?php echo $this->__('State / Province') ?>
96
+ </label>
97
+ <div class="data_area">
98
+ <select id="shipping:region_id" name="shipping[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select<?php if($state_r === 'required') { echo ' required-entry';}?>" style="display:none;">
99
+ <option value=""><?php echo $this->__('Select One') ?></option>
100
+ </select>
101
+ <script type="text/javascript">
102
+ //<![CDATA[
103
+ $('shipping:region_id').setAttribute('defaultValue', "<?php echo $this->getShipAddress()->getRegionId() ?>");
104
+ //]]>
105
+ </script>
106
+ <input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $this->htmlEscape($this->getShipAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="t1<?php if($state_r === 'required'){ echo ' required-entry';}?>" style="display:none;" />
107
+ </div>
108
+ </div>
109
+ </div>
110
+ <div class='clr'></div>
111
+ <?php
112
+ $zip_r = Mage::getStoreConfig('onepagecheckout/address_form/zip');
113
+ $phone_r= Mage::getStoreConfig('onepagecheckout/address_form/phone');
114
+ if ($zip_r !== 'hidden' || $phone_r !== 'hidden') :
115
+ ?>
116
+ <div class="two_fields">
117
+ <?php if ($zip_r !== 'hidden') : ?>
118
+ <div class="short">
119
+ <label>
120
+ <?php echo $this->__('Zip Code') ?>
121
+ </label>
122
+ <?php if($zip_r === 'required'){echo ' <sup>*</sup>';}?>
123
+ <div class="data_area">
124
+ <input type="text" name="shipping[postcode]" id="shipping:postcode" title="<?php echo $this->__('Zip/Postal Code') ?>" value="<?php echo $this->htmlEscape($this->getShipAddress()->getPostcode()) ?>" class="t1 validate-zip-international<?php if($zip_r === 'required'){echo ' required-entry ';}?>" onchange="shipping.setSameAsBilling(false);" />
125
+ </div>
126
+ </div>
127
+ <?php endif; ?>
128
+ <?php if ($phone_r !== 'hidden') : ?>
129
+ <div class="short">
130
+ <label>
131
+ <?php echo $this->__('Telephone') ?>
132
+ </label>
133
+ <?php if($phone_r === 'required') { echo ' <sup>*</sup> ';}?>
134
+ <div class="data_area">
135
+ <input type="text" name="shipping[telephone]" id="shipping:telephone" value="<?php echo $this->htmlEscape($this->getShipAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="t1<?php if($phone_r === 'required') { echo ' required-entry ';}?>" onchange="shipping.setSameAsBilling(false);" />
136
+ </div>
137
+ </div>
138
+ <?php endif; ?>
139
+ </div>
140
+ <div class='clr'></div>
141
+ <?php endif ?>
142
+
143
+ <?php
144
+ $country_r = Mage::getStoreConfig('onepagecheckout/address_form/country');
145
+ ?>
146
+ <div class="full"<?php if($country_r === 'hidden'){ echo ' style="display:none" ';}?>>
147
+ <label>
148
+ <?php echo $this->__('Country') ?>
149
+ </label>
150
+ <?php if($country_r === 'required') { echo ' <sup>*</sup> ';}?>
151
+ <div class="data_area">
152
+ <?php echo $this->getShippingCountriesSelectBox() ?>
153
+ </div>
154
+ </div>
155
+
156
+ <?php
157
+ $fax_r = Mage::getStoreConfig('onepagecheckout/address_form/fax');
158
+ if ($fax_r !== 'hidden') :
159
+ ?>
160
+ <div lang="two_fields">
161
+ <div class="short">
162
+ <label>
163
+ <?php echo $this->__('Fax') ?>
164
+ </label>
165
+ <?php if($fax_r === 'required') {echo ' <sup>*</sup> ';}?>
166
+ <div class="data_area">
167
+ <input type="text" name="shipping[fax]" id="shipping:fax" value="<?php echo $this->htmlEscape($this->getShipAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="t1<?php if($fax_r === 'required') {echo ' required-entry ';}?>" onchange="shipping.setSameAsBilling(false);" />
168
+ </div>
169
+ </div>
170
+ </div>
171
+ <div class='clr'></div>
172
+ <?php
173
+ endif;
174
+
175
+ ?>
176
+ <ul>
177
+ <?php
178
+ if ($logged && $has_addr){
179
+ ?>
180
+ <li class="options">
181
+ <input type="checkbox" class="checkbox" name="shipping[save_in_address_book]" id="shipping:save_in_address_book" value="1" title="<?php echo $this->__('Save in address book') ?>" <?php if ($this->getShipAddress()->getSaveInAddressBook()){ echo ' checked="checked" ';}?> />
182
+ <label>
183
+ <?php echo $this->__('Save in address book') ?>
184
+ </label>
185
+ </li>
186
+ <?php
187
+ }
188
+ else
189
+ {
190
+ ?>
191
+ <li class="no-display">
192
+ <input type="hidden" name="shipping[save_in_address_book]" value="1" />
193
+ </li>
194
+ <?php
195
+ }
196
+ ?>
197
+ </ul>
198
+ </div>
199
+ </div>
200
+ </div>
201
+ <script type="text/javascript">
202
+ //<![CDATA[
203
+ var shipping = new ShippingAddress('onepagecheckout_orderform');
204
+ var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', countryRegions, undefined, 'shipping:postcode');
205
+ //]]>
206
+ </script>
207
+ <?php
208
+ }
209
+ ?>
app/design/frontend/base/default/template/onepagecheckout/onepage/shipping_method.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->getQuote()->isVirtual()) : return; endif; ?>
2
+ <div id="shipping-method" class="onepagecheckout_block">
3
+ <div class="op_block_title"><?php echo $this->__('Shipping Method') ?></div>
4
+ <div id="checkout-shipping-method-load">
5
+ <?php echo $this->getChildHtml('available') ?>
6
+ </div>
7
+ <script type="text/javascript">
8
+ //<![CDATA[
9
+ var shippingMethod = new ShippingMethod('shipping-method');
10
+ //]]>
11
+ </script>
12
+ <div id="onepage-checkout-shipping-method-additional-load">
13
+ <?php echo $this->getChildHtml('additional') ?>
14
+ </div>
15
+ </div>
app/design/frontend/base/default/template/onepagecheckout/onepagecheckout.phtml ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="page-title">
2
+ <h1 class='h1_opc'><?php echo Mage::getStoreConfig('onepagecheckout/general/title') ?></h1>
3
+ Fill in the fields below to complete your purchase!
4
+ <?php if (!Mage::getSingleton('customer/session')->isLoggedIn()){ ?>
5
+ <p class="onepagecheckout_loginarea">
6
+ <a href="javascript:void(0)" class="onepagecheckout_loginlink" onclick='open_login();'>
7
+ <?php echo $this->__('Registered user? Login here') ?>
8
+ </a>
9
+ </p>
10
+
11
+ <?php
12
+
13
+ echo $this->getChildHtml('customer.login');
14
+ echo $this->getChildHtml('customer.forgot');
15
+
16
+ }
17
+ ?>
18
+ </div>
19
+ <div class='ptdivline'></div>
20
+
21
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
22
+
23
+ <?php
24
+ $seq_http = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on');
25
+
26
+ ?>
27
+ <script type="text/javascript">
28
+ var http_type = '<?php if($seq_http){echo 'https';}else{echo 'http';}?>';
29
+ </script>
30
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/onepagecheckout.js') ?>"></script>
31
+
32
+ <script type="text/javascript">countryRegions = <?php echo $this->helper('directory')->getRegionJson() ?></script>
33
+
34
+ <form action="" id="onepagecheckout_orderform">
35
+ <div class="col3-set onepagecheckout_datafields">
36
+ <div class="col-1">
37
+ <?php echo $this->getChildHtml('billing.address') ?>
38
+ <?php echo $this->getChildHtml('shipping.address') ?>
39
+ </div>
40
+
41
+ <div class="col-2">
42
+ <?php echo $this->getChildHtml('shipping.method') ?>
43
+ <?php echo $this->getChildHtml('payment.method') ?>
44
+ <div id="checkout-coupon-discount-load">
45
+ <?php echo $this->getChildHtml('coupon') ?>
46
+ </div>
47
+
48
+ <?php if (Mage::getStoreConfig('onepagecheckout/general/comment')) : ?>
49
+ <div class="op_block_title">
50
+ <?php echo $this->helper('sales')->__('Comment') ?>
51
+ </div>
52
+ <div class="form_fields">
53
+ <div class="full">
54
+ <div class="data_area" id='comment-block'>
55
+ <textarea name="order-comment" id="order-comment"><?php echo trim(Mage::getSingleton('customer/session')->getOrderCustomerComment()) ?></textarea>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ <?php endif; ?>
60
+ <?php if (Mage::helper('onepagecheckout')->isSubscribeNewAllowed()) : ?>
61
+ <p class="newsletter">
62
+ <input type="checkbox" id="newsletter-signup" name="newsletter" value="1" title="<?php echo Mage::helper('newsletter')->__('Sign up for our newsletter') ?>" class="checkbox" />
63
+ <label for="newsletter-signup">
64
+ <?php echo Mage::helper('newsletter')->__('Sign up for our newsletter') ?>
65
+ </label>
66
+ </p>
67
+ <?php endif; ?>
68
+ </div>
69
+
70
+ <div class="col-3">
71
+ <?php echo $this->getChildHtml('review') ?>
72
+ </div>
73
+ </div>
74
+ </form>
75
+
76
+ <script type="text/javascript">
77
+ //<![CDATA[
78
+ var checkout = new OPC('onepagecheckout_orderform', {
79
+ save : '<?php echo $this->getUrl('onepagecheckout/index/saveOrder', array('_secure'=>$seq_http)) ?>',
80
+ update : '<?php echo $this->getUrl('onepagecheckout/index/updateCheckout', array('_secure'=>$seq_http)) ?>',
81
+ success : '<?php echo $this->getUrl('onepagecheckout/index/success', array('_secure'=>$seq_http)) ?>',
82
+ failure : '<?php echo $this->getUrl('checkout/cart') ?>'
83
+ }, "<?php echo $this->__('Please agree to all the terms and conditions.') ?>");
84
+
85
+ document.observe("dom:loaded", function() {
86
+ var win_triggers = Array();
87
+ $$('.checkout-agreements .agree a').each(function(item){
88
+ var obj = {
89
+ el: $$('.' + item.className),
90
+ event: 'click',
91
+ window: $(item.className + '-window')
92
+ };
93
+ win_triggers.push(obj);
94
+ });
95
+ opc_window = new OPC.Window({triggers: win_triggers});
96
+ });
97
+ //]]>
98
+ </script>
app/design/frontend/base/default/template/onepagecheckout/widget/dob.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <label for="<?php echo $this->getFieldId('month')?>"<?php if ($this->isRequired()) echo ' class="required"' ?>>
2
+ <?php echo $this->__('Date of Birth') ?>
3
+ </label>
4
+ <?php if ($this->isRequired()) echo '<sup>*</sup>' ?>
5
+ <div class="data_area customer-dob">
6
+ <?php
7
+ $this->setDateInput('d',
8
+ '<div class="dob-day">
9
+ <input type="text" id="' . $this->getFieldId('day') . '" name="' . $this->getFieldName('day') . '" value="' . $this->getDay() . '" title="' . $this->__('Day') . '" class="t1 validate-custom" ' . $this->getFieldParams() . ' />
10
+ <label for="' . $this->getFieldId('day') . '">' . $this->__('DD') . '</label>
11
+ </div>'
12
+ );
13
+
14
+ $this->setDateInput('m',
15
+ '<div class="dob-month">
16
+ <input type="text" id="' . $this->getFieldId('month') . '" name="' . $this->getFieldName('month') . '" value="' . $this->getMonth() . '" title="' . $this->__('Month') . '" class="t1 validate-custom" ' . $this->getFieldParams() . ' />
17
+ <label for="' . $this->getFieldId('month') . '">' . $this->__('MM') . '</label>
18
+ </div>'
19
+ );
20
+
21
+ $this->setDateInput('y',
22
+ '<div class="dob-year">
23
+ <input type="text" id="' . $this->getFieldId('year') . '" name="' . $this->getFieldName('year') . '" value="' . $this->getYear() . '" title="' . $this->__('Year') . '" class="t1 validate-custom" ' . $this->getFieldParams() . ' />
24
+ <label for="' . $this->getFieldId('year') . '">' . $this->__('YYYY') . '</label>
25
+ </div>'
26
+ );
27
+
28
+ echo $this->getSortedDateInputs()
29
+ ?>
30
+ <div class="dob-full" style="display:none;">
31
+ <input type="hidden" id="<?php echo $this->getFieldId('dob')?>" name="<?php echo $this->getFieldName('dob')?>" />
32
+ </div>
33
+
34
+ <div class="validation-advice" style="display:none;"></div>
35
+ </div>
36
+ <script type="text/javascript">
37
+ //<![CDATA[
38
+ var customer_dob = new Varien.DOB('.customer-dob', <?php echo $this->isRequired() ? 'true' : 'false' ?>, '<?php echo $this->getDateFormat() ?>');
39
+ //]]>
40
+ </script>
app/design/frontend/base/default/template/onepagecheckout/widget/gender.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <label for="<?php echo $this->getFieldId('gender')?>"<?php if ($this->isRequired()) echo ' class="required"' ?>>
2
+ <?php echo $this->__('Gender') ?>
3
+ </label>
4
+ <?php if ($this->isRequired()) echo '<sup>*</sup>' ?>
5
+ <div class="data_area">
6
+ <select id="<?php echo $this->getFieldId('gender')?>" name="<?php echo $this->getFieldName('gender')?>" title="<?php echo $this->__('Gender') ?>"<?php if ($this->isRequired()):?> class="validate-select"<?php endif; ?> <?php echo $this->getFieldParams() ?>>
7
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();?>
8
+ <?php $value = $this->getGender();?>
9
+ <?php foreach ($options as $option):?>
10
+ <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $value) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
11
+ <?php endforeach;?>
12
+ </select>
13
+ </div>
app/design/frontend/base/default/template/onepagecheckout/widget/name.phtml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="<?php echo $this->getContainerClassName()?>">
2
+ <?php if ($this->showPrefix()): ?>
3
+ <div class="short name-prefix">
4
+ <label for="<?php echo $this->getFieldId('prefix')?>"<?php if ($this->isPrefixRequired()) echo ' class="required"' ?>>
5
+ <?php echo $this->__('Prefix'); ?>
6
+ </label>
7
+ <?php if ($this->isPrefixRequired()) echo '<sup>*</sup>'; ?>
8
+ <div class="data_area">
9
+ <?php if ($this->getPrefixOptions()===false): ?>
10
+ <input type="text" id="<?php echo $this->getFieldId('prefix')?>" name="<?php echo $this->getFieldName('prefix')?>" value="<?php echo $this->htmlEscape($this->getObject()->getPrefix()) ?>" title="<?php echo $this->__('Prefix') ?>" class="t1<?php if ($this->isPrefixRequired()):?> required-entry<?php endif; ?>" <?php echo $this->getFieldParams() ?> />
11
+ <?php else: ?>
12
+ <select id="<?php echo $this->getFieldId('prefix')?>" name="<?php echo $this->getFieldName('prefix')?>" title="<?php echo $this->__('Prefix') ?>"<?php if ($this->isPrefixRequired()):?> class="required-entry"<?php endif; ?> <?php echo $this->getFieldParams() ?>>
13
+ <?php foreach ($this->getPrefixOptions() as $_option): ?>
14
+ <option value="<?php echo $_option?>"<?php if ($this->getObject()->getPrefix()==$_option):?> selected="selected"<?php endif; ?>><?php echo $this->__($_option)?></option>
15
+ <?php endforeach ?>
16
+ </select>
17
+ <?php endif; ?>
18
+ </div>
19
+ </div>
20
+ <?php endif; ?>
21
+ <div class="short name-firstname">
22
+ <label for="<?php echo $this->getFieldId('firstname')?>" class="required">
23
+ <?php echo $this->__('First Name') ?>
24
+ </label>
25
+ <sup>*</sup>
26
+ <div class="data_area">
27
+ <input type="text" id="<?php echo $this->getFieldId('firstname')?>" name="<?php echo $this->getFieldName('firstname')?>" value="<?php echo $this->htmlEscape($this->getObject()->getFirstname()) ?>" title="<?php echo $this->__('First Name') ?>" class="t1 required-entry" <?php echo $this->getFieldParams() ?> />
28
+ </div>
29
+ </div>
30
+ <?php if ($this->showMiddlename()): ?>
31
+ <div class="short name-middlename">
32
+ <label for="<?php echo $this->getFieldId('middlename')?>"><?php echo $this->__('M.I.') ?></label>
33
+ <div class="data_area">
34
+ <input type="text" id="<?php echo $this->getFieldId('middlename')?>" name="<?php echo $this->getFieldName('middlename')?>" value="<?php echo $this->htmlEscape($this->getObject()->getMiddlename()) ?>" title="<?php echo $this->__('M.I.') ?>" class="t1" <?php echo $this->getFieldParams() ?> />
35
+ </div>
36
+ </div>
37
+ <?php endif; ?>
38
+ <div class="short name-lastname">
39
+ <label for="<?php echo $this->getFieldId('lastname')?>" class="required">
40
+ <?php echo $this->__('Last Name') ?>
41
+ </label>
42
+ <sup>*</sup>
43
+ <div class="data_area">
44
+ <input type="text" id="<?php echo $this->getFieldId('lastname')?>" name="<?php echo $this->getFieldName('lastname')?>" value="<?php echo $this->htmlEscape($this->getObject()->getLastname()) ?>" title="<?php echo $this->__('Last Name') ?>" class="t1 required-entry" <?php echo $this->getFieldParams() ?> />
45
+ </div>
46
+ </div>
47
+ <?php if ($this->showSuffix()): ?>
48
+ <div class="short name-suffix">
49
+ <label for="<?php echo $this->getFieldId('suffix')?>"<?php if ($this->isSuffixRequired()) echo ' class="required"' ?>>
50
+ <?php echo $this->__('Suffix') ?>
51
+ </label>
52
+ <?php if ($this->isSuffixRequired()) echo '<sup>*</sup>'; ?>
53
+ <div class="data_area">
54
+ <?php if ($this->getSuffixOptions()===false): ?>
55
+ <input type="text" id="<?php echo $this->getFieldId('suffix')?>" name="<?php echo $this->getFieldName('suffix')?>" value="<?php echo $this->htmlEscape($this->getObject()->getSuffix()) ?>" title="<?php echo $this->__('Suffix') ?>" class="t1<?php if ($this->isSuffixRequired()):?> required-entry<?php endif; ?>" <?php echo $this->getFieldParams() ?> />
56
+ <?php else: ?>
57
+ <select id="<?php echo $this->getFieldId('suffix')?>" name="<?php echo $this->getFieldName('suffix')?>" title="<?php echo $this->__('Suffix') ?>"<?php if ($this->isSuffixRequired()):?> class="required-entry"<?php endif; ?> <?php echo $this->getFieldParams() ?>>
58
+ <?php foreach ($this->getSuffixOptions() as $_option): ?>
59
+ <option value="<?php echo $_option?>"<?php if ($this->getObject()->getSuffix()==$_option):?> selected="selected"<?php endif; ?>><?php echo $this->__($_option)?></option>
60
+ <?php endforeach ?>
61
+ </select>
62
+ <?php endif; ?>
63
+ </div>
64
+ </div>
65
+ <?php endif; ?>
66
+ </div>
app/design/frontend/base/default/template/onepagecheckout/widget/taxvat.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <label for="<?php echo $this->getFieldId('taxvat')?>"<?php if ($this->isRequired()) echo ' class="required"' ?>>
2
+ <?php echo $this->__('Tax/VAT number') ?>
3
+ </label>
4
+ <?php if ($this->isRequired()) echo '<sup>*</sup>' ?>
5
+ <div class="data_area">
6
+ <input type="text" id="<?php echo $this->getFieldId('taxvat')?>" name="<?php echo $this->getFieldName('taxvat')?>" value="<?php echo $this->htmlEscape($this->getTaxvat()) ?>" title="<?php echo $this->__('Tax/VAT number') ?>" class="t1<?php if ($this->isRequired()){echo 'required-entry';} ?>" <?php echo $this->getFieldParams() ?> />
7
+ </div>
app/etc/modules/Swift_OnepageCheckout.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <modules>
4
+ <Swift_OnepageCheckout>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Swift_OnepageCheckout>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Swift_Checkout</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Swift checkout is a custom Magento extension to allow users to have an easy and quick checkout process with a single click</summary>
10
+ <description>Swift checkout is a custom Magento extension to allow users to have an easy checkout process with a single click. Swift checkout extension allows a fast and easy checkout with all features as in default checkout process incorporated in to a single page. Please follow the below steps carefully to install the swift checkout extension to make your store checkout more attractive</description>
11
+ <notes>First Stable Release</notes>
12
+ <authors><author><name>Team Php</name><user>teamphp2013</user><email>teamphp2013@gmail.com</email></author><author><name>Arun</name><user>abalakrishnan</user><email>abalakrishnan@suyati.com</email></author><author><name>Naveenbos</name><user>nmohanan</user><email>nmohanan@suyati.com</email></author></authors>
13
+ <date>2013-09-02</date>
14
+ <time>08:19:51</time>
15
+ <contents><target name="magecommunity"><dir name="Swift"><dir name="OnepageCheckout"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="AddressOptions.php" hash="3a2d3422d48a43b5564efe762f1d655b"/><file name="AgreementOptions.php" hash="cdee58b12855c02b6f6a035c0aceda0c"/></dir></dir></dir></dir></dir><dir name="Block"><file name="Agreements.php" hash="8e07f591ec995f71e60fa6aa4d15bdd5"/><file name="Links.php" hash="7dc69dc45015d67c509323c37e23b2bd"/><dir name="Onepage"><file name="Billship.php" hash="bdbe58046a2b350c6f3cd11358870037"/><file name="Link.php" hash="e433c5a5eca5a8189ab61fa3be486fb4"/></dir><dir name="Widget"><file name="Dob.php" hash="eb1730f2f6bfaa2ffcf393068713be7d"/><file name="Gender.php" hash="7b2a12486685bd7bddf5724e8a018413"/><file name="Name.php" hash="b60c353fead5b3104eaa08a0f5f14370"/><file name="Taxvat.php" hash="8c8bacb546cc524e633d39fb94ba65e1"/></dir></dir><dir name="Helper"><file name="Data.php" hash="0ee6370ca9ac1fbae725ea6eef07be8e"/><file name="Url.php" hash="7ae7cdf77c2d60a91649ff61a22db47f"/></dir><dir name="Model"><file name="Observer.php" hash="ef3ec64bb3406f4263ee3b8ccacd4d33"/><dir name="Service"><file name="Quote.php" hash="28535cc31c19821d264a82754e40e4f4"/></dir><dir name="Type"><file name="Opcheckout.php" hash="8a74ef23cbf21952342d396d59b2e02c"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="2a65da531b934a7c01d5f5517e681650"/></dir><dir name="etc"><file name="adminhtml.xml" hash="258a8979a38f642305fd92d038d2d812"/><file name="config.xml" hash="666aaa735a9698d4ed4590c515a87190"/><file name="system.xml" hash="55971be804476386ad0930d4f641fb7a"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="onepagecheckout.xml" hash="cf9eb0dd1f6a5f7d25ac9e4bcfa1ed58"/></dir><dir name="template"><dir name="onepagecheckout"><dir name="cart"><file name="noItems.phtml" hash="7241842adf6e48a262721ece2c1dc5c1"/></dir><file name="forgotpassword.phtml" hash="1c8b800716deddc1d1af13bd1e9a09cf"/><file name="login.phtml" hash="393710bf7c2867c3f348b9a559d6f8a7"/><dir name="onepage"><file name="agreements.phtml" hash="2d23d7a225354b518f31601dbc576c54"/><file name="billing.phtml" hash="b919bf535fabab7c43fe419dd032776a"/><file name="coupon.phtml" hash="682634b887fccdc897a48ecb9fe398e7"/><file name="link.phtml" hash="d8fe913d591231e0b0b07faa7b03cfbf"/><dir name="payment"><file name="methods.phtml" hash="ab38ce6dd1ef7cc7abd8fad455126b9a"/></dir><file name="payment.phtml" hash="f9d3832d0868639bfefcc0ebe6a0dcba"/><dir name="review"><file name="info.phtml" hash="93526d037504fa3848fb57403b80b2b6"/><file name="item.phtml" hash="f295522164317aad1d946641f0db3214"/><file name="totals.phtml" hash="ebede001e60aa493ee3e8c2910e7f376"/></dir><file name="review.phtml" hash="4607596510b51ab29ea5df9ba5f24bed"/><file name="shipping.phtml" hash="7c46e724e4274be3ffc1cb22951032cd"/><file name="shipping_method.phtml" hash="5e2ff8826fa66e984872be1228d98a3b"/></dir><file name="onepagecheckout.phtml" hash="2933161b18b325e9ea12b39e2300848e"/><dir name="widget"><file name="dob.phtml" hash="dee2e3ef1280104e85c235f55e583496"/><file name="gender.phtml" hash="a6ea08aea88e20d17237a40b1603732b"/><file name="name.phtml" hash="0c9866e0a21ac9b536ba97949e09d18d"/><file name="taxvat.phtml" hash="5e6eb55af488ad82fdf5677fb48d81b6"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Swift_OnepageCheckout.xml" hash="b8e954d259d9c5f9ebdd0198431f21e7"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="onepagecheckout.css" hash="0e1abc240ee7213610960f24418a9152"/></dir><dir name="images"><dir name="onepagecheckout"><file name="buttonbg.gif" hash="4880178dca4ff0230a82f964691c6a81"/><file name="buttonbgsmall.gif" hash="e8864f54f4c973ed8c091bdcaff2a6b4"/><file name="cancel.png" hash="52882817381a5cecc72b77b9579d4d2b"/><file name="cancel_round.png" hash="afcb08c1bdcdb7f9922ea289906fdfbf"/><file name="close.png" hash="0aa9c71e1e00deb929514c3b004e30c2"/><file name="loader.gif" hash="cf46f7db4c452ea2a94d33eabca8ba93"/><file name="place-order.jpg" hash="fd9e10e234dd1cb4f59f24ba6fd6b435"/><file name="shd-medium.png" hash="1c85643035d7b3bffc06f9b4a4f92417"/></dir></dir><dir name="js"><file name="onepagecheckout.js" hash="070d502cb226b60c9091de95a8d02846"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0</min><max>1.7</max></package></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/onepagecheckout.css ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .h1_opc{text-transform:uppercase;font-size:22px;color:#000;}
2
+
3
+ .onepagecheckout_loginarea { margin: 10px 0 20px; }
4
+ .op_login_area{width:200px;padding:10px;border:1px solid #ccc;margin-bottom:15px;}
5
+ .op_login_area sup{color:#767676;font-size:100%;line-height:0;margin-left:3px;position:relative;top:6px;}
6
+ .op_login_area .buttons-set{margin-top:10px;}
7
+ .op_login_area .buttons-set a{color:#767676;}
8
+ .op_login_area .page-title{margin-bottom:10px;}
9
+ .close_la{position:relative;margin-bottom:-16px;top:-16px;right:-16px;cursor:pointer;float:right;width:16px;height:16px;
10
+ background:url("../images/onepagecheckout/cancel.png") no-repeat scroll 0 0 transparent;}
11
+ .op_login_area button.button{border:1px solid #ccc;
12
+ background:url("../images/onepagecheckout/buttonbgsmall.gif") repeat-x scroll 0 0 #F18200;
13
+ -moz-box-shadow: 3px 3px 5px #ccc;-webkit-box-shadow: 3px 3px 5px #ccc;box-shadow: 3px 3px 5px #ccc;}
14
+ .op_login_area button.button span{background:none no-repeat scroll 0 0 transparent;border:0 none;
15
+ color:#FFFFFF;font:bold 12px/20px Arial,Helvetica,sans-serif;height:20px !important;padding:0 0 0 5px;text-transform:none;}
16
+ .op_login_area button.button span span {background-position:100% 0;padding:0 5px 0 0;}
17
+
18
+ .onepagecheckout-index-index .onepagetitle { margin-bottom: 10px; }
19
+ .onepagecheckout-index-index .page-title { border-bottom:1px solid #000;margin:0;}
20
+ .ptdivline{width:100%;height:1px;margin:-1px 0 0;-moz-box-shadow: 0 2px 2px #999;-webkit-box-shadow: 0 2px 2px #999;box-shadow: 0 2px 2px #999;}
21
+ .onepagecheckout_datafields{border-bottom:1px solid #CCCCCC;padding-bottom:20px;}
22
+
23
+ #onepagecheckout_orderform .col3-set .col-1{width:27%;}
24
+ #onepagecheckout_orderform .col3-set .col-2{width:30%;margin-left:6%;}
25
+
26
+ #onepagecheckout_orderform #register-customer-password{margin-bottom:5px;}
27
+ #onepagecheckout_orderform #ship_address_block{margin-top:35px;}
28
+
29
+ .onepagecheckout_datafields .op_block_title{text-transform:uppercase;color:#000;font-size:11pt;font-weight:bold;border-bottom:1px solid #000;margin: 25px 0 30px;}
30
+
31
+ .onepagecheckout_datafields .col-1 .form_fields .short {width:50%; float:left; }
32
+ .onepagecheckout_datafields .col-1 .form_fields div.two_fields .data_area { width: 95%; }
33
+ .onepagecheckout_datafields .col-1 .form_fields div.two_fields .short { margin-bottom:15px; }
34
+ .onepagecheckout_datafields .col-1 .form_fields input.t1 { width: 95%; padding:2px; background:none repeat scroll 0 0 #FFFFFF;border:1px solid #B6B6B6;}
35
+ .onepagecheckout_datafields .col-1 .form_fields select { width: 100%; }
36
+ .onepagecheckout_datafields .col-1 .form_fields div.full { margin:0 0 15px; }
37
+ .onepagecheckout_datafields .col-1 .form_fields div.full .data_area { width: 100%; }
38
+ .onepagecheckout_datafields .col-1 .form_fields div.full input.t1 { width: 95%; padding:2px; background:none repeat scroll 0 0 #FFFFFF;border:1px solid #B6B6B6;}
39
+ .onepagecheckout_datafields .col-1 .form_fields div.full select { width: 97%; }
40
+
41
+ .onepagecheckout_datafields .col-2 .form_fields div.full .data_area { width: 275px; }
42
+ .onepagecheckout_datafields .col-2 .form_fields div.full textarea { width: 254px; height: 85px; }
43
+ .onepagecheckout_datafields .col-2 .form-list li.wide .input-box { width: 275px; }
44
+ .onepagecheckout_datafields .col-2 .form-list li.wide textarea { width: 254px; height: 85px; }
45
+
46
+ .onepagecheckout_datafields .col-3 .form_fields div.full .data_area { width: 275px; }
47
+ .onepagecheckout_datafields .col-3 .form_fields div.full textarea { width: 280px; height: 60px; }
48
+ .onepagecheckout_datafields .col-3 .form-list li.wide .input-box { width: 275px; }
49
+ .onepagecheckout_datafields .col-3 .form-list li.wide textarea { width: 280px; height: 60px; }
50
+
51
+ .onepagecheckout_datafields #comment-block { width: 100%; }
52
+ .onepagecheckout_datafields #comment-label { font-weight:normal; }
53
+ .onepagecheckout_datafields #comment-block #order-comment{ width: 100%; padding:0px;}
54
+
55
+ .form_fields label {color:#767676;float:left;font-weight:normal;position:relative;z-index:0;}
56
+
57
+ .onepagecheckout_datafields .form_fields li {margin:0 0 8px;}
58
+ .onepagecheckout_datafields .form_fields li.options input.radio,
59
+ .onepagecheckout_datafields .form_fields li.options input.checkbox {margin-right:3px;}
60
+ .onepagecheckout_datafields .form_fields li.options label {float:none;}
61
+ .onepagecheckout_datafields .form_fields li.options .input-box {clear:none;display:inline;width:auto;}
62
+ li.options label {color:#767676;}
63
+
64
+ input, select, textarea, button{color:#000;}
65
+
66
+ #onepagecheckout_orderform .col3-set .col-2 , #onepagecheckout_orderform .col3-set .col-1 { min-height: 450px;}
67
+
68
+ .onepagecheckout_datafields .gift-messages-form .item .details .form-list .field,
69
+ .onepagecheckout_datafields .gift-messages-form .item .details .form-list .input-box,
70
+ .onepagecheckout_datafields .gift-messages-form .item .details .form-list li.wide .input-box { width:186px; }
71
+ .onepagecheckout_datafields .gift-messages-form .item .details .form-list input.input-text,
72
+ .onepagecheckout_datafields .gift-messages-form .item .details .form-list li.wide textarea { width:165px; }
73
+
74
+ .onepagecheckout_datafields .sp-methods { margin: 0; }
75
+ .onepagecheckout_datafields #checkout-review-submit { margin: 10px 0 0; }
76
+ .onepagecheckout_datafields .checkout-agreements li { margin: 0 0 30px 0; }
77
+
78
+ .onepagecheckout_datafields .loading { background: url(../images/onepagecheckout/loader.gif) no-repeat 50% 50%; }
79
+
80
+ .onepagecheckout_datafields #checkout-shipping-method-load,
81
+ .onepagecheckout_datafields #checkout-payment-method-load,
82
+ .onepagecheckout_datafields #checkout-review-load { min-height: 50px; }
83
+
84
+ .onepagecheckout_datafields .newsletter { margin:0; padding:35px 0 10px 0; }
85
+ .onepagecheckout_datafields .buttons-set { margin: 5px 0 0; border:0;padding:2px 0 0;}
86
+ .onepagecheckout_datafields .checkout-agreements .last { margin: 0; }
87
+
88
+ .onepagecheckout_loginlink{ color:#767676;}
89
+
90
+ .onepagecheckout_datafields .discount .buttons-set button:first-child{margin-left:0}
91
+ /*
92
+ #onepagecheckout_orderform button.btn-checkout{float:right;border:1px solid #ccc;margin-bottom:10px;
93
+ background:url("../images/onepagecheckout/buttonbg.gif") repeat-x scroll 0 0 #00A7D1;
94
+ -moz-box-shadow: 3px 3px 5px #ccc;-webkit-box-shadow: 3px 3px 5px #ccc;box-shadow: 3px 3px 5px #ccc;}
95
+ #onepagecheckout_orderform button.btn-checkout span {background:none no-repeat scroll 0 0 transparent;border:0 none;
96
+ color:#FFFFFF;font:bold 16px/32px Arial,Helvetica,sans-serif;height:32px !important;padding:0 0 0 20px;text-transform:uppercase;}
97
+ #onepagecheckout_orderform button.btn-checkout span span{background-position:100% 0;padding:0 20px 0 0;}
98
+ */
99
+
100
+ #onepagecheckout_orderform button.btn-checkout{border:0;margin-bottom:10px;padding:0 20px;
101
+ background:url("../images/onepagecheckout/buttonbg.gif") repeat-x scroll 0 0 #F18200; /*00A7D1*/
102
+ color:#FFFFFF;font:bold 16px/32px Arial,Helvetica,sans-serif;height:32px !important;text-transform:none;
103
+ box-shadow:0px 0px 8px #555;
104
+ -webkit-box-shadow: 0px 0px 8px #555;
105
+ -moz-box-shadow:0px 0px 8px #555;
106
+ filter: progid:DXImageTransform.Microsoft.dropShadow(color=#555, offX=0, offY=0, positive=true);
107
+ }
108
+
109
+ #onepagecheckout_orderform .form_fields sup {color:#767676;font-size:100%;line-height:0;margin-left:3px;position:relative;top:6px;}
110
+
111
+ #onepagecheckout_orderform .form-list label.required em{color:#767676;}
112
+
113
+ /* CHECKOUT Review Your Order Table */
114
+ #checkout-review-table-wrapper{margin-top:-5px;}
115
+ .order-products-table { width:100%;color:#767676;}
116
+ .order-products-table .odd { background:#fff; }
117
+ .order-products-table .even { background:#fff; }
118
+ .order-products-table td.last,
119
+ .order-products-table th.last { border-right:0; width:30%;}
120
+ /*
121
+ .order-products-table tr.last th,
122
+ .order-products-table tr.last td { border-bottom:0 !important; }
123
+ */
124
+ .order-products-table th { padding:3px 8px; font-weight:bold; border-bottom:1px solid #BFBFBF;}
125
+ .order-products-table td { padding:8px 8px 2px;}
126
+
127
+ .order-products-table thead th{font-weight:bold;border-bottom:1px solid #848484;font-size:13px;padding:2px 0;color:#000;white-space:nowrap;vertical-align:middle;text-transform:uppercase;}
128
+ .order-products-table thead th.wrap { white-space:normal; }
129
+ .order-products-table thead th a,
130
+ .order-products-table thead th a:hover { color:#fff; }
131
+ .order-products-table thead th .tax-flag { font-size:11px; white-space:nowrap; }
132
+
133
+ .order-products-table tfoot { border:0;}
134
+ .order-products-table tfoot tr.first td{background-color:#ffffff;}
135
+ .order-products-table tfoot tr.last td{border:0 none !important;font-size:13px;text-transform:uppercase;color:#000;}
136
+ .order-products-table tfoot tr { background-color:#FFFFFF !important; }
137
+ .order-products-table tfoot td { border-bottom:1px solid #BFBFBF; }
138
+ .order-products-table tfoot strong { font-size:105%; }
139
+
140
+ .order-products-table tbody th,
141
+ .order-products-table tbody td { border:0; border-bottom:1px dotted #BFBFBF;}
142
+
143
+ .order-products-table tbody.odd tr { background:#f8f7f5 !important; }
144
+ .order-products-table tbody.even tr { background:#f6f6f6 !important; }
145
+ .order-products-table tbody.odd tr td,
146
+ .order-products-table tbody.even tr td { border-bottom:0; }
147
+ .order-products-table tbody.odd tr.border td,
148
+ .order-products-table tbody.even tr.border td { border-bottom:1px solid #d9dde3; }
149
+
150
+ .order-products-table tbody td .option-label { font-weight:bold; font-style:italic; }
151
+ .order-products-table tbody td .option-value { padding-left:10px; }
152
+
153
+ .clr{clear:both;}
154
+
155
+ p.agree a{color:#8E8D8B;}
156
+ p.newsletter label{color:#8E8D8B;}
157
+
158
+ .onepagecheckout-window { border: none; background: #fff; z-index: 999; position: absolute; text-align: left; }
159
+ .onepagecheckout-window .page-title span { color:#0A263C; font-size:20px; margin:0; }
160
+ .onepagecheckout-window .content { padding: 7px; overflow: auto; }
161
+ .onepagecheckout-window .close { position: absolute; top: -15px; right: -16px; width: 16px; height: 16px; background: url(../images/onepagecheckout/cancel_round.png) no-repeat 50% 50%; }
162
+ .onepagecheckout-window .buttons-set { margin: 1em 0 0; }
163
+
164
+ .d-shadow { position: absolute; width: 30%; left: 20%; top: 10%; }
165
+ .d-shadow-wrap { position: relative; width: 100%; padding: 15px 21px 0 21px; margin: -15px -21px 0 -21px; overflow: hidden; }
166
+ .d-sh-cn { position: absolute; background: url(../images/onepagecheckout/shd-medium.png) no-repeat; left: -25px; z-index: -1; }
167
+ .d-sh-tl,
168
+ .d-sh-tr { height: 500px; top: -28px; }
169
+ .d-sh-tl,
170
+ .d-sh-bl { width: 100%; }
171
+ .d-sh-tr,
172
+ .d-sh-br { width: 25px; margin-left: 100%; }
173
+ .d-sh-bl,
174
+ .d-sh-br { height: 28px; }
175
+ .d-sh-bl { left: -46px; padding-right: 42px; clip: rect(auto auto auto 25px); }
176
+ .d-sh-br { left: -4px; }
177
+
178
+ /* IE6 fix */
179
+ * html .onepagecheckout-hidden { visibility: hidden; }
180
+ * html .onepagecheckout-window { width: 500px; }
181
+ * html .d-sh-tl, * html .d-sh-tr { padding-right:42px; }
182
+ /* IE7 fix */
183
+ *:first-child+html .onepagecheckout-window { width: 500px; }
skin/frontend/base/default/images/onepagecheckout/buttonbg.gif ADDED
Binary file
skin/frontend/base/default/images/onepagecheckout/buttonbgsmall.gif ADDED
Binary file
skin/frontend/base/default/images/onepagecheckout/cancel.png ADDED
Binary file
skin/frontend/base/default/images/onepagecheckout/cancel_round.png ADDED
Binary file
skin/frontend/base/default/images/onepagecheckout/close.png ADDED
Binary file
skin/frontend/base/default/images/onepagecheckout/loader.gif ADDED
Binary file
skin/frontend/base/default/images/onepagecheckout/place-order.jpg ADDED
Binary file
skin/frontend/base/default/images/onepagecheckout/shd-medium.png ADDED
Binary file
skin/frontend/base/default/js/onepagecheckout.js ADDED
@@ -0,0 +1,728 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var OPC = Class.create();
2
+ OPC.prototype = {
3
+ initialize: function (form, urls, agreement) {
4
+ this.acceptAgreementText = agreement;
5
+ this.successUrl = check_secure_url(urls.success);
6
+ this.saveUrl = check_secure_url(urls.save);
7
+ this.updateUrl = check_secure_url(urls.update);
8
+ this.failureUrl = check_secure_url(urls.failure);
9
+ this.form = form;
10
+ this.loadWaiting = false;
11
+ this.validator = new Validation(this.form);
12
+ this.sectionsToValidate = [payment];
13
+ if (typeof shippingMethod === 'object') {
14
+ this.sectionsToValidate.push(shippingMethod)
15
+ }
16
+ this._addEventListeners()
17
+ },
18
+ _addEventListeners: function () {
19
+ $('login-form') && $('login-form').observe('submit', function (e) {
20
+ Event.stop(e);
21
+ if (!loginForm.validator.validate()) {
22
+ return
23
+ }
24
+ $('login-please-wait').show();
25
+ $('send2').setAttribute('disabled', 'disabled');
26
+ $$('#login-form .buttons-set')[0].addClassName('disabled').setOpacity(0.5);
27
+ new Ajax.Request($('login-form').action, {
28
+ parameters: $('login-form').serialize(),
29
+ onSuccess: function (transport) {
30
+ OPC.Messenger.clear('login-form');
31
+ var response = transport.responseText.evalJSON();
32
+ if (response.error) {
33
+ OPC.Messenger.add(response.error, 'login-form', 'error')
34
+ }
35
+ if (response.redirect) {
36
+ document.location = response.redirect;
37
+ return
38
+ }
39
+ $('login-please-wait').hide();
40
+ $('send2').removeAttribute('disabled');
41
+ $$('#login-form .buttons-set')[0].removeClassName('disabled').setOpacity(1)
42
+ }
43
+ })
44
+ });
45
+ $('forgot-password-form') && $('forgot-password-form').observe('submit', function (e) {
46
+ Event.stop(e);
47
+ if (!forgotForm.validator.validate()) {
48
+ return
49
+ }
50
+ $('forgot-please-wait').show();
51
+ $('btn-forgot').setAttribute('disabled', 'disabled');
52
+ $$('#forgot-password-form .buttons-set')[0].addClassName('disabled').setOpacity(0.5);
53
+ new Ajax.Request($('forgot-password-form').action, {
54
+ parameters: $('forgot-password-form').serialize(),
55
+ onSuccess: function (transport) {
56
+ OPC.Messenger.clear('forgot-password-form');
57
+ $('forgot-please-wait').hide();
58
+ $('btn-forgot').removeAttribute('disabled');
59
+ $$('#forgot-password-form .buttons-set')[0].removeClassName('disabled').setOpacity(1);
60
+ var response = transport.responseText.evalJSON();
61
+ if (response.error) {
62
+ OPC.Messenger.add(response.error, 'forgot-password-form', 'error')
63
+ } else if (response.message) {
64
+ open_login();
65
+ OPC.Messenger.clear('login-form');
66
+ OPC.Messenger.add(response.message, 'login-form', 'success')
67
+ }
68
+ }
69
+ })
70
+ })
71
+ },
72
+ ajaxFailure: function () {
73
+ location.href = this.failureUrl
74
+ },
75
+ _disableEnableAll: function (element, isDisabled) {
76
+ var descendants = element.descendants();
77
+ for (var k in descendants) {
78
+ descendants[k].disabled = isDisabled
79
+ }
80
+ element.disabled = isDisabled
81
+ },
82
+ setLoadWaiting: function (flag) {
83
+ if (flag) {
84
+ var container = $('review-buttons-container');
85
+ container.addClassName('disabled');
86
+ container.setStyle({
87
+ opacity: 0.5
88
+ });
89
+ this._disableEnableAll(container, true)
90
+ } else if (this.loadWaiting) {
91
+ var container = $('review-buttons-container');
92
+ container.removeClassName('disabled');
93
+ container.setStyle({
94
+ opacity: 1
95
+ });
96
+ this._disableEnableAll(container, false)
97
+ }
98
+ this.loadWaiting = flag
99
+ },
100
+ save: function () {
101
+ if (this.loadWaiting != false) {
102
+ return
103
+ }
104
+ var isValid = true;
105
+ if (!this.validator.validate()) {
106
+ isValid = false
107
+ }
108
+ for (i in this.sectionsToValidate) {
109
+ if (typeof this.sectionsToValidate[i] === 'function') {
110
+ continue
111
+ }
112
+ if (!this.sectionsToValidate[i].validate()) {
113
+ isValid = false
114
+ }
115
+ }
116
+ OPC.Messenger.clear('checkout-review-submit');
117
+ $$('#checkout-review-submit .checkout-agreements input[type="checkbox"]').each(function (el) {
118
+ if (!el.checked) {
119
+ OPC.Messenger.add(this.acceptAgreementText, 'checkout-review-submit', 'error');
120
+ isValid = false;
121
+ throw $break
122
+ }
123
+ }.bind(this));
124
+ if (!isValid) {
125
+ var validationMessages = $$('.validation-advice, .messages').findAll(function (el) {
126
+ return el.visible()
127
+ });
128
+ if (!validationMessages.length) {
129
+ return
130
+ }
131
+ var viewportSize = document.viewport.getDimensions();
132
+ var hiddenMessages = [];
133
+ var needToScroll = true;
134
+ validationMessages.each(function (el) {
135
+ var offset = el.viewportOffset();
136
+ if (offset.top < 0 || offset.top > viewportSize.height || offset.left < 0 || offset.left > viewportSize.width) {
137
+ hiddenMessages.push(el)
138
+ } else {
139
+ needToScroll = false
140
+ }
141
+ });
142
+ if (needToScroll) {
143
+ Effect.ScrollTo(validationMessages[0], {
144
+ duration: 1,
145
+ offset: -20
146
+ })
147
+ }
148
+ return
149
+ }
150
+ checkout.setLoadWaiting(true);
151
+ var params = Form.serialize(this.form);
152
+ $('review-please-wait').show();
153
+ var request = new Ajax.Request(this.saveUrl, {
154
+ method: 'post',
155
+ parameters: params,
156
+ onSuccess: this.setResponse.bind(this),
157
+ onFailure: this.ajaxFailure.bind(this)
158
+ })
159
+ },
160
+ update: function (params) {
161
+ var parameters = $(this.form).serialize(true);
162
+ for (var i in params) {
163
+ if (!params[i]) {
164
+ continue
165
+ }
166
+ var obj = $('checkout-' + i + '-load');
167
+ if (obj != null) {
168
+ var size = obj.getDimensions();
169
+ obj.setStyle({
170
+ 'width': size.width + 'px',
171
+ 'height': size.height + 'px'
172
+ }).update('').addClassName('loading');
173
+ parameters[i] = params[i]
174
+ }
175
+ }
176
+ checkout.setLoadWaiting(true);
177
+ var request = new Ajax.Request(this.updateUrl, {
178
+ method: 'post',
179
+ onSuccess: this.setResponse.bind(this),
180
+ onFailure: this.ajaxFailure.bind(this),
181
+ parameters: parameters
182
+ })
183
+ },
184
+ setResponse: function (response) {
185
+ response = response.responseText.evalJSON();
186
+ if (response.redirect) {
187
+ location.href = check_secure_url(response.redirect);
188
+ return true
189
+ }
190
+ if (response.order_created) {
191
+ window.location = this.successUrl;
192
+ return
193
+ } else if (response.error_messages) {
194
+ var msg = response.error_messages;
195
+ if (typeof (msg) == 'object') {
196
+ msg = msg.join("\n")
197
+ }
198
+ alert(msg)
199
+ }
200
+ checkout.setLoadWaiting(false);
201
+ $('review-please-wait').hide();
202
+ if (response.update_section) {
203
+ for (var i in response.update_section) {
204
+ ch_obj = $('checkout-' + i + '-load');
205
+ if (ch_obj != null) {
206
+ ch_obj.setStyle({
207
+ 'width': 'auto',
208
+ 'height': 'auto'
209
+ }).update(response.update_section[i]).setOpacity(1).removeClassName('loading');
210
+ if (i === 'shipping-method') {
211
+ shippingMethod.addObservers()
212
+ }
213
+ }
214
+ }
215
+ }
216
+ if (response.duplicateBillingInfo) {
217
+ shipping.syncWithBilling()
218
+ }
219
+ if (response.reload_totals) {
220
+ checkout.update({
221
+ 'review': 1
222
+ })
223
+ }
224
+ return false
225
+ },
226
+ blockform: function () {
227
+ $(this.form).remove();
228
+ return false
229
+ }
230
+ };
231
+ var BillingAddress = Class.create();
232
+ BillingAddress.prototype = {
233
+ initialize: function () {
234
+ $('billing:country_id') && $('billing:country_id').observe('change', function () {
235
+ if ($('billing:region_id')) {function resetRegionId() {
236
+ $('billing:region_id').value = '';
237
+ $('billing:region_id')[0].selected = true
238
+ }
239
+ resetRegionId.delay(0.2)
240
+ }
241
+ if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) {
242
+ shipping.syncWithBilling()
243
+ }
244
+ checkout.update({
245
+ 'payment-method': 1,
246
+ 'shipping-method': !$('shipping:same_as_billing') || $('shipping:same_as_billing').checked ? 1 : 0
247
+ })
248
+ });
249
+ $('billing_customer_address') && $('billing_customer_address').observe('change', function () {
250
+ if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) {
251
+ shipping.syncWithBilling()
252
+ }
253
+ checkout.update({
254
+ 'payment-method': 1,
255
+ 'shipping-method': !$('shipping:same_as_billing') || $('shipping:same_as_billing').checked ? 1 : 0
256
+ })
257
+ });
258
+ $('billing:region_id') && $('billing:region_id').observe('change', function () {
259
+ if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) {
260
+ shipping.syncWithBilling();
261
+ checkout.update({
262
+ 'review': 1
263
+ })
264
+ } else if (!$('shipping:same_as_billing')) {
265
+ checkout.update({
266
+ 'review': 1
267
+ })
268
+ }
269
+ });
270
+ $('billing:postcode') && $('billing:postcode').observe('change', function () {
271
+ if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) {
272
+ shipping.syncWithBilling();
273
+ checkout.update({
274
+ 'review': 1
275
+ })
276
+ } else if (!$('shipping:same_as_billing')) {
277
+ checkout.update({
278
+ 'review': 1
279
+ })
280
+ }
281
+ })
282
+ },
283
+ newAddress: function (isNew) {
284
+ if (isNew) {
285
+ this.resetSelectedAddress();
286
+ Element.show('bill_form')
287
+ } else {
288
+ Element.hide('bill_form')
289
+ }
290
+ },
291
+ resetSelectedAddress: function () {
292
+ var selectElement = $('billing_customer_address');
293
+ if (selectElement) {
294
+ selectElement.value = ''
295
+ }
296
+ },
297
+ setCreateAccount: function (flag) {
298
+ if (flag) {
299
+ $('register-customer-password').show()
300
+ } else {
301
+ $('register-customer-password').hide()
302
+ }
303
+ }
304
+ };
305
+ var ShippingAddress = Class.create();
306
+ ShippingAddress.prototype = {
307
+ initialize: function (form) {
308
+ this.form = form;
309
+ $('shipping:country_id') && $('shipping:country_id').observe('change', function () {
310
+ if ($('shipping:region_id')) {
311
+ $('shipping:region_id').value = '';
312
+ $('shipping:region_id')[0].selected = true
313
+ }
314
+ checkout.update({
315
+ 'shipping-method': 1
316
+ })
317
+ });
318
+ $('shipping_customer_address') && $('shipping_customer_address').observe('change', function () {
319
+ checkout.update({
320
+ 'shipping-method': 1
321
+ })
322
+ });
323
+ $('shipping:region_id') && $('shipping:region_id').observe('change', function () {
324
+ checkout.update({
325
+ 'review': 1
326
+ })
327
+ });
328
+ $('shipping:postcode') && $('shipping:postcode').observe('change', function () {
329
+ checkout.update({
330
+ 'review': 1
331
+ })
332
+ })
333
+ },
334
+ newAddress: function (isNew) {
335
+ if (isNew) {
336
+ this.resetSelectedAddress();
337
+ Element.show('ship_form')
338
+ } else {
339
+ Element.hide('ship_form')
340
+ }
341
+ },
342
+ resetSelectedAddress: function () {
343
+ var selectElement = $('shipping_customer_address');
344
+ if (selectElement) {
345
+ selectElement.value = ''
346
+ }
347
+ },
348
+ setSameAsBilling: function (flag) {
349
+ $('shipping:same_as_billing').checked = flag;
350
+ $('billing:use_for_shipping').value = flag ? 1 : 0;
351
+ if (flag) {
352
+ $('ship_address_block').hide();
353
+ this.syncWithBilling();
354
+ checkout.update({
355
+ 'shipping-method': 1
356
+ })
357
+ } else {
358
+ $('ship_address_block').show()
359
+ }
360
+ },
361
+ syncWithBilling: function () {
362
+ $('billing_customer_address') && this.newAddress(!$('billing_customer_address').value);
363
+ $('shipping:same_as_billing').checked = true;
364
+ $('billing:use_for_shipping').value = 1;
365
+ if (!$('billing_customer_address') || !$('billing_customer_address').value) {
366
+ arrElements = Form.getElements(this.form);
367
+ for (var elemIndex in arrElements) {
368
+ if (arrElements[elemIndex].id) {
369
+ var sourceField = $(arrElements[elemIndex].id.replace(/^shipping:/, 'billing:'));
370
+ if (sourceField) {
371
+ arrElements[elemIndex].value = sourceField.value
372
+ }
373
+ }
374
+ }
375
+ shippingRegionUpdater.update();
376
+ $('shipping:region_id').value = $('billing:region_id').value;
377
+ $('shipping:region').value = $('billing:region').value
378
+ } else {
379
+ $('shipping_customer_address').value = $('billing_customer_address').value
380
+ }
381
+ },
382
+ setRegionValue: function () {
383
+ $('shipping:region').value = $('billing:region').value
384
+ }
385
+ };
386
+ var ShippingMethod = Class.create();
387
+ ShippingMethod.prototype = {
388
+ initialize: function () {
389
+ this.addObservers()
390
+ },
391
+ addObservers: function () {
392
+ $$('input[name="shipping_method"]').each(function (el) {
393
+ el.observe('click', function () {
394
+ checkout.update({
395
+ 'review': 1
396
+ })
397
+ })
398
+ })
399
+ },
400
+ validate: function () {
401
+ OPC.Messenger.clear('checkout-shipping-method-load');
402
+ var methods = document.getElementsByName('shipping_method');
403
+ if (methods.length == 0) {
404
+ OPC.Messenger.add(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make neccessary changes in your shipping address.'), 'checkout-shipping-method-load', 'error');
405
+ return false
406
+ }
407
+ for (var i = 0; i < methods.length; i++) {
408
+ if (methods[i].checked) {
409
+ return true
410
+ }
411
+ }
412
+ OPC.Messenger.add(Translator.translate('Please specify shipping method.'), 'checkout-shipping-method-load', 'error');
413
+ return false
414
+ }
415
+ };
416
+ var Payment = Class.create();
417
+ Payment.prototype = {
418
+ beforeInitFunc: $H({}),
419
+ afterInitFunc: $H({}),
420
+ beforeValidateFunc: $H({}),
421
+ afterValidateFunc: $H({}),
422
+ initialize: function (container) {
423
+ this.cnt = container
424
+ },
425
+ addBeforeInitFunction: function (code, func) {
426
+ this.beforeInitFunc.set(code, func)
427
+ },
428
+ beforeInit: function () {
429
+ (this.beforeInitFunc).each(function (init) {
430
+ (init.value)()
431
+ })
432
+ },
433
+ init: function () {
434
+ this.beforeInit();
435
+ var method = null;
436
+ var elements = $(this.cnt).select('input');
437
+ for (var i = 0; i < elements.length; i++) {
438
+ if (elements[i].name == 'payment[method]') {
439
+ if (elements[i].checked) method = elements[i].value
440
+ } else {
441
+ elements[i].disabled = true
442
+ }
443
+ elements[i].setAttribute('autocomplete', 'off')
444
+ }
445
+ elements = $(this.cnt).select('select');
446
+ for (var i = 0; i < elements.length; i++) {
447
+ if (elements[i].name == 'payment[method]') {
448
+ if (elements[i].checked) method = elements[i].value
449
+ } else {
450
+ elements[i].disabled = true
451
+ }
452
+ elements[i].setAttribute('autocomplete', 'off')
453
+ }
454
+ elements = $(this.cnt).select('textarea');
455
+ for (var i = 0; i < elements.length; i++) {
456
+ if (elements[i].name == 'payment[method]') {
457
+ if (elements[i].checked) method = elements[i].value
458
+ } else {
459
+ elements[i].disabled = true
460
+ }
461
+ elements[i].setAttribute('autocomplete', 'off')
462
+ }
463
+ if (method) this.switchMethod(method);
464
+ this.afterInit();
465
+ this.initWhatIsCvvListeners()
466
+ },
467
+ addAfterInitFunction: function (code, func) {
468
+ this.afterInitFunc.set(code, func)
469
+ },
470
+ afterInit: function () {
471
+ (this.afterInitFunc).each(function (init) {
472
+ (init.value)()
473
+ })
474
+ },
475
+ switchMethod: function (method) {
476
+ if (this.currentMethod && $('payment_form_' + this.currentMethod)) {
477
+ var form = $('payment_form_' + this.currentMethod);
478
+ form.style.display = 'none';
479
+ var elements = form.select('input');
480
+ for (var i = 0; i < elements.length; i++) elements[i].disabled = true;
481
+ elements = form.select('select');
482
+ for (var i = 0; i < elements.length; i++) elements[i].disabled = true;
483
+ elements = form.select('textarea');
484
+ for (var i = 0; i < elements.length; i++) elements[i].disabled = true
485
+ }
486
+ if ($('payment_form_' + method)) {
487
+ var form = $('payment_form_' + method);
488
+ form.style.display = '';
489
+ var elements = form.select('input');
490
+ for (var i = 0; i < elements.length; i++) elements[i].disabled = false;
491
+ elements = form.select('select');
492
+ for (var i = 0; i < elements.length; i++) elements[i].disabled = false;
493
+ elements = form.select('textarea');
494
+ for (var i = 0; i < elements.length; i++) elements[i].disabled = false
495
+ } else {
496
+ document.body.fire('payment-method:switched', {
497
+ method_code: method
498
+ })
499
+ }
500
+ this.currentMethod = method
501
+ },
502
+ addBeforeValidateFunction: function (code, func) {
503
+ this.beforeValidateFunc.set(code, func)
504
+ },
505
+ beforeValidate: function () {
506
+ var validateResult = true;
507
+ var hasValidation = false;
508
+ (this.beforeValidateFunc).each(function (validate) {
509
+ hasValidation = true;
510
+ if ((validate.value)() == false) {
511
+ validateResult = false
512
+ }
513
+ }.bind(this));
514
+ if (!hasValidation) {
515
+ validateResult = false
516
+ }
517
+ return validateResult
518
+ },
519
+ validate: function () {
520
+ OPC.Messenger.clear('checkout-payment-method-load');
521
+ var result = this.beforeValidate();
522
+ if (result) {
523
+ return true
524
+ }
525
+ var methods = document.getElementsByName('payment[method]');
526
+ if (methods.length == 0) {
527
+ OPC.Messenger.add(Translator.translate('Your order cannot be completed at this time as there is no payment methods available for it.'), 'checkout-payment-method-load', 'error');
528
+ return false
529
+ }
530
+ for (var i = 0; i < methods.length; i++) {
531
+ if (methods[i].checked) {
532
+ return true
533
+ }
534
+ }
535
+ result = this.afterValidate();
536
+ if (result) {
537
+ return true
538
+ }
539
+ OPC.Messenger.add(Translator.translate('Please specify payment method.'), 'checkout-payment-method-load', 'error');
540
+ return false
541
+ },
542
+ addAfterValidateFunction: function (code, func) {
543
+ this.afterValidateFunc.set(code, func)
544
+ },
545
+ afterValidate: function () {
546
+ var validateResult = true;
547
+ var hasValidation = false;
548
+ (this.afterValidateFunc).each(function (validate) {
549
+ hasValidation = true;
550
+ if ((validate.value)() == false) {
551
+ validateResult = false
552
+ }
553
+ }.bind(this));
554
+ if (!hasValidation) {
555
+ validateResult = false
556
+ }
557
+ return validateResult
558
+ },
559
+ initWhatIsCvvListeners: function () {
560
+ $$('.cvv-what-is-this').each(function (element) {
561
+ Event.observe(element, 'click', toggleToolTip)
562
+ })
563
+ }
564
+ };
565
+ OPC.Messenger = {
566
+ add: function (message, section, type) {
567
+ var s_obj = $(section);
568
+ if (s_obj != null) {
569
+ var ul = $(section).select('.messages')[0];
570
+ if (!ul) {
571
+ $(section).insert({
572
+ top: '<ul class="messages"></ul>'
573
+ });
574
+ ul = $(section).select('.messages')[0]
575
+ }
576
+ var li = $(ul).select('.' + type + '-msg')[0];
577
+ if (!li) {
578
+ $(ul).insert({
579
+ top: '<li class="' + type + '-msg"><ul></ul></li>'
580
+ });
581
+ li = $(ul).select('.' + type + '-msg')[0]
582
+ }
583
+ $(li).select('ul')[0].insert('<li>' + message + '</li>')
584
+ }
585
+ },
586
+ clear: function (section) {
587
+ var s_obj = $(section);
588
+ if (s_obj != null) {
589
+ var ul = $(section).select('.messages')[0];
590
+ if (ul) {
591
+ ul.remove()
592
+ }
593
+ }
594
+ }
595
+ };
596
+ OPC.Window = Class.create();
597
+ OPC.Window.prototype = {
598
+ initialize: function (config) {
599
+ this.config = Object.extend({
600
+ width: 'auto',
601
+ height: 'auto',
602
+ maxWidth: 500,
603
+ maxHeight: 400,
604
+ triggers: null,
605
+ markup: '<div class="d-shadow-wrap">' + '<div class="content"></div>' + '<div class="d-sh-cn d-sh-tl"></div><div class="d-sh-cn d-sh-tr"></div>' + '</div>' + '<div class="d-sh-cn d-sh-bl"></div><div class="d-sh-cn d-sh-br"></div>' + '<a href="javascript:void(0)" class="close"></a>'
606
+ }, config || {});
607
+ this._prepareMarkup();
608
+ this._attachEventListeners()
609
+ },
610
+ show: function () {
611
+ if (!this.centered) {
612
+ this.center()
613
+ }
614
+ $$('select').invoke('addClassName', 'onepagecheckout-hidden');
615
+ this.window.show()
616
+ },
617
+ hide: function () {
618
+ this.window.hide();
619
+ $$('select').invoke('removeClassName', 'onepagecheckout-hidden')
620
+ },
621
+ update: function (content) {
622
+ this.content.setStyle({
623
+ width: isNaN(this.config.width) ? this.config.width : this.config.width + 'px',
624
+ height: isNaN(this.config.height) ? this.config.height : this.config.height + 'px'
625
+ });
626
+ this.content.update(content);
627
+ this.updateSize();
628
+ this.center();
629
+ return this
630
+ },
631
+ center: function () {
632
+ var viewportSize = document.viewport.getDimensions();
633
+ var viewportOffset = document.viewport.getScrollOffsets();
634
+ this.setPosition(viewportSize.width / 2 - this.window.getWidth() / 2 + viewportOffset.left, viewportSize.height / 2 - this.window.getHeight() / 2 + viewportOffset.top);
635
+ this.centered = true
636
+ },
637
+ setPosition: function (x, y) {
638
+ this.window.setStyle({
639
+ left: x + 'px',
640
+ top: y + 'px'
641
+ })
642
+ },
643
+ activate: function (trigger) {
644
+ this.update(this.config.triggers[trigger].window.show()).show()
645
+ },
646
+ updateSize: function () {
647
+ this.window.setStyle({
648
+ visibility: 'hidden'
649
+ }).show();
650
+ var size = this.content.getDimensions();
651
+ if ('auto' === this.config.width && size.width > this.config.maxWidth) {
652
+ this.content.setStyle({
653
+ width: this.config.maxWidth + 'px'
654
+ })
655
+ }
656
+ if ('auto' === this.config.height && size.height > this.config.maxHeight) {
657
+ this.content.setStyle({
658
+ height: this.config.maxHeight + 'px'
659
+ })
660
+ }
661
+ this.window.hide().setStyle({
662
+ visibility: 'visible'
663
+ })
664
+ },
665
+ _prepareMarkup: function () {
666
+ this.window = new Element('div');
667
+ this.window.addClassName('onepagecheckout-window');
668
+ this.window.update(this.config.markup).hide();
669
+ this.content = this.window.select('.content')[0];
670
+ this.close = this.window.select('.close')[0];
671
+ $(document.body).insert(this.window)
672
+ },
673
+ _attachEventListeners: function () {
674
+
675
+ this.close.observe('click', this.hide.bind(this));
676
+ document.observe('keypress', this._onKeyPress.bind(this));
677
+ if (this.config.triggers) {
678
+ if (this.config.triggers.length!=0) {
679
+ for (var i in this.config.triggers) {
680
+ this.config.triggers[i].el.each(function (el) {
681
+ var trigger = this.config.triggers[i];
682
+ el.observe(this.config.triggers[i].event, function (e) {
683
+ Event.stop(e);
684
+ if (!trigger.window) {
685
+ return
686
+ }
687
+ var oldContent = this.content.down();
688
+ oldContent && $(document.body).insert(oldContent.hide());
689
+ this.update(trigger.window.show()).show()
690
+ }.bind(this))
691
+ }.bind(this))
692
+ }
693
+ }
694
+ }
695
+ },
696
+ _onKeyPress: function (e) {
697
+ var code = e.keyCode;
698
+ if (code == Event.KEY_ESC) {
699
+ this.hide()
700
+ }
701
+ }
702
+ };
703
+ function open_login() {
704
+ $('onepagecheckout_forgotbox').hide();
705
+ $('onepagecheckout_loginbox').show()
706
+ }function open_forgot() {
707
+ $('onepagecheckout_loginbox').hide();
708
+ $('onepagecheckout_forgotbox').show()
709
+ }function close_login() {
710
+ $('onepagecheckout_forgotbox').hide();
711
+ $('onepagecheckout_loginbox').hide()
712
+ }function check_secure_url(url) {
713
+ if (http_type == 'https') {
714
+ var u1 = url.substr(0, 5);
715
+ if (u1 != 'https') {
716
+ if (u1 == 'http:') url = 'https:' + url.substr(5);
717
+ else url = 'https://' + url
718
+ }
719
+ }
720
+ return url
721
+ }
722
+ window.onload = function () {
723
+ checkout.update({
724
+ 'payment-method': 1,
725
+ 'shipping-method': 1,
726
+ 'review': 1
727
+ })
728
+ }