From a97791bb1bde8be1c14728f7358838b3c129bfae Mon Sep 17 00:00:00 2001 From: Justin Sainton Date: Sat, 26 Nov 2016 13:33:22 -0800 Subject: [PATCH] Ensure that purchase logs are properly created and checked for existence in checkout process. Fix #2172. --- .../theme-engine-v2/mvc/controllers/checkout.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/wpsc-components/theme-engine-v2/mvc/controllers/checkout.php b/wpsc-components/theme-engine-v2/mvc/controllers/checkout.php index 76399ff054..2018ae56dd 100644 --- a/wpsc-components/theme-engine-v2/mvc/controllers/checkout.php +++ b/wpsc-components/theme-engine-v2/mvc/controllers/checkout.php @@ -237,9 +237,16 @@ public function get_purchase_log() { // otherwise create one $purchase_log_id = (int) wpsc_get_customer_meta( 'current_purchase_log_id' ); + $create = true; + if ( $purchase_log_id ) { $purchase_log = new WPSC_Purchase_Log( $purchase_log_id ); - } else { + $create = ! $purchase_log->exists(); + } + + if ( $create ) { + wpsc_delete_customer_meta( 'current_purchase_log_id' ); + $purchase_log = new WPSC_Purchase_Log(); $purchase_log->set( array( @@ -247,9 +254,7 @@ public function get_purchase_log() { 'date' => time(), 'plugin_version' => WPSC_VERSION, 'statusno' => '0', - ) ); - - $purchase_log->save(); + ) )->save(); } return $purchase_log;