• Hey,

    I also recognize this. For that reason i changed the code, to that the file will contains the order-id, so it’s unique for every session, user. This solves the problem. Below my changes :

    NMM_Gateway.php
    0) Create tmp dir in PluginDir/assests/tmp
    1) change qr function

    private function get_qr_code($order_id, $crypto, $walletAddress, $cryptoTotal) {        
            //$dirWrite = NMM_ABS_PATH . '/assets/img/';
            $dirWrite = NMM_ABS_PATH . '/assets/tmp/';
            $formattedName = $this->get_qr_prefix($crypto);
            //$qrData = $formattedName . ':' . $walletAddress . '?amount=' . $cryptoTotal;
            $qrData = $walletAddress;
    
            try {
                QRcode::png($qrData, $dirWrite . 'tmp_qrcode-' . $order_id . '.png', QR_ECLEVEL_H);            
                //QRcode::png($qrData, $dirWrite . 'tmp_qrcode.png', QR_ECLEVEL_H);            
            }
            catch (\Exception $e) {
                NMM_Util::log(__FILE__, __LINE__, 'QR code generation failed, falling back...');
                $endpoint = 'https://api.qrserver.com/v1/create-qr-code/?data=';
                return $endpoint . $qrData;
            }
            $dirRead = NMM_PLUGIN_DIR . '/assets/tmp/';
            return $dirRead . 'tmp_qrcode-'. $order_id . '.png';
            //return $dirRead . 'tmp_qrcode.png';
        }

    2) change in “additional_email_details” function :
    //$qrCode = $this->get_qr_code($crypto, $orderWalletAddress, $orderCryptoTotal);
    $qrCode = $this->get_qr_code($order->get_id(), $crypto, $orderWalletAddress, $orderCryptoTotal);

    3) change in “output_thank_you_html” function
    $qrCode = $this->get_qr_code($orderId,$crypto, $orderWalletAddress, $cryptoTotal);

    And this solves this problem.

    Thank you for this great plugin! Very usefully and good maintenable.

  • The topic ‘QR code file problem’ is closed to new replies.