# Adding a Custom Button to TakePOS

**URL:** <https://www.dolibarr.org/forum/t/adding-a-custom-button-to-takepos/30211>\
**Category:** Other native modules\
**Tags:** Help\
**Created:** [April 6, 2025, 5:25pm UTC](https://www.dolibarr.org/forum/t/adding-a-custom-button-to-takepos/30211 "2025-04-06T17:25:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hasjalil](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/hasjalil/32/8483_2.png) [@hasjalil](https://www.dolibarr.org/forum/u/hasjalil)\
**Post date:** [April 6, 2025, 5:25pm UTC](https://www.dolibarr.org/forum/t/adding-a-custom-button-to-takepos/30211/1 "2025-04-06T17:25:30Z")

</div>

I recently added a custom button to the TakePOS interface in Dolibarr 21.0.0 to enhance my point-of-sale workflow. By editing `/htdocs/takepos/index.php` at lines betwen 1400–1500, I inserted these lines:

* * *

```auto
$menus[$r++] = array('title' => '<span class="fa fa-qrcode paddingrightonly"></span><div class="trunc">'.$langs->trans("QR Code(s)").'</div>', 'action' => 'AddedAction()();');

```

* * *

This adds a button labeled “QR code(s)” with a fa-qrcode icon,. To make it functional, you’ll need to define the AddedAction()() function in `/takepos/js/index.php. here’ the javascript for the function to open popup window displaying codes (QR,Barcode or Datamatrix)

* * *

function AddedAction() {  
// Check if a line is selected  
if (typeof selectedline === ‘undefined’ || !selectedline) {  
alert(“Please select a product line first!”);  
return;  
}

```auto
  	  alert(selectedline);

```

// Extract product name, quantity, and price you must find the corresponding variables in httdocs/takepos/index.php

\<?php $product = "Laptop"; $price = 1200; $customer = "Alice Smith"; ?\>

// Open the popup with the QR code  
// open popopup window  
const product = “\<?php echo urlencode($product); ?\>”;  
const price = “\<?php echo urlencode($price); ?\>”;  
const customer = “\<?php echo urlencode($customer); ?\>”;  
const url = `qr.php?product=${product}&price=${price}&customer=${customer}`;  
window.open(  
url, // URL of the popup  
“Imression des codes”, // Name of the popup window  
“width=400,height=900” // Features  
);

```auto
}

```

* * *

It’s a simple way to customize TakePOS—just ensure you back up your file before editing!  
It will be helpful foe me if you can find the variables costumer, price,qte… in the file index.php. Thanks

 ![qr code takepos](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/2/2acb064ca98666b640477b7b7553b31fc8ec7731.png)

---

<div class="post-metadata">

**Author:** ![altatof](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/altatof/32/2426_2.png) [@altatof](https://www.dolibarr.org/forum/u/altatof)\
**Post date:** [April 7, 2025, 6:05am UTC](https://www.dolibarr.org/forum/t/adding-a-custom-button-to-takepos/30211/2 "2025-04-07T06:05:26Z")

</div>

Hello, i suggest you use the ActionButtons hook :wink:

```php
	function ActionButtons() {
		global $conf,$user,$langs,$hookmanager;

		if (in_array('takeposfrontend',$hookmanager->contextarray)) {
			print '<script type="text/javascript">
				// your js code here
			</script>';
		}
	}

```

---

<div class="post-metadata">

**Author:** ![hasjalil](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/hasjalil/32/8483_2.png) [@hasjalil](https://www.dolibarr.org/forum/u/hasjalil)\
**Post date:** [April 8, 2025, 6:26pm UTC](https://www.dolibarr.org/forum/t/adding-a-custom-button-to-takepos/30211/3 "2025-04-08T18:26:22Z")

</div>

This is the beginning of the project to build a module that produces and manages QR, Barcode and Datamatrix codes so any contribution, remark or suggestion will be very helpful. Thank you very much

---

<div class="post-metadata">

**Author:** ![altatof](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/altatof/32/2426_2.png) [@altatof](https://www.dolibarr.org/forum/u/altatof)\
**Post date:** [April 9, 2025, 6:53am UTC](https://www.dolibarr.org/forum/t/adding-a-custom-button-to-takepos/30211/4 "2025-04-09T06:53:31Z")

</div>

Ok, feel free to contact me if you need any help.  
Christophe
