notime_same_day_delivery - Version 1.0.0

Version Notes

Initial release

Download this release

Release Info

Developer notime
Extension notime_same_day_delivery
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Notime/Shipping/Block/Checkout/Onepage/Shipping/Notime.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One page checkout status
5
+ *
6
+ * @category Mage
7
+ * @category Mage
8
+ * @package Mage_Checkout
9
+ * @author Magento Core Team <core@magentocommerce.com>
10
+ */
11
+ class Notime_Shipping_Block_Checkout_Onepage_Shipping_Notime extends Mage_Checkout_Block_Onepage_Abstract
12
+ {
13
+ protected function _construct()
14
+ {
15
+ $this->setTemplate('notime/checkout/onepage/shipping_method/notime.phtml');
16
+
17
+ /*
18
+ $this->getCheckout()->setStepData('shipping_method', array(
19
+ 'label' => Mage::helper('checkout')->__('Shipping Method'),
20
+ 'is_show' => $this->isShow()
21
+ ));
22
+ parent::_construct();
23
+ */
24
+ }
25
+
26
+ public function getFormCode(){
27
+ return 'notime_additional_block';
28
+ }
29
+
30
+ /**
31
+ * Retrieve is allow and show block
32
+ *
33
+ * @return bool
34
+ */
35
+ public function isShow()
36
+ {
37
+ return !$this->getQuote()->isVirtual();
38
+ }
39
+
40
+ /**
41
+ * Return shipping widget code
42
+ * @return mixed|string
43
+ */
44
+ public function getWidgetButton() {
45
+ if(Mage::getStoreConfig('carriers/notime/active', Mage::app()->getStore()->getId())) {
46
+ return Mage::getStoreConfig('carriers/notime/widget_editmode_button', Mage::app()->getStore()->getId());
47
+ }
48
+ return '';
49
+ }
50
+
51
+ /**
52
+ * @return string
53
+ */
54
+ public function getWidgetCodeSrc() {
55
+ if(Mage::getStoreConfig('carriers/notime/active', Mage::app()->getStore()->getId())) {
56
+ $matches = array();
57
+ preg_match('/src=[\"\']([^"]*)[\"\']/i', Mage::getStoreConfig('carriers/notime/widget_editmode_code', Mage::app()->getStore()->getId()), $matches) ;
58
+ if(isset($matches[1])) {
59
+ return trim($matches[1]);
60
+ }
61
+ }
62
+ return '';
63
+ }
64
+
65
+ /**
66
+ * @return string
67
+ */
68
+ public function getWidgetZipCode() {
69
+ if(Mage::getStoreConfig('carriers/notime/active', Mage::app()->getStore()->getId())) {
70
+ $matches = array();
71
+ preg_match('/ecommerceZipCodeId=(.*?)[\&\'\"]/', Mage::getStoreConfig('carriers/notime/widget_editmode_code', Mage::app()->getStore()->getId()), $matches) ;
72
+ if(isset($matches[1])) {
73
+ return trim($matches[1]);
74
+ }
75
+ }
76
+ return '';
77
+ }
78
+
79
+ }
app/code/local/Notime/Shipping/Block/Product/Widget.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Notime_Shipping_Block_Product_Widget extends Mage_Core_Block_Template
3
+ {
4
+ public function __construct() {
5
+ $this->setTemplate('notime/product/widget.phtml');
6
+ }
7
+
8
+ /**
9
+ * @return mixed
10
+ */
11
+ public function getProduct()
12
+ {
13
+ $product = $this->_getData('product');
14
+ if (!$product) {
15
+ $product = Mage::registry('product');
16
+ }
17
+ return $product;
18
+ }
19
+
20
+ /**
21
+ * @return mixed|string
22
+ * Get Notime widget
23
+ */
24
+ public function getNotimeWidget() {
25
+ if(Mage::getStoreConfig('carriers/notime/active', Mage::app()->getStore()->getId())
26
+ && Mage::getStoreConfig('carriers/notime/show_product_widget', Mage::app()->getStore()->getId())
27
+ && $this->getProduct()->getNotimeWidget()
28
+ ) {
29
+ return
30
+ Mage::getStoreConfig('carriers/notime/widget_viewmode_button', Mage::app()->getStore()->getId())
31
+ .Mage::getStoreConfig('carriers/notime/widget_viewmode_code', Mage::app()->getStore()->getId());
32
+ }
33
+ return '';
34
+ }
35
+ }
app/code/local/Notime/Shipping/Block/ShippingMethod.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Notime_Shipping_Block_ShippingMethod extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
3
+ {
4
+ public function __construct(){
5
+ $this->setTemplate('notime/shipping_method/available.phtml');
6
+ }
7
+ }
app/code/local/Notime/Shipping/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Notime_Shipping_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ }
app/code/local/Notime/Shipping/Model/Carrier/Notime.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @category Mage
6
+ * @package Mage_Shipping
7
+ * @author Magento Core Team <core@magentocommerce.com>
8
+ */
9
+ class Notime_Shipping_Model_Carrier_Notime
10
+ extends Mage_Shipping_Model_Carrier_Abstract
11
+ implements Mage_Shipping_Model_Carrier_Interface
12
+ {
13
+
14
+ protected $_code = 'notime';
15
+
16
+ /*
17
+ *
18
+ */
19
+ public function getFormBlock(){
20
+ return 'notimeshipping/checkout_onepage_shipping_notime';
21
+ }
22
+
23
+ /**
24
+ * Enter description here...
25
+ *
26
+ * @param Mage_Shipping_Model_Rate_Request $data
27
+ * @return Mage_Shipping_Model_Rate_Result
28
+ */
29
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
30
+ {
31
+
32
+ if (!$this->getConfigFlag('active')) {
33
+ return false;
34
+ }
35
+
36
+ $freeBoxes = 0;
37
+ if ($request->getAllItems()) {
38
+ foreach ($request->getAllItems() as $item) {
39
+ if ($item->getFreeShipping() && !$item->getProduct()->isVirtual()) {
40
+ $freeBoxes+=$item->getQty();
41
+ }
42
+ }
43
+ }
44
+ $this->setFreeBoxes($freeBoxes);
45
+
46
+ $shippingPrice = '0.00';
47
+
48
+ $result = Mage::getModel('shipping/rate_result');
49
+ if ($this->getConfigData('type') == 'O') { // per order
50
+ $shippingPrice = $this->getConfigData('price');
51
+ } elseif ($this->getConfigData('type') == 'I') { // per item
52
+ $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
53
+ } else {
54
+ $shippingPrice = false;
55
+ }
56
+
57
+ if ($shippingPrice !== false) {
58
+ $method = Mage::getModel('shipping/rate_result_method');
59
+
60
+ $method->setCarrier($this->_code);
61
+ $method->setCarrierTitle($this->getConfigData('title'));
62
+
63
+ $method->setMethod($this->_code);
64
+ $method->setMethodTitle($this->getConfigData('name'));
65
+
66
+ if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
67
+ $shippingPrice = '0.00';
68
+ }
69
+
70
+ $method->setPrice($shippingPrice);
71
+ $method->setCost($shippingPrice);
72
+
73
+ $result->append($method);
74
+ }
75
+
76
+ return $result;
77
+ }
78
+
79
+ /**
80
+ * @return array
81
+ */
82
+ public function getAllowedMethods() {
83
+
84
+ return array('notime' => $this->getConfigData('name'));
85
+ }
86
+
87
+ }
app/code/local/Notime/Shipping/Model/Observer.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Notime_Shipping_Model_Observer
4
+ {
5
+
6
+ /**
7
+ * Add order id into armystar_ups and send request to UPS
8
+ *
9
+ */
10
+ public function notime_shipping_sales_order_complete(Varien_Event_Observer $observer) {
11
+
12
+ $_order = $observer->getEvent()->getOrder();
13
+
14
+ if(Mage_Sales_Model_Order::STATE_COMPLETE == $_order->getStatus()) {
15
+
16
+ // check if order use Notime shipping
17
+ if('notime_notime' == $_order->getShippingMethod()) {
18
+
19
+ $resource = Mage::getSingleton('core/resource');
20
+ $readConnection = $resource->getConnection('core_read');
21
+ $writeConnection = $resource->getConnection('core_write');
22
+
23
+ $query = 'SELECT shipment_id FROM notime_shipping WHERE `status` = 0 AND quote_id = '. $_order->getQuoteId() .' LIMIT 1';
24
+ $shipment_id = $readConnection->fetchOne($query);
25
+ if($shipment_id) {
26
+ try {
27
+
28
+ // send POST request to Notime
29
+ $shipment_id = $shipment_id;
30
+ if($shipment_id) {
31
+
32
+ // SEND POST REQUEST
33
+ // get customer shipping address
34
+ $_shippingAddress = $_order->getShippingAddress();
35
+ if($_shippingAddress->getId()) {
36
+ $params = array(
37
+ 'ShipmentId' => $shipment_id,
38
+ 'Dropoff' => array(
39
+ 'Name' => $_shippingAddress->getFirstname() .' '. $_shippingAddress->getLastname(),
40
+ 'Phone' => $_shippingAddress->getTelephone(),
41
+ 'City' => $_shippingAddress->getCity(),
42
+ 'CountryCode' => $_shippingAddress->getCountryId(),
43
+ 'Postcode' => $_shippingAddress->getPostcode(),
44
+ 'Streetaddress' => implode(' ',$_shippingAddress->getStreet())
45
+ )
46
+ );
47
+
48
+ $client = new Varien_Http_Client();
49
+
50
+ $client->setUri('http://nt-staging-api.azurewebsites.net/api/shipment/approve')
51
+ ->setConfig(array('timeout' => 30, 'keepalive' => 1))
52
+ ->setHeaders(array(
53
+ 'Ocp-Apim-Subscription-Key' => '493dc25bf9674ccb9c5920a035c1f777',
54
+ ))
55
+ ->setRawData(json_encode($params), 'application/json')
56
+ ->setMethod(Zend_Http_Client::POST);
57
+
58
+ $client->setHeaders(array('Content-Type: application/json'));
59
+
60
+ $response = $client->request();
61
+
62
+ if($response->isSuccessful()){
63
+ // update status
64
+ $writeConnection->update(
65
+ 'notime_shipping',
66
+ array('status' => 1),
67
+ 'quote_id='.$_order->getQuoteId()
68
+ );
69
+ $_order->addStatusHistoryComment('Notime->Success: Shipment was approved successfully!')->save();
70
+ } else {
71
+ Mage::log('ERROR:'.$response->getMessage(),false,'notime-shipping.log');
72
+ //$_order->addStatusHistoryComment('Notime->Error: '.$response->getMessage());
73
+ }
74
+ }
75
+ }
76
+ } catch (Exception $e) {
77
+ Mage::log($e->getMessage(),false,'notime-shipping.log');
78
+ }
79
+ }
80
+ }
81
+
82
+ }
83
+ }
84
+
85
+ /**
86
+ * save notime shipmentId to table 'notime_shipping'
87
+ *
88
+ */
89
+ public function notime_shipping_save_shipment_id($event) {
90
+
91
+ $_quote = $event->getQuote();
92
+
93
+ $request = Mage::app()->getRequest();
94
+ $shipmentId = trim($request->getPost('notime_shipment_id'));
95
+
96
+ if($shipmentId == '') { exit; }
97
+
98
+ try {
99
+
100
+ $resource = Mage::getSingleton('core/resource');
101
+ $readConnection = $resource->getConnection('core_read');
102
+ $writeConnection = $resource->getConnection('core_write');
103
+
104
+ $query = 'SELECT quote_id FROM notime_shipping WHERE quote_id = '. $_quote->getId() .' LIMIT 1';
105
+ $val = $readConnection->fetchOne($query);
106
+ if(!$val) {
107
+
108
+ $writeConnection->insert(
109
+ "notime_shipping",
110
+ array("quote_id" => $_quote->getId(),"shipment_id" => $shipmentId, "status" => 0)
111
+ );
112
+
113
+ }
114
+ } catch (Exception $e) {
115
+ mage::log('Error when processing shipping method:'.$e->getMessage(), false, 'notime_shipping.log');
116
+ }
117
+ }
118
+
119
+ public function notime_shipping_core_block_html_after($observer)
120
+ {
121
+ /* @var $block Mage_Core_Block_Abstract */
122
+ $block = $observer->getBlock();
123
+ $template = $block->getTemplate();
124
+
125
+ if(strpos($template, 'shipping_method/available.phtml') || $template=='onestepcheckout/shipping_method.phtml' || $template == 'onestepcheckout/onestepcheckout/shipping_method.phtml' || $template == 'onestepcheckout/onestep/shipping.phtml'){
126
+ if(method_exists($block, 'getShippingRates')){
127
+ foreach ($block->getShippingRates() as $code => $_rates){
128
+ if($code == 'notime'){
129
+
130
+ $endingToken = '</label>';
131
+ $html = $observer->getTransport()->getHtml();
132
+ if($pos1 = strpos($html, 'value="notime_notime"')){
133
+ $pos1 += strlen($endingToken);
134
+ if($pos2 = strpos($html, $endingToken, $pos1)){
135
+
136
+ $carrier = Mage::getModel('shipping/config')->getCarrierInstance($code);
137
+ Mage::log($carrier->getFormBlock(), false, 'notime_shipping.log');
138
+ $injectBlock = $block->getLayout()->createBlock($carrier->getFormBlock());
139
+
140
+ //Store adress id so we can use it in the ajax call done in the block
141
+ //$injectBlock->setAddressId($block->getAddress()->getId());
142
+ //$injectBlock->setCountryCode($block->getAddress()->getCountryId());
143
+ //$injectBlock->setMethodCode($code);
144
+ //$injectBlock->setRate($_rate);
145
+ //$injectBlock->setMethodInstance($carrier);
146
+
147
+ $htmlBefore = substr($html,0,$pos2+strlen($endingToken));
148
+ $htmlAfter = substr($html,$pos2);
149
+ $observer->getTransport()->setHtml($htmlBefore.$injectBlock->toHtml().$htmlAfter);
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+
157
+ //$this->AddSalesRuleJavascript($observer);
158
+ }
159
+
160
+ public function notime_shipping_salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer)
161
+ {
162
+ //$custom_price = Mage::app()->getRequest()->getPost('notime_shipment_fee');
163
+ //$quote = $observer->getQuote();
164
+ //$store = Mage::app()->getStore($quote->getStoreId());
165
+ //$carriers = Mage::getStoreConfig('carriers', $store);
166
+ //foreach ($carriers as $carrierCode => $carrierConfig) {
167
+ // if($carrierCode == 'notime'){
168
+ // $store->setConfig("carriers/{$carrierCode}/price", $custom_price);
169
+ // }
170
+ //}
171
+ }
172
+
173
+ }
app/code/local/Notime/Shipping/etc/config.xml ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Notime_Shipping>
6
+ <version>1.0.1</version>
7
+ </Notime_Shipping>
8
+ </modules>
9
+ <frontend>
10
+ <layout>
11
+ <updates>
12
+ <notime_shipping>
13
+ <file>notime.xml</file>
14
+ </notime_shipping>
15
+ </updates>
16
+ </layout>
17
+ <translate>
18
+ <modules>
19
+ <notime_shipping>
20
+ <files>
21
+ <default>Notime_Shipping.csv</default>
22
+ </files>
23
+ </notime_shipping>
24
+ </modules>
25
+ </translate>
26
+ </frontend>
27
+ <global>
28
+ <blocks>
29
+ <notimeshipping>
30
+ <class>Notime_Shipping_Block</class>
31
+ </notimeshipping>
32
+ </blocks>
33
+ <models>
34
+ <notimeshipping>
35
+ <class>Notime_Shipping_Model</class>
36
+ </notimeshipping>
37
+ </models>
38
+ <helpers>
39
+ <notimeshipping>
40
+ <class>Notime_Shipping_Helper</class>
41
+ </notimeshipping>
42
+ </helpers>
43
+ <resources>
44
+ <notimeshipping_setup>
45
+ <setup>
46
+ <module>Notime_Shipping</module>
47
+ <class>Mage_Eav_Model_Entity_Setup</class>
48
+ </setup>
49
+ <connection>
50
+ <use>core_setup</use>
51
+ </connection>
52
+ </notimeshipping_setup>
53
+ <notimeshipping_write>
54
+ <connection>
55
+ <use>core_write</use>
56
+ </connection>
57
+ </notimeshipping_write>
58
+ <notimeshipping_read>
59
+ <connection>
60
+ <use>core_read</use>
61
+ </connection>
62
+ </notimeshipping_read>
63
+ </resources>
64
+ <events>
65
+ <checkout_controller_onepage_save_shipping_method>
66
+ <observers>
67
+ <notime_save_shipment>
68
+ <type>singleton</type>
69
+ <class>Notime_Shipping_Model_Observer</class>
70
+ <method>notime_shipping_save_shipment_id</method>
71
+ </notime_save_shipment>
72
+ </observers>
73
+ </checkout_controller_onepage_save_shipping_method>
74
+ <sales_order_save_commit_after>
75
+ <observers>
76
+ <notime_order_complete>
77
+ <type>singleton</type>
78
+ <class>Notime_Shipping_Model_Observer</class>
79
+ <method>notime_shipping_sales_order_complete</method>
80
+ </notime_order_complete>
81
+ </observers>
82
+ </sales_order_save_commit_after>
83
+ <core_block_abstract_to_html_after>
84
+ <observers>
85
+ <notime_core_block_html_before>
86
+ <type>singleton</type>
87
+ <class>Notime_Shipping_Model_Observer</class>
88
+ <method>notime_shipping_core_block_html_after</method>
89
+ </notime_core_block_html_before>
90
+ </observers>
91
+ </core_block_abstract_to_html_after>
92
+ <sales_quote_collect_totals_before>
93
+ <observers>
94
+ <notime_order_change_price>
95
+ <type>singleton</type>
96
+ <class>Notime_Shipping_Model_Observer</class>
97
+ <method>notime_shipping_salesQuoteCollectTotalsBefore</method>
98
+ </notime_order_change_price>
99
+ </observers>
100
+ </sales_quote_collect_totals_before>
101
+ </events>
102
+ </global>
103
+ <adminhtml>
104
+ <translate>
105
+ <modules>
106
+ <notime_shipping>
107
+ <files>
108
+ <default>Notime_Shipping.csv</default>
109
+ </files>
110
+ </notime_shipping>
111
+ </modules>
112
+ </translate>
113
+ </adminhtml>
114
+ <default>
115
+ <carriers>
116
+ <notime>
117
+ <active>0</active>
118
+ <model>notimeshipping/carrier_notime</model>
119
+ <name>Same-day (by notime)</name>
120
+ <price>4.90</price>
121
+ <title>Same-day (by notime)</title>
122
+ <type>0</type>
123
+ <shipping_widget></shipping_widget>
124
+ <product_widget></product_widget>
125
+ <show_product_widget></show_product_widget>
126
+ <additional_info></additional_info>
127
+ <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
128
+ <sort_order>200</sort_order>
129
+ </notime>
130
+ </carriers>
131
+ </default>
132
+ </config>
app/code/local/Notime/Shipping/etc/system.xml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <carriers>
5
+ <groups>
6
+ <notime translate="label" module="notimeshipping">
7
+ <label>Notime Shipping</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>20</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ </active>
23
+ <name translate="label">
24
+ <label>Method name</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>2</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </name>
31
+ <title translate="label">
32
+ <label>Title</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>3</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </title>
39
+ <price translate="label">
40
+ <label>Price</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>4</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </price>
47
+ <type translate="label">
48
+ <label>Type</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_shipping_flatrate</source_model>
51
+ <sort_order>5</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </type>
56
+ <widget_editmode_button translate="label">
57
+ <label>Notime Widget Button (edit mode)</label>
58
+ <frontend_type>textarea</frontend_type>
59
+ <sort_order>6</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </widget_editmode_button>
64
+ <widget_editmode_code translate="label">
65
+ <label>Notime Widget Code (edit mode)</label>
66
+ <frontend_type>textarea</frontend_type>
67
+ <sort_order>7</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </widget_editmode_code>
72
+ <widget_viewmode_button translate="label">
73
+ <label>Notime Widget Button (view mode)</label>
74
+ <frontend_type>textarea</frontend_type>
75
+ <sort_order>8</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
+ </widget_viewmode_button>
80
+ <widget_viewmode_code translate="label">
81
+ <label>Notime Widget Code (view mode)</label>
82
+ <frontend_type>textarea</frontend_type>
83
+ <sort_order>9</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </widget_viewmode_code>
88
+ <show_product_widget translate="label">
89
+ <label>Notime Widget at a Product Page</label>
90
+ <frontend_type>select</frontend_type>
91
+ <source_model>adminhtml/system_config_source_yesno</source_model>
92
+ <sort_order>10</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ </show_product_widget>
97
+ <additional_info translate="label">
98
+ <label>Additional Information</label>
99
+ <frontend_type>textarea</frontend_type>
100
+ <sort_order>11</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ </additional_info>
105
+ <specificerrmsg translate="label">
106
+ <label>Displayed Error Message</label>
107
+ <frontend_type>textarea</frontend_type>
108
+ <sort_order>12</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>1</show_in_store>
112
+ </specificerrmsg>
113
+ <sort_order translate="label">
114
+ <label>Sort Order</label>
115
+ <frontend_type>text</frontend_type>
116
+ <sort_order>13</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </sort_order>
121
+ </fields>
122
+ </notime>
123
+ </groups>
124
+ </carriers>
125
+ </sections>
126
+ </config>
app/code/local/Notime/Shipping/sql/notimeshipping_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* @var $this Mage_Eav_Model_Entity_Setup */
4
+ $this->startSetup();
5
+
6
+ $this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'notime_widget', array(
7
+ 'group' => 'General',
8
+ 'input' => 'select',
9
+ 'type' => 'int',
10
+ 'source' => 'eav/entity_attribute_source_boolean',
11
+ 'backend' => '',
12
+ 'frontend' => '',
13
+ 'label' => Mage::helper('notimeshipping')->__('Show Notime widget ?'),
14
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
15
+ 'required' => false,
16
+ 'default' => 1,
17
+ 'default_value' => 1,
18
+ 'searchable' => false,
19
+ 'filterable' => false,
20
+ 'user_defined' => true,
21
+ 'visible' => false,
22
+ 'visible_on_front' => false,
23
+ 'unique' => false,
24
+ 'is_configurable' => false,
25
+ 'used_for_promo_rules' => false
26
+ ));
27
+
28
+ $this->endSetup();
app/code/local/Notime/Shipping/sql/notimeshipping_setup/mysql4-upgrade-1.0.0-1.0.1.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
3
+
4
+ $installer = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
5
+
6
+ $installer->startSetup();
7
+
8
+ try {
9
+ $installer->run("
10
+ DROP TABLE IF EXISTS {$this->getTable('notime_shipping')};
11
+ CREATE TABLE {$this->getTable('notime_shipping')} (
12
+ `id` INT(11) NOT NULL auto_increment,
13
+ `quote_id` int(6) unsigned NOT NULL default '0',
14
+ `status` tinyint(1) NOT NULL default '0',
15
+ `shipment_id` VARCHAR(255) NOT NULL default '',
16
+ PRIMARY KEY (`id`),
17
+ KEY `quote_id` ( `quote_id` )
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
19
+ ");
20
+ }catch (Exception $e) {
21
+ Mage::logException($e);
22
+ }
23
+ $installer->endSetup();
app/design/frontend/base/default/layout/notime.xml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <checkout_multishipping_shipping>
4
+ <reference name='checkout_shipping'>
5
+ <action method='setTemplate'><template>gls/checkout/multishipping/shipping.phtml</template></action>
6
+ </reference>
7
+ <reference name="head">
8
+ <action method="addItem"><type>skin_js</type><name>js/notime.js</name></action>
9
+ <action method="addItem"><type>skin_css</type><name>css/notime.css</name></action>
10
+ </reference>
11
+ </checkout_multishipping_shipping>
12
+
13
+ <checkout_onepage_index>
14
+ <reference name="head">
15
+ <action method="addItem"><type>skin_js</type><name>js/notime.js</name></action>
16
+ <action method="addItem"><type>skin_css</type><name>css/notime.css</name></action>
17
+ </reference>
18
+ </checkout_onepage_index>
19
+
20
+ <firecheckout_index_index>
21
+ <reference name="head">
22
+ <action method="addItem"><type>skin_js</type><name>js/notime.js</name></action>
23
+ <action method="addItem"><type>skin_css</type><name>css/notime.css</name></action>
24
+ </reference>
25
+ </firecheckout_index_index>
26
+
27
+ <onepagecheckout_index_index>
28
+ <reference name="head">
29
+ <action method="addItem"><type>skin_js</type><name>js/notime.js</name></action>
30
+ <action method="addItem"><type>skin_css</type><name>css/notime.css</name></action>
31
+ </reference>
32
+ </onepagecheckout_index_index>
33
+
34
+ <opc_index_index>
35
+ <reference name="head">
36
+ <action method="addItem"><type>skin_js</type><name>js/notime.js</name></action>
37
+ <action method="addItem"><type>skin_css</type><name>css/notime.css</name></action>
38
+ </reference>
39
+ </opc_index_index>
40
+
41
+ <onestepcheckout_index_index>
42
+ <reference name="head">
43
+ <action method="addItem"><type>skin_js</type><name>js/notime.js</name></action>
44
+ <action method="addItem"><type>skin_css</type><name>css/notime.css</name></action>
45
+ </reference>
46
+ </onestepcheckout_index_index>
47
+ <!--
48
+ <checkout_onepage_index>
49
+ <reference name="head">
50
+ <block type="core/text" name="notimewidget">
51
+ <action method="setText"><text><![CDATA[<script src="//nt-staging-servicemanagement.azurewebsites.net/NotimeWidget?groupId=28228cfe-12f2-4bfb-b8bf-b7ff87746e96&mode=2&notimeButtonNumber=1&language=en"></script>]]></text></action>
52
+ </block>
53
+ </reference>
54
+ </checkout_onepage_index>
55
+ -->
56
+
57
+ <!--
58
+ <checkout_onepage_index>
59
+ <reference name="checkout.onepage.shipping_method.available">
60
+ <action method="setTemplate"><template>notime/shipping_method/available.phtml</template></action>
61
+ </reference>
62
+ </checkout_onepage_index>
63
+ <checkout_onepage_shippingmethod>
64
+ <reference name="root">
65
+ <action method="setTemplate"><template>notime/shipping_method/available.phtml</template></action>
66
+ </reference>
67
+ </checkout_onepage_shippingmethod>
68
+ -->
69
+ <!-- add widget into product view page -->
70
+ <catalog_product_view>
71
+ <reference name="product.info.additional">
72
+ <block type="notimeshipping/product_widget" name="notimeshipping_product_widget" as="notimeshipping.product.widget" template="notime/product/widget.phtml" />
73
+ </reference>
74
+ </catalog_product_view>
75
+ </layout>
app/design/frontend/base/default/template/notime/checkout/onepage/shipping_method/notime.phtml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $carrier = $this->getMethodInstance();
3
+ $formCode = $this->getFormCode();
4
+ $rate_id = 'notime_notime';
5
+ $zipInputId = 'gls_zip_input_'.$formCode;
6
+ ?>
7
+
8
+ <ul class="form-list" id="<?php echo $formCode ?>">
9
+ <input type="hidden" id="<?php echo $this->getWidgetZipCode();?>" name="magento_notime_zip_code" value="<?php echo $this->getQuote()->getShippingAddress()->getPostcode();?>">
10
+ <input type="hidden" id="notime_shipment_id" name="notime_shipment_id" class="input-text required-notime-shipment" value="-">
11
+ <input type="hidden" id="notime_shipment_fee" name="notime_shipment_fee" class="input-text" value="">
12
+ <li>
13
+ <?php echo $this->getWidgetButton(); ?>
14
+ <span id="notime_shipment_success"></span>
15
+ </li>
16
+ <script type="text/javascript">
17
+ var myEventHandler = function(event) {
18
+ var generatedId = event.detail.generatedShippmentGuid;
19
+ var shipmentFee = event.detail.fee;
20
+ if(generatedId) {
21
+ $('notime_shipment_id').setValue(generatedId);
22
+ $('notime_shipment_fee').setValue(shipmentFee);
23
+ //var oldPriceWithCurrency = $$("label[for='s_method_notime_notime'] > span[class='price']")[0].innerHTML;
24
+ //var newPriceWithCurrency = oldPriceWithCurrency.replace(/\d+(\.\d{1,2})?/gi, shipmentFee);
25
+ //$$("label[for='s_method_notime_notime'] > span[class='price']")[0].update(newPriceWithCurrency);
26
+ var $validationError = $('advice-required-notime-shipment-notime_shipment_id');
27
+ if($validationError){
28
+ $validationError.hide();
29
+ }
30
+ $('notime_shipment_success').update('<?php echo $this->__('You have successfully selected time window'); ?>');
31
+ }
32
+ }
33
+ document.body.addEventListener("notime_widget:shipmentGenerated",myEventHandler);
34
+
35
+ function load_js() {
36
+ var head= document.getElementsByTagName('head')[0];
37
+ var script= document.createElement('script');
38
+ script.type= 'text/javascript';
39
+ script.src= '<?php echo $this->getWidgetCodeSrc(); ?>';
40
+ head.appendChild(script);
41
+ // http://nt-staging-servicemanagement.azurewebsites.net/NotimeWidget?groupId=28228cfe-12f2-4bfb-b8bf-b7ff87746e96&mode=2&ecommerceZipCodeId=magentoNotimeZipCode&notimeButtonNumber=1&language=en';
42
+
43
+ }
44
+ load_js();
45
+ </script>
46
+
47
+ <script type="text/javascript">
48
+ // <![CDATA[
49
+
50
+ document.observe('dom:loaded', function(){
51
+ createNotimeShippingForm<?php echo $formCode ?>();
52
+ });
53
+
54
+ createNotimeShippingForm<?php echo $formCode ?>();
55
+
56
+ function createNotimeShippingForm<?php echo $formCode ?>(){
57
+ new NotimeShippingForm('<?php echo $rate_id; ?>','<?php echo $formCode; ?>');
58
+ }
59
+
60
+ Translator.add('Click here and choose your delivery time-slot','<?php echo Mage::helper('notimeshipping')->__('Click here and choose your delivery time-slot')?>');
61
+
62
+ // ]]>
63
+ </script>
64
+ </ul>
app/design/frontend/base/default/template/notime/product/widget.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php echo $this->getNotimeWidget(); ?>
app/etc/modules/Notime_Shipping.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Notime_Shipping>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Notime_Shipping>
8
+ </modules>
9
+ </config>
10
+
11
+
app/locale/de_DE/Notime_Shipping.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ "Click here and choose your delivery time-slot","Klicken Sie hier und wahlen Sie Ihr Lieferzeit-Fenster aus"
2
+ "You have successfully selected time window","Ihre Auswahl wurde erfoglreich in unser System erfasst"
3
+ "Notime Widget Button (edit mode)","Notime Widget Button (edit mode)"
4
+ "Notime Widget Code (edit mode)","Notime Widget Code (edit mode)"
5
+ "Notime Widget Button (view mode)","Notime Widget Button (view mode)"
6
+ "Notime Widget Code (view mode)","Notime Widget Code (view mode)"
7
+ "Notime Widget at a Product Page","Notime Widget at a Product Page"
app/locale/en_US/Notime_Shipping.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ "Click here and choose your delivery time-slot","Click here and choose your delivery time-slot"
2
+ "You have successfully selected time window","You have successfully selected a time window for your delivery"
3
+ "Notime Widget Button (edit mode)","Notime Widget Button (edit mode)"
4
+ "Notime Widget Code (edit mode)","Notime Widget Code (edit mode)"
5
+ "Notime Widget Button (view mode)","Notime Widget Button (view mode)"
6
+ "Notime Widget Code (view mode)","Notime Widget Code (view mode)"
7
+ "Notime Widget at a Product Page","Notime Widget at a Product Page"
app/locale/fr_FR/Notime_Shipping.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ "Click here and choose your delivery time-slot","Click here and choose your delivery time-slot"
2
+ "You have successfully selected time window","You have successfully selected a time window for your delivery"
3
+ "Notime Widget Button (edit mode)","Notime Widget Button (edit mode)"
4
+ "Notime Widget Code (edit mode)","Notime Widget Code (edit mode)"
5
+ "Notime Widget Button (view mode)","Notime Widget Button (view mode)"
6
+ "Notime Widget Code (view mode)","Notime Widget Code (view mode)"
7
+ "Notime Widget at a Product Page","Notime Widget at a Product Page"
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>notime_same_day_delivery</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>It is an extension that allows merchants to add same-day shipping by notime to the store. notime is supported in all major Swiss cities.</summary>
10
+ <description>This extension allows a merchant to add a same-day shipping option to their store. &#xD;
11
+ notime same-day shipping is provided by notime AG based in Z&#xFC;rich Switzerland and currently supports shipping to all major Swiss cities.&#xD;
12
+ With this new shipping method customers can view and pick from the available delivery time-slots. &#xD;
13
+ The popup can be placed either in the preview section, next to the product, and/or in the checkout page.&#xD;
14
+ The merchant can configure this shipping method in the "Shipping methods" area and "Product Information" area.</description>
15
+ <notes>Initial release</notes>
16
+ <authors><author><name>notime</name><user>notime</user><email>dmitry.zhersh@notime.eu</email></author></authors>
17
+ <date>2016-04-04</date>
18
+ <time>20:17:25</time>
19
+ <contents><target name="magelocal"><dir name="Notime"><dir name="Shipping"><dir name="Block"><dir name="Checkout"><dir name="Onepage"><dir name="Shipping"><file name="Notime.php" hash="3cf3bb2779a9a35cca776de23e2a3665"/></dir></dir></dir><dir name="Product"><file name="Widget.php" hash="e72292e3c7e8aed1909f4584fd1ea037"/></dir><file name="ShippingMethod.php" hash="b7cd80898a2a06821e6104a35b90b61e"/></dir><dir name="Helper"><file name="Data.php" hash="42686d5dffb62fdfc799d4a052daa968"/></dir><dir name="Model"><dir name="Carrier"><file name="Notime.php" hash="99b8d655f7cb95afe2bcbcacc88b117f"/></dir><file name="Observer.php" hash="9cc155e599af50eeeb515593fbbfbcff"/></dir><dir name="etc"><file name="config.xml" hash="955c73f3617e118da4df2c1dc8a1122f"/><file name="system.xml" hash="bd8747f9d8f1588fa19f779dd3cc0c90"/></dir><dir name="sql"><dir name="notimeshipping_setup"><file name="mysql4-install-1.0.0.php" hash="7647e9d736ac1199cb7732358b539be6"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="e15b6ad29a30175b3afca7280d1162ce"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="notime.xml" hash="3c16298a844be38a8a6d2a7ee615d6b9"/></dir><dir name="template"><dir name="notime"><dir name="checkout"><dir name="onepage"><dir name="shipping_method"><file name="notime.phtml" hash="c5575bafdd7af6e904f7c3e9f71d31e7"/></dir></dir></dir><dir name="product"><file name="widget.phtml" hash="23da2d2a03f095b8fe467c9c5c6b3c96"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Notime_Shipping.xml" hash="f5de879b88f342a03e16c4d655867b21"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="Notime_Shipping.csv" hash="14d216f093725c72aca60b1a165a084a"/></dir><dir name="en_US"><file name="Notime_Shipping.csv" hash="ef8c967d4c44a6afe1f01b9cde9ff761"/></dir><dir name="fr_FR"><file name="Notime_Shipping.csv" hash="ef8c967d4c44a6afe1f01b9cde9ff761"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="notime.css" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="js"><file name="notime.js" hash="7678c5eebe3ccd258d1a1fcac13bdaa5"/></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.4.0</min><max>7.0.4</max></php></required></dependencies>
22
+ </package>
skin/frontend/base/default/css/notime.css ADDED
File without changes
skin/frontend/base/default/js/notime.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var NotimeShippingForm = Class.create();
2
+ NotimeShippingForm.prototype = {
3
+ initialize: function (rate_id,formElementId) {
4
+ this.rate_id = rate_id;
5
+ this.formElement = $(formElementId);
6
+ this._addEventListeners();
7
+ this._addValidation();
8
+ this._toggleForm();
9
+ },
10
+ _addEventListeners: function () {
11
+ var self = this;
12
+ $$('input[name="shipping_method"]').each(
13
+ function(sel){
14
+
15
+ if (window.addEventListener) {
16
+ // Check for addEventListener first, since IE9/10 have both,
17
+ // but you should use the standard over the deprecated IE-specific one
18
+ sel.addEventListener('click', function() {
19
+ self._toggleForm();
20
+ });
21
+ } else if (window.attachEvent) {
22
+ sel.attachEvent('onclick', function() {
23
+ self._toggleForm();
24
+ });
25
+ } else {
26
+ Event.observe(sel, 'click', function() {
27
+ self._toggleForm();
28
+ });
29
+ }
30
+ }
31
+ );
32
+ },
33
+ _toggleForm: function(){
34
+ var selectedShippingMethodCode = $$('input[name="shipping_method"]:checked');
35
+
36
+ //alert(selectedShippingMethodCode.pluck('value'));
37
+
38
+ if(this.rate_id == selectedShippingMethodCode.pluck('value')){
39
+ this.formElement.show();
40
+ }else{
41
+ this.formElement.hide();
42
+ }
43
+ },
44
+ _addValidation: function(){
45
+ var self = this;
46
+ Validation.add('required-notime-shipment',Translator.translate('Click here and choose your delivery time-slot'),function(value){
47
+ if(value != '' && value != '-')
48
+ {
49
+ return true;
50
+ }
51
+ return false;
52
+ });
53
+ },
54
+ _validate: function(){
55
+
56
+ }
57
+ };