Skip to content

Commit a97791b

Browse files
committed
Ensure that purchase logs are properly created and checked for existence in checkout process. Fix #2172.
1 parent 859ed44 commit a97791b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

wpsc-components/theme-engine-v2/mvc/controllers/checkout.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,24 @@ public function get_purchase_log() {
237237
// otherwise create one
238238
$purchase_log_id = (int) wpsc_get_customer_meta( 'current_purchase_log_id' );
239239

240+
$create = true;
241+
240242
if ( $purchase_log_id ) {
241243
$purchase_log = new WPSC_Purchase_Log( $purchase_log_id );
242-
} else {
244+
$create = ! $purchase_log->exists();
245+
}
246+
247+
if ( $create ) {
248+
wpsc_delete_customer_meta( 'current_purchase_log_id' );
249+
243250
$purchase_log = new WPSC_Purchase_Log();
244251

245252
$purchase_log->set( array(
246253
'user_ID' => get_current_user_id(),
247254
'date' => time(),
248255
'plugin_version' => WPSC_VERSION,
249256
'statusno' => '0',
250-
) );
251-
252-
$purchase_log->save();
257+
) )->save();
253258
}
254259

255260
return $purchase_log;

0 commit comments

Comments
 (0)