Discrepancy between Order notifications

  • Posts: 12
  • Thank you received: 1
1 year 5 months ago #353199

-- HikaShop version -- : 4.7.1
-- Joomla version -- : 4.3.2
-- PHP version -- : 7.4

Dear support,
I'm working on my first project with Hikashop Business and I'm quite happy with it.

I need your help to understand why admin emails are different from user ones:
I use the same code for both:

    <p><strong>ID: </strong>{VAR:order.order_id}</p>
    <p><strong>Date: </strong><?php echo hikashop_getDate($data->order_created); ?></p>
    <p><strong>Total: </strong><?php echo round($data->cart->order_full_price, 2); ?> €</p>
    <p><strong>Status: </strong><?php echo $data->mail_status; ?></p>
    <p><strong>Email:</strong> {VAR:customer.user_email}</p>

I have "Order administrator notification" for shop owners that returns:

ID: 30
Date: 07-07-2023 15:57
Total: 1 €
Status: Created


I have "Order status notification" for users that returns:

ID: 30
Date: Notice: Undefined property: stdClass::$order_created in media/com_hikashop/mail/order_status_notification.html.modified.php on line 25
Total: 1 €
Status: Confirmed

  1. Why doesn't the date script for users work? If I remove the php error show, the date is blank
  2. Why admin status is Created instead of Confirmed?
  3. Why does the € format show 1 € instead of 1,00 € ?

Kindest regards
Lorenzo

Last edit: 1 year 5 months ago by LorenzoC.

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

  • Posts: 83017
  • Thank you received: 13400
  • MODERATOR
1 year 5 months ago #353204

Hi,

1. $data contains the data of the order being saved to the database. When the order administrator notification email is sent, the order is being created and thus $data contains all the order data. When the order status notification email is sent, the order status is being updated from created to updated, and so only the data which is being modified is available in $data. In that second case, the whole data is available in $data->cart

2. Because the email is sent when the order is created, not when it is being confirmed. HikaShop sends 4 emails:
- the "order creation notification" to the user when the order is created
- the "order admin notification" to the admin when the order is created
- the "order status notification" to the user when the order status is changed automatically from "created" to "confirmed" by a payment method receiving a notification of payment or when you manually change the status of an order and activate the nofitication of the user
- the "payment notification" to the admin when a payment method receives a payment notification. It will even send it when the payment is refused of when there is a problem with the notification so that the admin can check if there is something wrong

3. The round function returns the number as a float:
www.php.net/manual/en/function.round.php
Then, you do an echo on that float and in that case, PHP itself displays it the way it want.
If you want a display where you have more control on the format, you want to use number_format to convert the float to a string before the echo :
www.php.net/manual/en/function.number-format.php

The following user(s) said Thank You: LorenzoC

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

Time to create page: 0.048 seconds
Powered by Kunena Forum