-
+
', 'OnDownloadLabel'); return false;">
@@ -243,4 +243,4 @@
-
\ No newline at end of file
+
Index: branches/5.3.x/units/products/products_config.php
===================================================================
diff -u -N -r16174 -r16192
--- branches/5.3.x/units/products/products_config.php (.../products_config.php) (revision 16174)
+++ branches/5.3.x/units/products/products_config.php (.../products_config.php) (revision 16192)
@@ -1,6 +1,6 @@
hAFTER,
+ 'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'lst',
'HookToSpecial' => '*',
Index: branches/5.3.x/units/addresses/addresses_config.php
===================================================================
diff -u -N -r15656 -r16192
--- branches/5.3.x/units/addresses/addresses_config.php (.../addresses_config.php) (revision 15656)
+++ branches/5.3.x/units/addresses/addresses_config.php (.../addresses_config.php) (revision 16192)
@@ -1,6 +1,6 @@
'OnUpdateProfileAddress',
),
Array (
- 'Mode' => hAFTER,
+ 'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => '#PARENT#',
'HookToSpecial' => '*',
Index: branches/5.3.x/units/orders/orders_event_handler.php
===================================================================
diff -u -N -r16106 -r16192
--- branches/5.3.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 16106)
+++ branches/5.3.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 16192)
@@ -1,6 +1,6 @@
getInventoryObject($product_object, $combination_item, $combinations[ $rec['ProductId'].'_'.$rec['OptionsSalt'] ]);
$lack = $rec['Quantity'] - $rec['QuantityReserved'];
- if ($lack > 0) {
- // reserve lack or what is available (in case if we need to reserve anything, by Alex)
- $to_reserve = min($lack, $inv_object->GetDBField('QtyInStock') - $product_object->GetDBField('QtyInStockMin'));
- if ($to_reserve < $lack) $event->status = kEvent::erFAIL; // if we can't reserve the full lack
+ if ( $lack > 0 ) {
+ // Reserve lack or what is available (in case if we need to reserve anything, by Alex).
+ $to_reserve = min(
+ $lack,
+ $inv_object->GetDBField('QtyInStock') - $product_object->GetDBField('QtyInStockMin')
+ );
- //reserve in order
- $order_item->SetDBFieldsFromHash($rec);
- $order_item->SetDBField('QuantityReserved', $rec['QuantityReserved'] + $to_reserve);
- $order_item->SetId($rec['OrderItemId']);
- $order_item->Update();
+ // If we can't reserve the full lack.
+ if ( $to_reserve < $lack ) {
+ $event->status = kEvent::erFAIL;
+ }
- //update product - increase reserved, decrease in stock
+ // Reserve in order.
+ $order_item->SetDBFieldsFromHash($rec);
+ $order_item->SetDBField('QuantityReserved', $rec['QuantityReserved'] + $to_reserve);
+ $new_lack = $order_item->GetDBField('Quantity') - $order_item->GetDBField('QuantityReserved');
+ $order_item->SetDBField('BackOrderFlag', abs($new_lack) <= 0.0001 ? 0 : 1);
+ $order_item->SetId($rec['OrderItemId']);
+ $order_item->Update();
+
+ // Update product - increase reserved, decrease in stock.
$inv_object->SetDBField('QtyReserved', $inv_object->GetDBField('QtyReserved') + $to_reserve);
$inv_object->SetDBField('QtyInStock', $inv_object->GetDBField('QtyInStock') - $to_reserve);
$inv_object->SetDBField('QtyBackOrdered', $inv_object->GetDBField('QtyBackOrdered') - $to_reserve);
$inv_object->Update();
- if ($product_object->GetDBField('InventoryStatus') == 2) {
- // inventory by options, then restore changed combination values back to common $combinations array !!!
- $combinations[ $rec['ProductId'].'_'.$rec['OptionsSalt'] ] = $inv_object->GetFieldValues();
+ if ( $product_object->GetDBField('InventoryStatus') == 2 ) {
+ // Inventory by options, then restore changed combination
+ // values back to common $combinations array !!!
+ $combinations[$rec['ProductId'] . '_' . $rec['OptionsSalt']] = $inv_object->GetFieldValues();
}
}
$order_items->GoNext();
@@ -3810,9 +3820,7 @@
return ;
}
- $copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(Array ())));
-
- foreach ($copied_ids as $id) {
+ foreach ( $this->trackCopiedOrderIDs($event) as $id ) {
$an_event = new kEvent($this->Prefix . ':Dummy');
$this->Application->SetVar($this->Prefix . '_id', $id);
$this->Application->SetVar($this->Prefix . '_mode', ''); // this is to fool ReserveItems to use live table
@@ -3821,22 +3829,39 @@
}
/**
- * Occurs before an item is copied to live table (after all foreign keys have been updated)
- * Id of item being copied is passed as event' 'id' param
+ * Occurs after an item has been copied to live table
+ * Id of copied item is passed as event' 'id' param
*
* @param kEvent $event
* @return void
* @access protected
*/
- protected function OnBeforeCopyToLive(kEvent $event)
+ protected function OnAfterCopyToLive(kEvent $event)
{
- parent::OnBeforeCopyToLive($event);
+ parent::OnAfterCopyToLive($event);
- $id = $event->getEventParam('id');
- $copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(array ())));
- array_push($copied_ids, $id);
+ $this->trackCopiedOrderIDs($event, $event->getEventParam('id'));
+ }
- $this->Application->StoreVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize($copied_ids));
+ /**
+ * Tracks copied order IDs.
+ *
+ * @param kEvent $event Event.
+ * @param integer $id Order ID.
+ *
+ * @return array
+ */
+ protected function trackCopiedOrderIDs(kEvent $event, $id = null)
+ {
+ $setting_name = $event->Prefix . '_copied_ids' . $this->Application->GetVar('wid');
+ $ids = $this->Application->GetVar($setting_name, array());
+
+ if ( isset($id) ) {
+ array_push($ids, $id);
+ $this->Application->SetVar($setting_name, $ids);
+ }
+
+ return $ids;
}
/**
Index: branches/5.3.x/units/shipping/shipping_tag_processor.php
===================================================================
diff -u -N -r15671 -r16192
--- branches/5.3.x/units/shipping/shipping_tag_processor.php (.../shipping_tag_processor.php) (revision 15671)
+++ branches/5.3.x/units/shipping/shipping_tag_processor.php (.../shipping_tag_processor.php) (revision 16192)
@@ -1,6 +1,6 @@
Application->isAdminUser && $key ) {
+
+ if ( $this->Application->isAdminUser && isset($key) && $key ) {
$orig_name = ltrim($last_shippings[$package_id][$key]['ShippingName'], 'Original: ');
$last_shippings[$package_id][$key]['ShippingName'] = $orig_name;
}
@@ -334,4 +335,4 @@
return $o;
}
-}
\ No newline at end of file
+}
Index: branches/5.3.x/admin_templates/orders/orders_edit_billing.tpl
===================================================================
diff -u -N -r15971 -r16192
--- branches/5.3.x/admin_templates/orders/orders_edit_billing.tpl (.../orders_edit_billing.tpl) (revision 15971)
+++ branches/5.3.x/admin_templates/orders/orders_edit_billing.tpl (.../orders_edit_billing.tpl) (revision 16192)
@@ -106,8 +106,6 @@
-
-
@@ -155,8 +153,6 @@
-
-
@@ -217,4 +213,4 @@
-
\ No newline at end of file
+
Index: branches/5.3.x/units/sections/sections_config.php
===================================================================
diff -u -N -r15492 -r16192
--- branches/5.3.x/units/sections/sections_config.php (.../sections_config.php) (revision 15492)
+++ branches/5.3.x/units/sections/sections_config.php (.../sections_config.php) (revision 16192)
@@ -1,6 +1,6 @@
Array (
Array (
- 'Mode' => hAFTER,
+ 'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'site-domain',
'HookToSpecial' => '*',
Index: branches/5.3.x/units/reports/reports_config.php
===================================================================
diff -u -N -r15925 -r16192
--- branches/5.3.x/units/reports/reports_config.php (.../reports_config.php) (revision 15925)
+++ branches/5.3.x/units/reports/reports_config.php (.../reports_config.php) (revision 16192)
@@ -1,6 +1,6 @@
Array (
Array (
- 'Mode' => hAFTER,
+ 'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'rep',
'HookToSpecial' => '*',
|