Version Notes
Fixed non stock managed logic, disabled for downloadable and virtual product types.
Download this release
Release Info
Developer | Hussey Coding |
Extension | HusseyCoding_Backorder |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- app/code/community/HusseyCoding/Backorder/Block/Estimate.php +155 -21
- app/code/community/HusseyCoding/Backorder/Helper/Data.php +7 -0
- app/code/community/HusseyCoding/Backorder/etc/config.xml +1 -1
- app/design/frontend/base/default/template/backorder/estimate.phtml +4 -0
- package.xml +5 -5
- skin/frontend/base/default/js/backorder.js +39 -25
app/code/community/HusseyCoding/Backorder/Block/Estimate.php
CHANGED
@@ -7,15 +7,18 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
7 |
private $_childids = array();
|
8 |
private $_bundleids = array();
|
9 |
private $_nolead;
|
|
|
|
|
|
|
10 |
|
11 |
public function isEnabled()
|
12 |
{
|
13 |
-
return
|
14 |
}
|
15 |
|
16 |
public function acceptEnabled()
|
17 |
{
|
18 |
-
if (
|
19 |
return 'true';
|
20 |
endif;
|
21 |
|
@@ -60,29 +63,28 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
60 |
|
61 |
private function _getGroupedEstimates($product)
|
62 |
{
|
63 |
-
$
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
66 |
}
|
67 |
|
68 |
private function _getConfigurableEstimates($product)
|
69 |
{
|
70 |
-
$
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
73 |
}
|
74 |
|
75 |
private function _getBundleEstimates($product)
|
76 |
{
|
77 |
$estimates = array();
|
78 |
-
|
79 |
-
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
|
80 |
-
$product->getTypeInstance(true)->getOptionsIds($product),
|
81 |
-
$product
|
82 |
-
);
|
83 |
-
|
84 |
-
$options = $optionCollection->appendSelections($selectionCollection);
|
85 |
-
foreach ($options as $option):
|
86 |
if ($selections = $option->getSelections()):
|
87 |
$optionid = $option->getId();
|
88 |
foreach ($selections as $selection):
|
@@ -103,6 +105,17 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
103 |
return false;
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
private function _getEstimatesByIds($ids)
|
107 |
{
|
108 |
foreach ($ids as $group):
|
@@ -124,12 +137,13 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
124 |
|
125 |
private function _getEstimateDate($product)
|
126 |
{
|
127 |
-
return
|
128 |
}
|
129 |
|
130 |
public function getCartEstimates()
|
131 |
{
|
132 |
$return = array();
|
|
|
133 |
if ($cart = Mage::getModel('checkout/cart')->getQuote()):
|
134 |
$empty = true;
|
135 |
foreach ($cart->getAllItems() as $item):
|
@@ -137,13 +151,24 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
137 |
$this->_childids[$parent][] = $item;
|
138 |
else:
|
139 |
$this->_ids[] = $item->getId();
|
|
|
140 |
if ($item->getProductType() == 'configurable'):
|
141 |
if ($option = $item->getOptionByCode('simple_product')):
|
142 |
if ($estimate = $this->_getEstimateDate($option->getProduct())):
|
143 |
$return[] = $estimate;
|
144 |
$empty = false;
|
|
|
145 |
else:
|
146 |
$return[] = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
endif;
|
148 |
endif;
|
149 |
elseif ($item->getProductType() == 'bundle'):
|
@@ -156,25 +181,47 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
156 |
if ($estimate = $this->_getEstimateDate($item->getProduct())):
|
157 |
$return[] = $estimate;
|
158 |
$empty = false;
|
|
|
159 |
else:
|
160 |
$return[] = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
endif;
|
162 |
endif;
|
163 |
endif;
|
164 |
endforeach;
|
165 |
|
166 |
foreach ($this->_bundleids as $bundleid):
|
|
|
167 |
$estimates = array();
|
168 |
if (isset($this->_childids[$bundleid])):
|
169 |
foreach ($this->_childids[$bundleid] as $childitem):
|
170 |
if ($estimate = $this->_getEstimateDate($childitem->getProduct())):
|
171 |
$epoch = strtotime($estimate);
|
172 |
$estimates[$epoch] = $estimate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
endif;
|
174 |
endforeach;
|
175 |
if (!empty($estimates)):
|
176 |
ksort($estimates);
|
177 |
$return[$bundleid] = end($estimates);
|
|
|
|
|
|
|
178 |
endif;
|
179 |
endif;
|
180 |
endforeach;
|
@@ -196,6 +243,24 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
196 |
return '[]';
|
197 |
}
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
public function getHasAccepted()
|
200 |
{
|
201 |
if (Mage::getSingleton('customer/session')->getBackorderAccepted()):
|
@@ -238,7 +303,7 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
238 |
|
239 |
public function getCutOff()
|
240 |
{
|
241 |
-
$cutoff =
|
242 |
$return = strtotime($cutoff);
|
243 |
$now = Mage::getModel('core/date')->timestamp();
|
244 |
if ($now >= $return):
|
@@ -250,13 +315,13 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
250 |
|
251 |
public function getOrderBefore()
|
252 |
{
|
253 |
-
return
|
254 |
}
|
255 |
|
256 |
public function getNoLeadTimestamp()
|
257 |
{
|
258 |
if (!isset($this->_nolead)):
|
259 |
-
$this->_nolead =
|
260 |
endif;
|
261 |
|
262 |
return $this->_nolead;
|
@@ -268,11 +333,80 @@ class HusseyCoding_Backorder_Block_Estimate extends Mage_Core_Block_Template
|
|
268 |
$this->getNoLeadTimestamp();
|
269 |
endif;
|
270 |
|
271 |
-
$date =
|
272 |
if (!empty($date)):
|
273 |
return $date;
|
274 |
endif;
|
275 |
|
276 |
return false;
|
277 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
}
|
7 |
private $_childids = array();
|
8 |
private $_bundleids = array();
|
9 |
private $_nolead;
|
10 |
+
private $_helper;
|
11 |
+
private $_showorderbefore = array();
|
12 |
+
private $_cartproducttypes = array();
|
13 |
|
14 |
public function isEnabled()
|
15 |
{
|
16 |
+
return $this->_getHelper()->isEnabled();
|
17 |
}
|
18 |
|
19 |
public function acceptEnabled()
|
20 |
{
|
21 |
+
if ($this->_getHelper()->acceptEnabled()):
|
22 |
return 'true';
|
23 |
endif;
|
24 |
|
63 |
|
64 |
private function _getGroupedEstimates($product)
|
65 |
{
|
66 |
+
return $this->_getEstimatesByIds($this->_getGroupedIds($product));
|
67 |
+
}
|
68 |
+
|
69 |
+
private function _getGroupedIds($product)
|
70 |
+
{
|
71 |
+
return Mage::getModel('catalog/product_type_grouped')->getChildrenIds($product->getId());
|
72 |
}
|
73 |
|
74 |
private function _getConfigurableEstimates($product)
|
75 |
{
|
76 |
+
return $this->_getEstimatesByIds($this->_getConfigurableIds($product));
|
77 |
+
}
|
78 |
+
|
79 |
+
private function _getConfigurableIds($product)
|
80 |
+
{
|
81 |
+
return Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
|
82 |
}
|
83 |
|
84 |
private function _getBundleEstimates($product)
|
85 |
{
|
86 |
$estimates = array();
|
87 |
+
foreach ($this->_getBundleOptions($product) as $option):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
if ($selections = $option->getSelections()):
|
89 |
$optionid = $option->getId();
|
90 |
foreach ($selections as $selection):
|
105 |
return false;
|
106 |
}
|
107 |
|
108 |
+
private function _getBundleOptions($product)
|
109 |
+
{
|
110 |
+
$optioncollection = $product->getTypeInstance(true)->getOptionsCollection($product);
|
111 |
+
$selectioncollection = $product->getTypeInstance(true)->getSelectionsCollection(
|
112 |
+
$product->getTypeInstance(true)->getOptionsIds($product),
|
113 |
+
$product
|
114 |
+
);
|
115 |
+
|
116 |
+
return $optioncollection->appendSelections($selectioncollection);
|
117 |
+
}
|
118 |
+
|
119 |
private function _getEstimatesByIds($ids)
|
120 |
{
|
121 |
foreach ($ids as $group):
|
137 |
|
138 |
private function _getEstimateDate($product)
|
139 |
{
|
140 |
+
return $this->_getHelper()->getEstimatedDispatch($product);
|
141 |
}
|
142 |
|
143 |
public function getCartEstimates()
|
144 |
{
|
145 |
$return = array();
|
146 |
+
$notmanaged = Mage::getStoreConfig('backorder/general/notmanaged');
|
147 |
if ($cart = Mage::getModel('checkout/cart')->getQuote()):
|
148 |
$empty = true;
|
149 |
foreach ($cart->getAllItems() as $item):
|
151 |
$this->_childids[$parent][] = $item;
|
152 |
else:
|
153 |
$this->_ids[] = $item->getId();
|
154 |
+
$this->_cartproducttypes[] = $item->getProductType();
|
155 |
if ($item->getProductType() == 'configurable'):
|
156 |
if ($option = $item->getOptionByCode('simple_product')):
|
157 |
if ($estimate = $this->_getEstimateDate($option->getProduct())):
|
158 |
$return[] = $estimate;
|
159 |
$empty = false;
|
160 |
+
$this->_showorderbefore[] = false;
|
161 |
else:
|
162 |
$return[] = '';
|
163 |
+
if (!$this->_getHelper()->areManagingStock($option->getProduct())):
|
164 |
+
if (!$notmanaged):
|
165 |
+
$this->_showorderbefore[] = false;
|
166 |
+
else:
|
167 |
+
$this->_showorderbefore[] = true;
|
168 |
+
endif;
|
169 |
+
else:
|
170 |
+
$this->_showorderbefore[] = true;
|
171 |
+
endif;
|
172 |
endif;
|
173 |
endif;
|
174 |
elseif ($item->getProductType() == 'bundle'):
|
181 |
if ($estimate = $this->_getEstimateDate($item->getProduct())):
|
182 |
$return[] = $estimate;
|
183 |
$empty = false;
|
184 |
+
$this->_showorderbefore[] = false;
|
185 |
else:
|
186 |
$return[] = '';
|
187 |
+
if (!$this->_getHelper()->areManagingStock($item->getProduct())):
|
188 |
+
if (!$notmanaged):
|
189 |
+
$this->_showorderbefore[] = false;
|
190 |
+
else:
|
191 |
+
$this->_showorderbefore[] = true;
|
192 |
+
endif;
|
193 |
+
else:
|
194 |
+
$this->_showorderbefore[] = true;
|
195 |
+
endif;
|
196 |
endif;
|
197 |
endif;
|
198 |
endif;
|
199 |
endforeach;
|
200 |
|
201 |
foreach ($this->_bundleids as $bundleid):
|
202 |
+
$showbundlebefore = false;
|
203 |
$estimates = array();
|
204 |
if (isset($this->_childids[$bundleid])):
|
205 |
foreach ($this->_childids[$bundleid] as $childitem):
|
206 |
if ($estimate = $this->_getEstimateDate($childitem->getProduct())):
|
207 |
$epoch = strtotime($estimate);
|
208 |
$estimates[$epoch] = $estimate;
|
209 |
+
elseif (!$showbundlebefore):
|
210 |
+
if (!$this->_getHelper()->areManagingStock($childitem->getProduct())):
|
211 |
+
if ($notmanaged):
|
212 |
+
$showbundlebefore = true;
|
213 |
+
endif;
|
214 |
+
else:
|
215 |
+
$showbundlebefore = true;
|
216 |
+
endif;
|
217 |
endif;
|
218 |
endforeach;
|
219 |
if (!empty($estimates)):
|
220 |
ksort($estimates);
|
221 |
$return[$bundleid] = end($estimates);
|
222 |
+
$this->_showorderbefore[] = false;
|
223 |
+
else:
|
224 |
+
$this->_showorderbefore[] = $showbundlebefore;
|
225 |
endif;
|
226 |
endif;
|
227 |
endforeach;
|
243 |
return '[]';
|
244 |
}
|
245 |
|
246 |
+
public function getCartShowOrderBefore()
|
247 |
+
{
|
248 |
+
if (!empty($this->_showorderbefore)):
|
249 |
+
return '["' . implode('","', $this->_showorderbefore) . '"]';
|
250 |
+
endif;
|
251 |
+
|
252 |
+
return '[]';
|
253 |
+
}
|
254 |
+
|
255 |
+
public function getCartProductTypes()
|
256 |
+
{
|
257 |
+
if (!empty($this->_cartproducttypes)):
|
258 |
+
return '["' . implode('","', $this->_cartproducttypes) . '"]';
|
259 |
+
endif;
|
260 |
+
|
261 |
+
return '[]';
|
262 |
+
}
|
263 |
+
|
264 |
public function getHasAccepted()
|
265 |
{
|
266 |
if (Mage::getSingleton('customer/session')->getBackorderAccepted()):
|
303 |
|
304 |
public function getCutOff()
|
305 |
{
|
306 |
+
$cutoff = $this->_getHelper()->getCutOff();
|
307 |
$return = strtotime($cutoff);
|
308 |
$now = Mage::getModel('core/date')->timestamp();
|
309 |
if ($now >= $return):
|
315 |
|
316 |
public function getOrderBefore()
|
317 |
{
|
318 |
+
return $this->_getHelper()->getOrderBefore();
|
319 |
}
|
320 |
|
321 |
public function getNoLeadTimestamp()
|
322 |
{
|
323 |
if (!isset($this->_nolead)):
|
324 |
+
$this->_nolead = $this->_getHelper()->getNoLeadTimestamp();
|
325 |
endif;
|
326 |
|
327 |
return $this->_nolead;
|
333 |
$this->getNoLeadTimestamp();
|
334 |
endif;
|
335 |
|
336 |
+
$date = $this->_getHelper()->createDateString($this->_nolead);
|
337 |
if (!empty($date)):
|
338 |
return $date;
|
339 |
endif;
|
340 |
|
341 |
return false;
|
342 |
}
|
343 |
+
|
344 |
+
public function getProductShowOrderBefore()
|
345 |
+
{
|
346 |
+
$notmanaged = Mage::getStoreConfig('backorder/general/notmanaged');
|
347 |
+
if ($this->_getProductType() == 'grouped'):
|
348 |
+
$ids = $this->_getGroupedIds($this->_getProduct());
|
349 |
+
$orderbefore = $this->_getOrderBeforeByIds($ids, $notmanaged);
|
350 |
+
elseif ($this->_getProductType() == 'configurable'):
|
351 |
+
$ids = $this->_getConfigurableIds($this->_getProduct());
|
352 |
+
$orderbefore = $this->_getOrderBeforeByIds($ids, $notmanaged);
|
353 |
+
elseif ($this->_getProductType() == 'bundle'):
|
354 |
+
$orderbefore = array();
|
355 |
+
$options = $this->_getBundleOptions($this->_getProduct());
|
356 |
+
foreach ($options as $option):
|
357 |
+
if ($selections = $option->getSelections()):
|
358 |
+
$optionid = $option->getId();
|
359 |
+
foreach ($selections as $selection):
|
360 |
+
$selectionid = $selection->getSelectionId();
|
361 |
+
$product = Mage::getModel('catalog/product')->load($selection->getId());
|
362 |
+
$orderbefore[$optionid][$selectionid] = true;
|
363 |
+
if (!$this->_getHelper()->areManagingStock($product)):
|
364 |
+
if (!$notmanaged):
|
365 |
+
$orderbefore[$optionid][$selectionid] = false;
|
366 |
+
endif;
|
367 |
+
endif;
|
368 |
+
endforeach;
|
369 |
+
endif;
|
370 |
+
endforeach;
|
371 |
+
endif;
|
372 |
+
|
373 |
+
if (!empty($orderbefore)):
|
374 |
+
return Mage::helper('core')->jsonEncode($orderbefore);
|
375 |
+
endif;
|
376 |
+
|
377 |
+
if (!$this->_getHelper()->areManagingStock($this->_getProduct())):
|
378 |
+
if (!$notmanaged):
|
379 |
+
return 'false';
|
380 |
+
endif;
|
381 |
+
endif;
|
382 |
+
|
383 |
+
return 'true';
|
384 |
+
}
|
385 |
+
|
386 |
+
private function _getOrderBeforeByIds($ids, $notmanaged)
|
387 |
+
{
|
388 |
+
$orderbefore = array();
|
389 |
+
foreach ($ids as $group):
|
390 |
+
foreach ($group as $id):
|
391 |
+
$product = Mage::getModel('catalog/product')->load($id);
|
392 |
+
$orderbefore[$product->getId()] = true;
|
393 |
+
if (!$this->_getHelper()->areManagingStock($product)):
|
394 |
+
if (!$notmanaged):
|
395 |
+
$orderbefore[$product->getId()] = false;
|
396 |
+
endif;
|
397 |
+
endif;
|
398 |
+
endforeach;
|
399 |
+
endforeach;
|
400 |
+
|
401 |
+
return $orderbefore;
|
402 |
+
}
|
403 |
+
|
404 |
+
private function _getHelper()
|
405 |
+
{
|
406 |
+
if (!isset($this->_helper)):
|
407 |
+
$this->_helper = Mage::helper('backorder');
|
408 |
+
endif;
|
409 |
+
|
410 |
+
return $this->_helper;
|
411 |
+
}
|
412 |
}
|
app/code/community/HusseyCoding/Backorder/Helper/Data.php
CHANGED
@@ -65,6 +65,13 @@ class HusseyCoding_Backorder_Helper_Data extends Mage_Core_Helper_Abstract
|
|
65 |
return false;
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
private function _areManagingStock($stock)
|
69 |
{
|
70 |
if ($stock->getUseConfigManageStock()):
|
65 |
return false;
|
66 |
}
|
67 |
|
68 |
+
public function areManagingStock($product)
|
69 |
+
{
|
70 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
71 |
+
|
72 |
+
return $this->_areManagingStock($stock);
|
73 |
+
}
|
74 |
+
|
75 |
private function _areManagingStock($stock)
|
76 |
{
|
77 |
if ($stock->getUseConfigManageStock()):
|
app/code/community/HusseyCoding/Backorder/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<HusseyCoding_Backorder>
|
5 |
-
<version>1.0.
|
6 |
</HusseyCoding_Backorder>
|
7 |
</modules>
|
8 |
<global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<HusseyCoding_Backorder>
|
5 |
+
<version>1.0.3</version>
|
6 |
</HusseyCoding_Backorder>
|
7 |
</modules>
|
8 |
<global>
|
app/design/frontend/base/default/template/backorder/estimate.phtml
CHANGED
@@ -15,6 +15,7 @@
|
|
15 |
thisbackorder.noleaddatestring = "<?php echo $this->getNoLeadDateString(); ?>";
|
16 |
thisbackorder.cutoff = "<?php echo $this->getCutOff(); ?>";
|
17 |
thisbackorder.now = "<?php echo Mage::getModel('core/date')->timestamp(); ?>";
|
|
|
18 |
<?php if ($isproduct == 'true'): ?>
|
19 |
<?php if ($estimate = $this->getProductEstimate()): ?>
|
20 |
thisbackorder.producttype = "<?php echo $this->getProductType(); ?>";
|
@@ -24,6 +25,7 @@
|
|
24 |
thisbackorder.productestimate = <?php echo Mage::helper('core')->jsonEncode($estimate); ?>;
|
25 |
<?php endif; ?>
|
26 |
<?php endif; ?>
|
|
|
27 |
<?php elseif ($iscart == 'true'): ?>
|
28 |
thisbackorder.cartestimates = <?php echo $this->getCartEstimates(); ?>;
|
29 |
thisbackorder.itemids = <?php echo $this->getItemIds(); ?>;
|
@@ -32,6 +34,8 @@
|
|
32 |
thisbackorder.hasaccepted = <?php echo $this->getHasAccepted(); ?>;
|
33 |
thisbackorder.acceptedids = <?php echo $this->getAcceptedIds(); ?>;
|
34 |
thisbackorder.acceptenabled = <?php echo $this->acceptEnabled(); ?>;
|
|
|
|
|
35 |
<?php endif; ?>
|
36 |
|
37 |
if (typeof(spConfig) == "object") {
|
15 |
thisbackorder.noleaddatestring = "<?php echo $this->getNoLeadDateString(); ?>";
|
16 |
thisbackorder.cutoff = "<?php echo $this->getCutOff(); ?>";
|
17 |
thisbackorder.now = "<?php echo Mage::getModel('core/date')->timestamp(); ?>";
|
18 |
+
thisbackorder.orderbeforestring = false;
|
19 |
<?php if ($isproduct == 'true'): ?>
|
20 |
<?php if ($estimate = $this->getProductEstimate()): ?>
|
21 |
thisbackorder.producttype = "<?php echo $this->getProductType(); ?>";
|
25 |
thisbackorder.productestimate = <?php echo Mage::helper('core')->jsonEncode($estimate); ?>;
|
26 |
<?php endif; ?>
|
27 |
<?php endif; ?>
|
28 |
+
thisbackorder.showorderbefore = <?php echo $this->getProductShowOrderBefore(); ?>;
|
29 |
<?php elseif ($iscart == 'true'): ?>
|
30 |
thisbackorder.cartestimates = <?php echo $this->getCartEstimates(); ?>;
|
31 |
thisbackorder.itemids = <?php echo $this->getItemIds(); ?>;
|
34 |
thisbackorder.hasaccepted = <?php echo $this->getHasAccepted(); ?>;
|
35 |
thisbackorder.acceptedids = <?php echo $this->getAcceptedIds(); ?>;
|
36 |
thisbackorder.acceptenabled = <?php echo $this->acceptEnabled(); ?>;
|
37 |
+
thisbackorder.showorderbefore = <?php echo $this->getCartShowOrderBefore(); ?>;
|
38 |
+
thisbackorder.cartproducttypes = <?php echo $this->getCartProductTypes(); ?>;
|
39 |
<?php endif; ?>
|
40 |
|
41 |
if (typeof(spConfig) == "object") {
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>HusseyCoding_Backorder</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Adds dispatch estimate notifications to product pages and the cart.</summary>
|
10 |
<description>Adds a dispatch lead time attribute to each product which should be entered as a human readable text string describing the lead time for the product, i.e. 1 week and 3 days. For parent products (grouped, configurable and bundle) the lead time should be entered for the child simple products rather than the parent product - any lead time on a parent product will be ignored.</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>Hussey Coding</name><user>husseycoding</user><email>info@husseycoding.co.uk</email></author></authors>
|
13 |
-
<date>2015-03-
|
14 |
-
<time>13:
|
15 |
-
<contents><target name="magecommunity"><dir name="HusseyCoding"><dir name="Backorder"><dir name="Block"><file name="Estimate.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>HusseyCoding_Backorder</name>
|
4 |
+
<version>1.0.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Adds dispatch estimate notifications to product pages and the cart.</summary>
|
10 |
<description>Adds a dispatch lead time attribute to each product which should be entered as a human readable text string describing the lead time for the product, i.e. 1 week and 3 days. For parent products (grouped, configurable and bundle) the lead time should be entered for the child simple products rather than the parent product - any lead time on a parent product will be ignored.</description>
|
11 |
+
<notes>Fixed non stock managed logic, disabled for downloadable and virtual product types.</notes>
|
12 |
<authors><author><name>Hussey Coding</name><user>husseycoding</user><email>info@husseycoding.co.uk</email></author></authors>
|
13 |
+
<date>2015-03-10</date>
|
14 |
+
<time>13:02:44</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="HusseyCoding"><dir name="Backorder"><dir name="Block"><file name="Estimate.php" hash="d72aca15f662940fe7c1a1db0faf1c90"/></dir><dir name="Helper"><file name="Data.php" hash="5e5b9078f5f8a9aa34e5b8d0c7d101d7"/></dir><dir name="Model"><file name="Observer.php" hash="971fa0f7da6d23849fdf856aa21f1499"/><dir name="Order"><file name="SalesItem.php" hash="04de33199c3fac846eefaa9276114183"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="398362af6bd568d1cb5cb616c73d461a"/></dir><dir name="etc"><file name="adminhtml.xml" hash="81e616c4c65ddbd6e92728f8dc8e3fe5"/><file name="config.xml" hash="705009f4008acc391b9405e5e833c187"/><file name="system.xml" hash="c3a6eb4358c2718fa834b43aa4f3e9ab"/></dir><dir name="sql"><dir name="backorder_setup"><file name="install-1.0.0.php" hash="54c2cb1a423fad263b465df516da1ccb"/><file name="upgrade-1.0.0-1.0.1.php" hash="87b1f3a15a9e062691e33be10e39d330"/></dir></dir></dir><dir name="Common"><dir name="etc"><file name="system.xml" hash="6c9ba9f227b9adfc9abf97f17b46fdbf"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="HusseyCoding_Backorder.xml" hash="97f4e05e024b0baa9f51ed3be9929168"/><file name="HusseyCoding_Common.xml" hash="31e82d3d9b3179c2fa9e002f9669da47"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="backorder.xml" hash="04d971a9830ffb2240b348783fec82bc"/></dir><dir name="template"><dir name="backorder"><file name="estimate.phtml" hash="0dcd530661f569dfb9db9f818397b787"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><file name="backorder.js" hash="d1515bb6ec6807a56b2e4adb3d28d5a2"/></dir><dir name="css"><file name="backorder.css" hash="f9601103bb20f597f9b58ec31d53ca6a"/></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
skin/frontend/base/default/js/backorder.js
CHANGED
@@ -1,19 +1,20 @@
|
|
1 |
var backorder = Class.create({
|
2 |
afterInit: function() {
|
3 |
-
this.orderbeforestring = false;
|
4 |
if (this.isproduct) {
|
5 |
-
if (this.
|
6 |
-
if (this.
|
7 |
-
this.
|
8 |
-
|
9 |
-
this.
|
10 |
-
|
11 |
-
this.
|
12 |
-
|
13 |
-
if (this.productestimate) {
|
14 |
-
$$(".availability")[0].insert({after: "<p class=\"dispatch-estimate\">" + this.estimatetext + ": <span>" + this.productestimate + "</span></p>"});
|
15 |
} else {
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
}
|
18 |
}
|
19 |
}
|
@@ -21,16 +22,20 @@ var backorder = Class.create({
|
|
21 |
$$("#shopping-cart-table .product-name").each(function(e) {
|
22 |
var estimate = this.cartestimates.shift();
|
23 |
var itemid = this.itemids.shift();
|
24 |
-
var
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
}
|
36 |
}.bind(this));
|
@@ -73,7 +78,7 @@ var backorder = Class.create({
|
|
73 |
var productid = e.name.match(/[0-9]+/);
|
74 |
if (this.productestimate[productid]) {
|
75 |
e.up("tr").down().insert({bottom: "<p class=\"dispatch-estimate\">" + this.estimatetext + ": <span>" + this.productestimate[productid] + "</span></p>"});
|
76 |
-
} else if (this.orderbefore) {
|
77 |
e.up("tr").down().insert({bottom: "<p class=\"dispatch-nolead\">" + this.getOrderBeforeString() + "</p>"});
|
78 |
}
|
79 |
}.bind(this));
|
@@ -95,7 +100,7 @@ var backorder = Class.create({
|
|
95 |
if (productid) {
|
96 |
if (this.productestimate[productid]) {
|
97 |
$$(".availability")[0].insert({after: "<p class=\"dispatch-estimate\">" + this.estimatetext + ": <span>" + this.productestimate[productid] + "</span></p>"});
|
98 |
-
} else if (this.orderbefore) {
|
99 |
$$(".availability")[0].insert({after: "<p class=\"dispatch-nolead\">" + this.getOrderBeforeString() + "</p>"});
|
100 |
}
|
101 |
}
|
@@ -126,6 +131,7 @@ var backorder = Class.create({
|
|
126 |
this.removeEstimate();
|
127 |
var estimates = [];
|
128 |
var selected = $("product_addtocart_form").serialize(true);
|
|
|
129 |
$H(selected).each(function(e) {
|
130 |
if (e.key.indexOf("bundle_option") == 0 && e.value != "") {
|
131 |
var bundleid = e.key.match(/[0-9]+/);
|
@@ -139,6 +145,8 @@ var backorder = Class.create({
|
|
139 |
var estimate = this.getBundleEstimate(bundleid, value);
|
140 |
if (estimate) {
|
141 |
estimates.push(estimate);
|
|
|
|
|
142 |
}
|
143 |
}.bind(this));
|
144 |
}
|
@@ -146,7 +154,7 @@ var backorder = Class.create({
|
|
146 |
var estimate = this.getLongestBundleEstimate(estimates);
|
147 |
if (estimate) {
|
148 |
$$(".availability")[0].insert({after: "<p class=\"dispatch-estimate\">" + this.estimatetext + ": <span>" + estimate + "</span></p>"});
|
149 |
-
} else if (this.orderbefore) {
|
150 |
$$(".availability")[0].insert({after: "<p class=\"dispatch-nolead\">" + this.getOrderBeforeString() + "</p>"});
|
151 |
}
|
152 |
},
|
@@ -215,5 +223,11 @@ var backorder = Class.create({
|
|
215 |
new Ajax.Request(this.acceptedurl, {
|
216 |
parameters: {accepted: accepted, itemids: itemids.join()}
|
217 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
});
|
1 |
var backorder = Class.create({
|
2 |
afterInit: function() {
|
|
|
3 |
if (this.isproduct) {
|
4 |
+
if (this.isValidProductType()) {
|
5 |
+
if (this.productestimate || this.orderbefore) {
|
6 |
+
if (this.producttype == "grouped") {
|
7 |
+
this.initGrouped();
|
8 |
+
} else if (this.producttype == "configurable") {
|
9 |
+
this.initConfigurable();
|
10 |
+
} else if (this.producttype == "bundle") {
|
11 |
+
this.initBundle();
|
|
|
|
|
12 |
} else {
|
13 |
+
if (this.productestimate) {
|
14 |
+
$$(".availability")[0].insert({after: "<p class=\"dispatch-estimate\">" + this.estimatetext + ": <span>" + this.productestimate + "</span></p>"});
|
15 |
+
} else if (this.showorderbefore) {
|
16 |
+
$$(".availability")[0].insert({after: "<div class=\"dispatch-nolead\">" + this.getOrderBeforeString() + "</div>"});
|
17 |
+
}
|
18 |
}
|
19 |
}
|
20 |
}
|
22 |
$$("#shopping-cart-table .product-name").each(function(e) {
|
23 |
var estimate = this.cartestimates.shift();
|
24 |
var itemid = this.itemids.shift();
|
25 |
+
var showorderbefore = this.showorderbefore.shift();
|
26 |
+
var producttype = this.cartproducttypes.shift();
|
27 |
+
if (this.isValidProductType(producttype)) {
|
28 |
+
var checked = "";
|
29 |
+
if (this.hasaccepted || this.acceptedids.indexOf(itemid) >= 0) {
|
30 |
+
checked = "checked ";
|
31 |
+
}
|
32 |
+
if (!estimate && this.orderbefore && showorderbefore) {
|
33 |
+
e.insert({after: "<div class=\"dispatch-nolead\">" + this.getOrderBeforeString() + "</div>"});
|
34 |
+
} else if (estimate) {
|
35 |
+
e.insert({after: "<div class=\"dispatch-estimate\">" + this.estimatetext + ": <span>" + estimate + "</span></div>"});
|
36 |
+
if (this.acceptenabled) {
|
37 |
+
e.next().insert({after: "<div class=\"backorder-accept\"><input " + checked + "type=\"checkbox\" class=\"checkbox\" name=\"backorder[" + itemid + "]\" /><span>" + this.delayedtext + "</span></div>"});
|
38 |
+
}
|
39 |
}
|
40 |
}
|
41 |
}.bind(this));
|
78 |
var productid = e.name.match(/[0-9]+/);
|
79 |
if (this.productestimate[productid]) {
|
80 |
e.up("tr").down().insert({bottom: "<p class=\"dispatch-estimate\">" + this.estimatetext + ": <span>" + this.productestimate[productid] + "</span></p>"});
|
81 |
+
} else if (this.orderbefore && this.showorderbefore[productid]) {
|
82 |
e.up("tr").down().insert({bottom: "<p class=\"dispatch-nolead\">" + this.getOrderBeforeString() + "</p>"});
|
83 |
}
|
84 |
}.bind(this));
|
100 |
if (productid) {
|
101 |
if (this.productestimate[productid]) {
|
102 |
$$(".availability")[0].insert({after: "<p class=\"dispatch-estimate\">" + this.estimatetext + ": <span>" + this.productestimate[productid] + "</span></p>"});
|
103 |
+
} else if (this.orderbefore && this.showorderbefore[productid]) {
|
104 |
$$(".availability")[0].insert({after: "<p class=\"dispatch-nolead\">" + this.getOrderBeforeString() + "</p>"});
|
105 |
}
|
106 |
}
|
131 |
this.removeEstimate();
|
132 |
var estimates = [];
|
133 |
var selected = $("product_addtocart_form").serialize(true);
|
134 |
+
var showbundleorderbefore = false
|
135 |
$H(selected).each(function(e) {
|
136 |
if (e.key.indexOf("bundle_option") == 0 && e.value != "") {
|
137 |
var bundleid = e.key.match(/[0-9]+/);
|
145 |
var estimate = this.getBundleEstimate(bundleid, value);
|
146 |
if (estimate) {
|
147 |
estimates.push(estimate);
|
148 |
+
} else if (this.showorderbefore[bundleid][value]) {
|
149 |
+
showbundleorderbefore = true;
|
150 |
}
|
151 |
}.bind(this));
|
152 |
}
|
154 |
var estimate = this.getLongestBundleEstimate(estimates);
|
155 |
if (estimate) {
|
156 |
$$(".availability")[0].insert({after: "<p class=\"dispatch-estimate\">" + this.estimatetext + ": <span>" + estimate + "</span></p>"});
|
157 |
+
} else if (this.orderbefore && showbundleorderbefore) {
|
158 |
$$(".availability")[0].insert({after: "<p class=\"dispatch-nolead\">" + this.getOrderBeforeString() + "</p>"});
|
159 |
}
|
160 |
},
|
223 |
new Ajax.Request(this.acceptedurl, {
|
224 |
parameters: {accepted: accepted, itemids: itemids.join()}
|
225 |
});
|
226 |
+
},
|
227 |
+
isValidProductType: function(type) {
|
228 |
+
if (!type) {
|
229 |
+
var type = this.producttype;
|
230 |
+
}
|
231 |
+
return type == "grouped" || type == "configurable" || type == "bundle" || type == "simple";
|
232 |
}
|
233 |
});
|