Cart page : add donation line

  • Posts: 36
  • Thank you received: 0
8 years 11 months ago #223351

It doesn't work. ..
I put it in the beginning of the file and I have a error message when I confirm the command.

zupimages.net/viewer.php?id=15/50/yhg1.png

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

  • Posts: 82908
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #223375

It says that you're using "my_data" and that there is no "my_data" custom field configured on your website.
Please make sure that you use the exact same name as you've set in the column name of your custom field.

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

  • Posts: 36
  • Thank you received: 0
8 years 11 months ago #223903

If I do this ?

    $orderClass = hikashop_get('class.order');
    $order = new stdClass();
    $order->order_id = $data->order_id;
    $order->donation = $_SESSION['donation'];
    $orderClass->save($order);

Last edit: 8 years 11 months ago by nicolas. Reason: please use the code tags in your messages on the forum

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

  • Posts: 82908
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #223926

Yes, you can do that, if you have a custom order field with the column name "donation"

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

  • Posts: 36
  • Thank you received: 0
8 years 11 months ago #224008

the order field with the column name 'donation' is already set in the line 4 no ?

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

  • Posts: 82908
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #224017

Yes.

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

  • Posts: 36
  • Thank you received: 0
8 years 11 months ago #224129

I don't understand..
It doesn't work.

If the column name 'donation' is set in the line 4 then this code should work no ?

  $orderClass = hikashop_get('class.order');
    $order = new stdClass();
    $order->order_id = $data->order_id;
    $order->donation = $_SESSION['donation'];
    $orderClass->save($order);

Last edit: 8 years 11 months ago by nicolas.

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

  • Posts: 82908
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #224147

Hi,

So are you sure that you have something in

$_SESSION['donation']
where you have that code ?
Because the rest of the code is definitely correct.

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

  • Posts: 36
  • Thank you received: 0
8 years 11 months ago #224219

Yes because I can display it.
It's the value that the client put in the donation input in the command page.

I made another test.

$order->donation = 42;

but I have the same error where the donation column is unknown...

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

  • Posts: 82908
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #224223

So did you create a custom field of the table "order" and with the column name "donation" like I said before ?
Otherwise, you won't be able to save anything in it.

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

  • Posts: 36
  • Thank you received: 0
8 years 11 months ago #224336

No i didn't.
I read again but I don't find how can I create it ?

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

  • Posts: 82908
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #224347

Hi,

Go in the menu Display>Custom fields, click on the "new" button and select the "order" choice in the "table" setting.
Note that this is only available with the Business edition of HikaShop.

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

  • Posts: 36
  • Thank you received: 0
8 years 11 months ago #224476

Thank you

To use it I just do for example

echo $order->donation;

?

I tried this in the order_status_notification file but it display nothing.
And to edit the total in the database I can use the previous code to modify it ?

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

  • Posts: 82908
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #224507

It should be:
<?php echo $order->cart->donation; ?>
in the HTML version of the email.

Normally, to have the total take it into account, you would have to develop a plugin like I said previously:
www.hikashop.com/forum/checkout/880481-c...ion-line.html#221354
Otherwise, it require code modifications a bit everywhere in order to take into account the donation.

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

Time to create page: 0.080 seconds
Powered by Kunena Forum