how to add a value to a custom column

  • Posts: 4
  • Thank you received: 0
13 years 9 months ago #5369

hi and thank you for your great shop
i created a payment type on my country and when the payment is done, i want to add a custom reference value to a custom column i created inside the jos_hikashop_order table.

The value is "referencia". this value is for payments done in ATM in my country wich are very popular (in Portugal)
so i created the "multibanco" payment option and it works, it generates the reference to wich people have to pay, and also sends an e-mail to our clients with that reference but i need to add this value to the database to keep track of things in the future.
on my multibanco.php i added:

$db =& JFactory::getDBO();
$query = 'UPDATE '.hikashop::table('order').' SET referencia ='.$referencia2.' WHERE order_id ='.$order->order_id'';
$db->setQuery($query);
$result = $db->query();

but this does not work. i dont konw what is wrong with it
thanks in advance

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

  • Posts: 82725
  • Thank you received: 13338
  • MODERATOR
13 years 9 months ago #5372

$referencia2 needs to be quoted and you have two quotes at the end which is not correct. It should be:

$query = 'UPDATE '.hikashop::table('order').' SET referencia ='.$db->Quote($referencia2).' WHERE order_id ='.(int)$order->order_id;

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

  • Posts: 4
  • Thank you received: 0
13 years 9 months ago #5373

hi mate thank you for your fast reply i tested and it still does not work.

it's like this:

$db =& JFactory::getDBO();
$query = 'UPDATE '.hikashop::table('order').' SET referencia ='.$db->Quote($referencia2).' WHERE order_id ='.(int)$order->order_id;
$db->setQuery($query);
$result = $db->query();

i dont know if my file multibanco.php on the payment plugins should include some kind of joomla file.
im using joomla 1.5.22
at least i have phpmyadmin opened and i refresh the databse and i see the new product on the order tables but the "referencia" field is still empty.
also "referencia" is set as text to avoid problems once we just need it to check manually and know wich person bought what and when, and also to put it on the invoice on the details field.

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

  • Posts: 82725
  • Thank you received: 13338
  • MODERATOR
13 years 9 months ago #5374

Are you sure that you have the order_id in the $order object ? In which function of your plugin are you doing that query ?

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

  • Posts: 4
  • Thank you received: 0
13 years 9 months ago #5382

hi mate here is the code:
pastebin.com/9UhBgTf6
it will work for 24 hours
you can see the full multibanco payment system.
please dont laught at the "mess" of my code, at least part of it works :)
thanks

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

  • Posts: 82725
  • Thank you received: 13338
  • MODERATOR
13 years 9 months ago #5384

In your function onAfterOrderConfirm, you don't set the variable $referencia2 and directly use it in the query, so it's normal that you get an empty value in the field in the database.

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

  • Posts: 4
  • Thank you received: 0
13 years 9 months ago #5387

hi, thank you very much, i also set that variable as global so i dont have more problems. it's only used on the payment action and only if the payment is ATM so i will not touch it again soon.

once again thank you very much

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

  • Posts: 111
  • Thank you received: 0
  • Hikashop Essential
9 years 4 months ago #203885

Hello,

I have a similar situation: we need the same system: "Multibanco" references sent to the customer. This is a very popular payment system here in Portugal.

Can anyone share any code to be used as a reference so that I can create a custom payment in Hikashop?

Thank you for any help!

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

  • Posts: 26150
  • Thank you received: 4026
  • MODERATOR
9 years 4 months ago #203890

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.051 seconds
Powered by Kunena Forum