CodeIgniter Forums
Ciqrcode generate - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Ciqrcode generate (/showthread.php?tid=81178)



Ciqrcode generate - Lipe Shtogu - 02-01-2022

Hi bros, how can i automatically create QrCode upon product creation.
i have managed to create the product and then to add one button which generates the QRCode for the specific id.
//Generate QRCode
public function qrgenerator($id){

$config['cacheable']    = true; //boolean, the default is true
$config['cachedir']    = ''; //string, the default is application/cache/
$config['errorlog']    = ''; //string, the default is application/logs/
$config['quality']      = true; //boolean, the default is true
$config['size']        = '1024'; //interger, the default is 1024
$config['black']        = array(224,255,255); // array, default is array(255,255,255)
$config['white']        = array(70,130,180); // array, default is array(0,0,0)
$this->ciqrcode->initialize($config);

//GenerateQR
$params['data']  = base_url().'products/'.$id;
$params['level'] = 'H';
$params['size'] = 10;
$image_name = $id.'.png';
$params['savename'] = FCPATH.'uploads/qr_image/'.$image_name;

$this->ciqrcode->generate($params);

$product = $this->product_model->get_product_by_id($id);

$data = array(
'title' => 'print_qrcode',
'product' => $product['product_id'],
'qr_image' => $image_name,
);

$this->session->set_flashdata('success', 'Generated');
redirect(base_url('product/index'));

}


RE: Ciqrcode generate - InsiteFX - 02-02-2022

When you create the product save the product then get the insertId and then call your qrgenerator($id) method right after the insertId call..