Skip to content

Instantly share code, notes, and snippets.

@alpharder
Last active August 29, 2015 14:24
Show Gist options
  • Save alpharder/06546b972e801d6c927c to your computer and use it in GitHub Desktop.
Save alpharder/06546b972e801d6c927c to your computer and use it in GitHub Desktop.
diff --git a/app/functions/fn.cart.php b/app/functions/fn.cart.php
index 1e96c84..efa7eed 100644
--- a/app/functions/fn.cart.php
+++ b/app/functions/fn.cart.php
@@ -809,11 +810,19 @@ function fn_update_order(&$cart, $order_id = 0)
$order['promotion_ids'] = fn_create_set(array_keys($cart['promotions']));
}
- $old_order = db_get_row("SELECT company_id, payment_id, status FROM ?:orders WHERE order_id = ?i", $order_id);
+ $old_order = db_get_row(
+ "SELECT company_id, payment_id, status, parent_order_id FROM ?:orders WHERE order_id = ?i",
+ $order_id
+ );
+
$order['status'] = $old_order['status'];
$order['company_id'] = $old_order['company_id'];
$order_status = $order['status'];
+ if (!isset($order['parent_order_id'])) {
+ $order['parent_order_id'] = $old_order['parent_order_id'];
+ }
+
if (!empty($cart['payment_id']) && $cart['payment_id'] == $old_order['payment_id']) {
$payment_info = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = 'P'", $order_id);
if (!empty($payment_info)) {
@@ -1073,6 +1082,10 @@ function fn_update_order_data($order_id, $cart)
*/
function fn_place_order(&$cart, &$auth, $action = '', $issuer_id = null, $parent_order_id = 0)
{
+ if (isset($cart['parent_order_id']) && empty($parent_order_id)) {
+ $parent_order_id = (int)$cart['parent_order_id'];
+ }
+
$allow = fn_allow_place_order($cart, $auth);
fn_set_hook('pre_place_order', $cart, $allow, $cart['product_groups']);
@@ -4724,6 +4737,7 @@ function fn_form_cart($order_id, &$cart, &$auth)
Storage::instance('custom_files')->copy($dir_path, 'sess_data');
}
+ $cart['parent_order_id'] = $order_info['parent_order_id'];
$cart['payment_id'] = $order_info['payment_id'];
$cart['stored_taxes'] = 'Y';
$cart['stored_discount'] = 'Y';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment