1

I want to render/execute some javascript code written inside virtuemart JDispatcher eg: plgVmConfirmedOrder

eg:

$script='console.log("this is dummy script");jQuery.ajax({url:'',type:'post',success:function(){console.log("task has been done")}})';

function plgVmConfirmedOrder(VirtuemartCart $cart,$order){
      $document=JFactory::getDocument();
      $document->addScriptDeclaartion($script);// this is not working
      How to do?
}
1

You need to escape your javascript properly.

$script='console.log("this is dummy script");jQuery.ajax({url:\'\',type:\'post\',success:function(){console.log("task has been done")}})';

And, you misspelt declaration

$document->addScriptDeclaartion($script);

And I presume you have your vm plugin installed and switched on and working. If you're not sure if your event is firing then change your code to:

function plgVmConfirmedOrder(VirtuemartCart $cart,$order){
    echo "confirm order event fired";
    die();
}

If that doesn't work then your problem is different from dealing with js.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.