Skip to content

Instantly share code, notes, and snippets.

@andriyun
Created October 22, 2020 09:50
Show Gist options
  • Save andriyun/3938aa78af909dca4dff0a41f10fbc6f to your computer and use it in GitHub Desktop.
Save andriyun/3938aa78af909dca4dff0a41f10fbc6f to your computer and use it in GitHub Desktop.

Revisions

  1. andriyun revised this gist Oct 22, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions debug-method.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    /**
    * Helper function to log info.
    */
  2. andriyun created this gist Oct 22, 2020.
    19 changes: 19 additions & 0 deletions debug-method.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    /**
    * Helper function to log info.
    */
    public static function _bc_filelog($message) {
    error_log(print_r($message, 1) . PHP_EOL, 3, '../checkout-session-info.log');
    }

    /**
    * {@inheritdoc}
    */
    public function addCartId($cart_id, $type = self::ACTIVE) {
    $key = $this->getSessionKey($type);
    $ids = $this->session->get($key, []);
    $ids[] = $cart_id;
    $this->session->set($key, array_unique($ids));
    self::_bc_filelog(date('Y-m-d H:i:s', strtotime('now')) . ' ' . __FUNCTION__);
    self::_bc_filelog($_SESSION);
    }