Skip to content

Commit

Permalink
Merge pull request #51 from aait/master
Browse files Browse the repository at this point in the history
Generate guest handle in admin
  • Loading branch information
markusbrunke authored Dec 4, 2019
2 parents 6d01f0e + a4d2566 commit 7506c27
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions includes/abstracts/abstract-wc-payment-gateway-reepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,20 @@ public static function wcs_cart_have_subscription() {
*/
public function get_customer_handle( $user_id ) {
if ( ! $user_id ) {
if ( is_admin() ) {
if ( session_status() === PHP_SESSION_NONE ) {
session_start();
}

$guest_id = isset( $_SESSION['reepay_guest'] ) ? $_SESSION['reepay_guest'] : null;
if ( empty( $guest_id ) ) {
$guest_id = 'guest-' . wp_generate_password(12, false);
$_SESSION['reepay_guest'] = $guest_id;
}

return $guest_id;
}

$guest_id = WC()->session->get( 'reepay_guest' );
if ( empty( $guest_id ) ) {
$guest_id = WC()->session->generate_customer_id();
Expand Down

0 comments on commit 7506c27

Please sign in to comment.