Jump to content

[SOLVED] Get a sagepay value from database for mailalert module


Recommended Posts

I need to be able to add a sagepay code to the new order email used in mailalert module.

 

What I have is

// Filling-in vars for email
 $template = 'new_order';
 $subject = $this->l('New order');
 $spvtxc = Db::getInstance()->ExecuteS("SELECT vendortxcode FROM `"._DB_PREFIX_."sagepay_transactions` WHERE id_cart = '$order->id_cart'");
...
 $templateVars = array(
  '{firstname}' => $customer->firstname,
  '{lastname}' => $customer->lastname,
...
  '{sagepay_no}' => $spvtxc,
...
 );

Every time i test a transaction the $spvtxc returns 'ARRAY'.

I have tried

$spvtxc = '5';

As Expected this returns 5 as the sagepay number, so I'm confident the variables are being called and added to the email.

And I tried

$spvtxc = Db::getInstance()->ExecuteS("SELECT vendortxcode FROM `"._DB_PREFIX_."sagepay_transactions` WHERE id_cart = '2'");

So this should set $spvtxc to the value that is definatly there (i manually added it in the database), but this still returned 'ARRAY'.

 

If anyone can point out what I have missed, it is greatly appriceated.

Edited by neller (see edit history)
Link to comment
Share on other sites

try using the getValue function instead of ExecuteS

  $spvtxc = Db::getInstance()->getValue("SELECT vendortxcode FROM `"._DB_PREFIX_."sagepay_transactions` WHERE id_cart = '$order->id_cart'");

 

As long as your query will return only a single row, and you are only trying to select a single column, then getValue should work for you

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...