Phoca Cart / PDF QR code

Phoca Cart - complex e-commerce extension
User avatar
Nidzo
Phoca Professional
Phoca Professional
Posts: 388
Joined: 07 Nov 2018, 14:55

Phoca Cart / PDF QR code

Post 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?

Tags:
User avatar
Nidzo
Phoca Professional
Phoca Professional
Posts: 388
Joined: 07 Nov 2018, 14:55

Re: Phoca Cart / PDF QR code

Post 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
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Cart / PDF QR code

Post 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
If you find Phoca extensions useful, please support the project
User avatar
Nidzo
Phoca Professional
Phoca Professional
Posts: 388
Joined: 07 Nov 2018, 14:55

Re: Phoca Cart / PDF QR code

Post 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
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Cart / PDF QR code

Post 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
If you find Phoca extensions useful, please support the project
User avatar
Nidzo
Phoca Professional
Phoca Professional
Posts: 388
Joined: 07 Nov 2018, 14:55

Re: Phoca Cart / PDF QR code

Post 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!
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Cart / PDF QR code

Post by Jan »

Ok, thank you for the info, this will be set as standard in Phoca Cart 4

Jan
If you find Phoca extensions useful, please support the project
User avatar
Nidzo
Phoca Professional
Phoca Professional
Posts: 388
Joined: 07 Nov 2018, 14:55

Re: Phoca Cart / PDF QR code

Post by Nidzo »

Thread can be marked as solved.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Cart / PDF QR code

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
Post Reply