change default text displayed after PayPal payment.

Phoca Cart - complex e-commerce extension
unclepips
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 15 Feb 2021, 15:43

change default text displayed after PayPal payment.

Post by unclepips »

I am wanting to change the text that is displayed to the shopper once they have returned from PayPal. At the moment it is a basic one line response.

Having searched through the forums, and read through the extremely good PDF manual, I think I know what I need to do. I need to change something with the PCP plugin for PayPal.

I thought I would be able to do a template override, but when I go to create this in my template (Helix3), I cannot see the PCP there. I have found this in the plugins > pcp > paypal_standard folder.

Obviously I don’t want to overwrite these files. If I am correct in my thinking that these are the files I need to change, can you advise on how to create template overrides for them please.

I am new to using Phoca Cart, and am slowly getting my head around how it works. I will happily share any code that I create if it will be of use to others too :-)

I have had lots of other questions, most of which I have resolved now, by reading the forums and the manual :-)

Thank you in advance,
Phil.

Tags:
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: change default text displayed after PayPal payment.

Post by Jan »

Hi, there are different options to do this:

- you can set the message to option Info View Description:
Image
- you can change the language strings (in file or in language override in Joomla administration)
Image
- the strings can be managed even by payment plugin
- and of course the view can be overriden by template

Jan
If you find Phoca extensions useful, please support the project
unclepips
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 15 Feb 2021, 15:43

Re: change default text displayed after PayPal payment.

Post by unclepips »

Thank you Jan for your reply.

I have created a template override for the language file and can now change that text, thank you.

I was hoping I could use some of the variables in there, like: {invoicenumber}, {name} etc. like you can use in an email on the order statuses.

I was thinking of how to display these variables. They don’t appear to work in the language file, so then I was thinking of using a third party plugin to allow me to use custom PHP in an article which I then specify in the INFO VIEW setting, this PHP code would then pull up session variables.

I have created a template override of the order.php page, and then added a line at the end:-

$_SESSION['pipscart'] = “invoice: “.PhocacartOrder::getInvoiceNumber($d['common']->id, $d['common']->date, $d['common']->invoice_number);

(I have also added some more variables in the string that I haven’t listed) then in my custom PHP page I have put

print_r($_SESSION);

This works perfectly when I use the Cash on Delivery payment method, however when I use the PayPal Standard method it fails to record the session variable (see screenshots below).

Am I over-complicating what I am trying to achieve? Is there a system already built in to the phocacart whereby I can display order variables in the INFO VIEW article?

I have looked through the PDF and found some information on InfoView on pages 68 and 104, but cannot find what I am looking for (I am probably not looking in the right place).

This is the output when order is processed by the Cash on Delivery option
[img]https://i.imgur.com/eDMQMA2.png[/img]

This is the output when order is procssed by the PayPal Standard option
[img]https://i.imgur.com/Gnh3HVK.png[/img]

Thanks again,
Phil.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: change default text displayed after PayPal payment.

Post by Jan »

Hi, yes, it is not easy as it looks. After the order is done and you are redirected to PayPal or another payment method, session needs to be cleaned - because you are forwarding to another page and your order is finished in Phoca Cart website. So after you will be returning back to Phoca Cart page, there cannot be any information in session regarding order because you need to be able to do new order in the browser - so all the previous activity needs to be deleted when leaving Phoca Cart after order is finished and we are redirecting to payment method website. And all the information are stored in database not in session so it can be checked for correctness, etc. etc.

I have added it to feature request list to take a look at it if there is no such option to set the session even when you leave the pate and are redirected to payment method (in case, there will be such possibility, the problematic part will be, in which time it should be then completely cleaned :idea:)

Jan

https://github.com/PhocaCz/PhocaCart/issues/46
If you find Phoca extensions useful, please support the project
unclepips
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 15 Feb 2021, 15:43

Re: change default text displayed after PayPal payment.

Post by unclepips »

Thank you for your reply Jan and also for adding it to the feature request list. I will keep thinking myself of ways around this, and let you know if I do.

The idea was to just display some information on screen for the customer, just in case they do not receive the email (or it goes to their Spam folder), they would have a reference number displayed on screen.

Thanks again,
Phil.
unclepips
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 15 Feb 2021, 15:43

Re: change default text displayed after PayPal payment.

Post by unclepips »

Hi Jan,

I have had an idea on possibly achieving this. Outlined below:-

/templates/shaper_helix3/html/com_phocacart/checkout/default.php
1: Check if a cookie exists called “bid”, if not create it with unique number based on time() and 4 random characters.

/templates/shaper_helix3/html/layouts/com_phocacart/order.php
2: get value of cookie “bid”
3: write text file with the filename of the value of the cookie “bid” to DOCUMENT_ROOT/includes
4: add variable values to the text file: ordernumber, amount, name, ship

In custom.php file called from article in INFOVIEW
5: get value of cookie “bid” and open the text file with that filename
6: extract values from text file and echo to screen.
7: delete cookie and text file

The only problem that I have is that the text file is being written without a filename, so in order.php

Then I have just realised that the order.php page is probably called after the IPN from PayPal, which is why the Cookie won’t show as the session data has been cleared from memory!

So my next thought then is to put the code from order.php (steps 2,3,4) in to the page which calls the payment. Just not sure which that page is......

Thanks,
Phil.
unclepips
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 15 Feb 2021, 15:43

Re: change default text displayed after PayPal payment.

Post by unclepips »

Hi Jan,

I have managed to get this working using a combination of ways:-

Payment by cash: I add the details that I want to the cookie ‘bid’.

Payment by PayPal: templates/shaper_helix3/html/com_phocacart/payment/default.php - save to the cookie 'bid' the data: $this->t['o']

then in the test.php page, which is called by INFO VIEW I open the cookie ‘bid’ and search for the word "paypal" if found then extract the relevant bits of information to display on the screen from the html form. Otherwise, just explode the string in the cookie ‘bid’ into the variables.

It might be a bit of a messy way of achieving what I want at the moment, and maybe it can be improved on.

I am just debating whether there are any details in the “$this->t['o']” data that would be sensative if anyone where to examine the cookie on their PC? The cookie does get deleted as soon as my test.php page gets the relevant data it needs.

I can send you my code if you want to see it on private message?

Screenshots:-
Cash Payment
Image

PayPal Payment
Image


Thanks,
Phil.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: change default text displayed after PayPal payment.

Post by Jan »

Hi, thank you for the info.

So that there is no need to customize it in template overrides, maybe some way could be adding events to the views and add all this to plugin events (info view and payment view can get these info when triggering event in payment plugin)

Yes, the problem with cookie is, you maybe will be not redirected from payment gateway back to the shop website so it will be not deleted. When this happen by anonymous cart, then it is not sensitive like when this happen with finished order with all the data.

But if this will be done in plugins and events then it will depend on each user - we can add an example to plugin and let users decide to e.g. uncomment such code for their needs.

Yes, will be great to get the code. See PM
If you find Phoca extensions useful, please support the project
Post Reply