Skip to content

Commit

Permalink
Ensure that purchase logs are properly created and checked for existe…
Browse files Browse the repository at this point in the history
…nce in checkout process. Fix #2172.
  • Loading branch information
JustinSainton committed Nov 26, 2016
1 parent 859ed44 commit a97791b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions wpsc-components/theme-engine-v2/mvc/controllers/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,24 @@ 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(
'user_ID' => get_current_user_id(),
'date' => time(),
'plugin_version' => WPSC_VERSION,
'statusno' => '0',
) );

$purchase_log->save();
) )->save();
}

return $purchase_log;
Expand Down

0 comments on commit a97791b

Please sign in to comment.