get order total and id in after_end

  • Posts: 60
  • Thank you received: 8
11 years 5 months ago #68733

I am trying to use a third party affiliate tracking script on hikashop.

I need to get the order id and order total in the script I am putting in the after_end.php override file.

Right now I have the following cod but it is not working:

$order_id = $this->order->order_number;
$order_total = $this->order->order_full_price;

echo "<script type='text/javascrip' src='//tags.mediaforge.com/js/954/?orderNumber=${order_id}&price=${order_total}'></script>"


Any thoughts on what I need to change on my code to get the order id and order total into my script would be great. Thanks.


Ecommerce expert for hire. DaveKarlsven.com

I love helping businesses make lots of money online.

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
11 years 5 months ago #68886

That's the correct way of doing it.
Are you sure that you're editing the view file for the correct template ?
Do you have an error ?

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

  • Posts: 60
  • Thank you received: 8
11 years 5 months ago #69724

I just can't get the Order number and order total into the variables for my script. When I run the script I just get the following as a result:

tags.mediaforge.com/js/954/?orderNumber=&price=

Order Number and Price are blank.

For some reason this is not putting anything in the $order_id field.

By the way, I am using the Authorize.net payment plugin. Would that effect getting the order id and order total in any way?

Do I need to change the way I get the values at the end of the order when using the Authorize.net plugin?

$order_id = $this->order->order_number;
$order_total = $this->order->order_full_price;


Ecommerce expert for hire. DaveKarlsven.com

I love helping businesses make lots of money online.

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
11 years 5 months ago #69896

It means that there is no order_id parameter in your after_end URL as it should.
Not usre what you're doing to reach that page.

Anyway, you can try to load the order manually like that:
$app = JFactory::getApplication();
$order_id = $app->getUserState('com_hikashop.order_id');
$orderClass = hikashop_get('class.order');
$this->order = $orderClass->loadFullOrder($order_id);

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

  • Posts: 60
  • Thank you received: 8
11 years 5 months ago #71932

How do we get the Order Subtotal into the url?

This is the code I have thus far but there are Two problems I am still facing. 1. The order full price is still not showing up in my URL, and I don't know how to also get the Order Subtotal (Total Before shipping and taxes) into a variable that I can put into the tracking URL:

Any Help you can give me on the below code to get the Order full price to show up and the order subtotal also into the url, would be really appreciated. (By the way, we are using the Authorize.net payment plugin.)

$app =& JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

$order_id = $app->getUserState('com_hikashop.order_id');
$orderClass = hikashop_get('class.order');
$this->order = $orderClass->loadFullOrder($order_id);


$order_total = $this->order->order_full_price;


echo "<script type='text/javascript' src='//tags.mediaforge.com/js/954/?orderNumber=${order_id}&price=${order_total}'></script>";


Ecommerce expert for hire. DaveKarlsven.com

I love helping businesses make lots of money online.

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
11 years 5 months ago #72142

1. Try like that:
$this->order = $orderClass->loadFullOrder($order_id,true,false);
instead of:
$this->order = $orderClass->loadFullOrder($order_id);

2. The subtotal would be:
$this->order->order_full_price + $this->orderorder->order_discount_price - $this->orderorder->order_shipping_price - $this->orderorder->order_payment_price

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

  • Posts: 15
  • Thank you received: 0
6 years 4 months ago #282373

The return is an array or object?


:)


fFull-stack

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
6 years 4 months ago #282376

Hi,

$this->order is an object. You can see a rough example here:
www.hikashop.com/support/documentation/156
But the best is to do a var_dump/print_r of the variable.

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

Time to create page: 0.079 seconds
Powered by Kunena Forum