Page 1 of 1

Phoca Cart / PDF QR code

Posted: 17 Feb 2022, 19:17
by Nidzo
How Phoca Cart generates QR code?

National Bank of Serbia enabled QR Code payment system where using their code generator script you can scan generated code with bank mobile application and you get all data filled. User just need to confirm payment.
This is example for generating QR code via text record (string):

Code: Select all

K:PR|V:01|C:1|R:SELLER ACCOUNT NUMBER|N:NAME OF RECIPIENT
ADRESS LINE 1
ADRESS LINE 2|I:RSDAMMOUNT TO PAY|SF:[b]PAYMENT CODE[/b]|S:PURPOSE OF PAYMENT
|RO:0000
Some of those fields maybe could be replaced with Phoca Cart short codes but I don't know where to start, what files generates Phoca QR Code?

Re: Phoca Cart / PDF QR code

Posted: 20 Feb 2022, 23:26
by Nidzo
It can be achieved by using short codes.
I need to change way how {totaltopaynoformat} short code displays decimal space. Currently it display as dot. I need it to show a comma.
For example 20,00

Re: Phoca Cart / PDF QR code

Posted: 20 Feb 2022, 23:43
by Jan
Hi, totalpaynoformat uses standard computer dot. What about "totaltopay"?

Are you really sure, the comma is used as this is not usual for raw numbers :idea:

I can add new variable there: totaltopaynoformatcomma but this will be used in Joomla 4 and Phoca Cart 4

Re: Phoca Cart / PDF QR code

Posted: 21 Feb 2022, 01:50
by Nidzo
"totaltopay" adds currency symbol which is not valid in this case.
Absolutely sure about dot. This is qr code generated only with "totaltopaynoformat"

Image

Result is 650.00
I need to be 650,00 :|

It would be nice to work in Joomla 3

Re: Phoca Cart / PDF QR code

Posted: 21 Feb 2022, 14:20
by Jan
Quick hack:

File: administrator/components/com_phocacart/libraries/phocacart/text/text.php
Add below (line cca 95, can be other as I do this in J4):
$body = isset($replace['totaltopaynoformat']) ? str_replace('{totaltopaynoformat}', $replace['totaltopaynoformat'], $body) : $body;

following code:

Code: Select all

$body = isset($replace['totaltopaynoformatcomma'])	? str_replace('{totaltopaynoformatcomma}', $replace['totaltopaynoformatcomma'], $body)	: $body;
File: administrator/components/com_phocacart/libraries/phocacart/text/text.php

Add below (line cca 345, can be other as I do this in J4):
$r['totaltopaynoformat'] = number_format($totalToPay, 2, '.', '');
following code:

Code: Select all

$r['totaltopaynoformatcomma']	= number_format($totalToPay, 2, ',', '');
This should do the trick.

Jan

Re: Phoca Cart / PDF QR code

Posted: 21 Feb 2022, 14:59
by Nidzo
I like this quick hack! :twisted: It works flawlessly.
In Joomla 3, first code is at line 90 and the second one is at line 339.
You can see it in action:
https://photos.app.goo.gl/L4uQWsuyWJkA3qg76

Achieved with Phoca Cart short codes.

Code: Select all

K:PR|V:01|C:1|R:205000000040471010|N:Una Serbica
Nehruova 105
Novi Beograd|I:RSD{totaltopaynoformatcomma}|P:{b_name_first} {b_name_last}
{b_address_1}
{b_city}|SF:289|S:Knjiga za humanost|RO:0000
Thank you Jan!

Re: Phoca Cart / PDF QR code

Posted: 01 Mar 2022, 20:54
by Jan
Ok, thank you for the info, this will be set as standard in Phoca Cart 4

Jan

Re: Phoca Cart / PDF QR code

Posted: 03 Mar 2022, 16:46
by Nidzo
Thread can be marked as solved.

Re: Phoca Cart / PDF QR code

Posted: 04 Mar 2022, 23:41
by Jan
Ok