Displaying html/js at checkout end using plugin

  • Posts: 42
  • Thank you received: 1
9 years 4 months ago #208972

-- url of the page with the problem -- : localhost
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.3
-- PHP version -- : 5.5.12
-- Browser(s) name and version -- : Firefox 37.0.2

Hello,

I'm trying to display some javascript code at the end of checkout (on last checkout page - after customer confirms order).

I found in your API docs some very useful info, for now I made some simple plugin. It has one parameter, under Extensions->Plugins->myplugin I can enter this param and everything is saving fine (plugin is group="hikashop" and it's published etc., I checked all things twice). Now in my php file I'm trying simple things like:


defined('_JEXEC') or die('Restricted access');
class plgHikashopMyPlugin extends JPlugin {
function plgHikashopMyPlugin(&$subject, $config){
parent::__construct($subject, $config);
}
function onAfterOrderCreate(&$order, &$send_email) {
$document = JFactory::getDocument();
$document->addScriptDeclaration('SOME_DUMMY_CODE = 1');
}
}


However no matter what, SOME_DUMMY_CODE doesn't appear on my after checkout (confirmation) page.
Could you please suggest why? Maybe it's not possible to "echo" anything through triggers?

I was trying also: onAfterOrderConfirm(&$order,&$methods,$method_id), didn't work.

Best regards,
Chris

Last edit: 9 years 4 months ago by Gnsbud.

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 4 months ago #208978

Hi,

The triggers onAfterOrderCreate and onAfterOrderConfirm are called at the end of the checkout before the redirection to the payment gateway.
I suppose that what you want to do is to display your javascript after the payment on the payment gateway, when the user comes back on the website and in that case, none of these triggers will help.
The simplest would be to edit the file "after_end" of the view "checkout" via the menu Display>Views and add your code directly in there.
It will be added on the end page, when the customer is returning on the website and see the "thank you for your purchase" message.

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 1
9 years 4 months ago #209045

Hi Nicolas,

no, it's not payment gateway, I'm using "HikaShop bank transfer payment plugin", it just displays some info at the end.

The purpose for this javascript (or any other simple code I want to display) is as follows:

Client must fill some order custom field and at the end of checkout javascript will appear or not (I'll do some simple if statement), however I can't display anything using above triggers, that's why I'm asking if everything is ok with these triggers.

Best regards,
Chris

Last edit: 9 years 4 months ago by Gnsbud.

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 1
9 years 4 months ago #209052

sorry, wrong topic

Last edit: 9 years 4 months ago by Gnsbud.

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 4 months ago #209066

For the onAfterOrderConfirm trigger it's normal that you don't get anything as it is called only in the payment plugin which was selected. So your custom plugin onAfterOrderConfirm function will never be called.
For the onAfterOrderCreate trigger, it is called at the end of the checkout with the bank transfer payment method selected and if you add javascript in that function you'll see it in the headers of the page.
If you don't get anything, check that this function is called at the end of the checkout (add an exit; in it)
If it's not called, then either the plugin is in the correct group, or not published, or the file name or class name are not correct, etc.
If it's called, then I don't see why you wouldn't see your javascript in the header of the page.

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 1
9 years 4 months ago #209373

I'm out of ideas :dry: Would you kindly check by your side if plugin from attachment is working or not? Thanks in advance.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 4 months ago #209375

Hi,

The solution is in my previous message:

If it's not called, then either the plugin is in the correct group, or not published, or the file name or class name are not correct, etc.


The class name of your plugin is wrong. Based on your XML it should be plgHikashopCeneo_zaufane_hikashop and not plgHikashopCeneoZaufaneOpinie

The following user(s) said Thank You: Gnsbud

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum