payment method renderMailLayout() < finded bug and solution>

Started by revo1, January 12, 2012, 18:45:37 PM

Previous topic - Next topic

revo1

If you make a gateway for vmpayment example bank transfer  and use

if ($order_id) {
                               // send the email only if payment has been accepted
                               if (!class_exists('VirtueMartModelOrders'))
                                require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
                               $modelOrder = new VirtueMartModelOrders();
                               $order['order_status'] = $method->status_success;
                               $order['virtuemart_order_id'] = $order_id;
                               $order['customer_notified'] = 1;
                               $order['comments'] = JTExt::sprintf('VMPAYMENT_BANK_PAYMENT_CONFIRMED', $order_id);
                               $modelOrder->updateStatusForOneOrder($order_id, $order, true);
                               // remove vmcart
                           }

you get error like this :
Fatal error: Call to undefined method VirtuemartViewOrders::renderMailLayout() in /home/xxxxxxx/public_html/joomla17/components/com_virtuemart/helpers/shopfunctionsf.php on line 339.

is $order defined with this:
$cart = VirtueMartCart::getCart();
$order= new VirtueMartModelOrders();
$order=$order->getOrder($order_id);
or I just make a new array or what?
$order=new array(); -
Anyone help?


ruudjonk

I can confirm this, I also run into this problem.

Hope someone know a fix for this one.

ruudjonk


revo1

Same here.

if you get it working , please let me know it:)
if i, then i send to you pm and post somewhere

ruudjonk

Will do that. If we dont get an answer from someone that can help us before sunday then I will take a look at the latest svn or start looking at the vm core functions that are used to send mail. Maybe I could write up a patch.



---
I am here: http://maps.google.com/maps?ll=52.498100,5.053895

revo1

i have watched those mail's cores already
I think it's a problem with data
it's not with right format or something.da
Anyone can print $order out and send it to me? anyone, who has a paypal(i dont have it). then we can compare a data
before
this row
$order['order_status'] = $new_status;


Thanks folks.
sorry my bad english

ruudjonk

I just noticed that in the current svn version they set the $order['customer_notified'] to 0. Probably to temporarily fix this issue to not send the payment confirmation emails...

revo1

ok.
open
~/components/com_virtuemart/helpers/shopfunctionsf.php
FInd renderMail


Modify function start like this:


public function renderMail ($viewName, $recipient, $vars=array(),$controllerName = null,$noVendorMail = false) {
      if(!class_exists('VirtueMartControllerVirtuemart')) require(JPATH_VM_SITE.DS.'controllers'.DS.'virtuemart.php');
      $format = (VmConfig::get('order_html_email',1)) ? 'html' : 'raw';
       
      $controller = new VirtueMartControllerVirtuemart();
      $controller->addModelPath(JPATH_VM_SITE.DS.'models');
      $controller->addModelPath(JPATH_VM_ADMINISTRATOR.DS.'models');
        $controller->addViewPath(JPATH_VM_ADMINISTRATOR.DS.'views');
      $view = $controller->getView($viewName, $format);
        $view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.'/views/orders/tmpl');

all this need to be befor if()....


long version:
find rendermail function

find
$controller = new VirtueMartControllerVirtuemart();
         $controller->addModelPath(JPATH_VM_ADMINISTRATOR.DS.'models');
         $controller->addModelPath(JPATH_VM_SITE.DS.'models');

add after that
        $controller->addViewPath(JPATH_VM_ADMINISTRATOR.DS.'views');

find
  $view = $controller->getView($viewName, $format);
add after that
  $view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.'/views/orders/tmpl');

ruudjonk

Hello Revo1,

I will test this tomorrow. I hope this can be added to the core to fix that problem so we don't need to get worried whenever we will update our Virtuemart 2 Installation.

Thanks for the update and fix.

Ruud

ruudjonk

Hello Revo1,

I can confirme that it also works overhere.

You can also notice now that this one has never worked before with VM 2 as all the language strings used in the confirmation email are'nt available yet.

I hope a Virtuemart developer read this one and checks it out.

revo1

Problem explane:

We have two VirtuemartViewOrders. One for Admin and one for site.

On admin VirtuemartviewORDERs class have renderMaillayout function but site VirtuemartviewOrders doesn't.

To resolve this problem we need to add controller view and template to view.
1) find ~/components/com_virtuemart/helpers/shopfunctionsf.php and open it
2)find renderMail function and add after
$controller = new VirtueMartControllerVirtuemart();
         $controller->addModelPath(JPATH_VM_ADMINISTRATOR.DS.'models');
         $controller->addModelPath(JPATH_VM_SITE.DS.'models');

this:
$controller->addViewPath(JPATH_VM_ADMINISTRATOR.DS.'views');

3) Now find  $view = $controller->getView($viewName, $format);
and add after this
$view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.'/views/orders/tmpl');

this modification load VM administrator template and view.



Please notify me, when this bug is fixed.

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

bunglehaze

Would this be to start sending admin confirmation emails? I have added the code but am still not receiving admin confirmation emails as described here:
http://forum.virtuemart.net/index.php?topic=95733.0

I am also getting a lot of missing language on payment confirmations which are also mentioned in the other thread.

werian

This one added after
$format = (VmConfig::get('order_html_email',1)) ? 'html' : 'raw';
will translate new order status template:

$lang = &JFactory::getLanguage();      
$lang->load('com_virtuemart',JPATH_ADMINISTRATOR);