return url

  • Posts: 6
  • Thank you received: 0
1 year 2 months ago #349224

-- url of the page with the problem -- : www.padelcabriolo.it

it is possible to indicate in return url the purchased items? (for example using alias url)
i have many items in my shop and i need to know in return url which items has been purchased
can i have and example?

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
1 year 2 months ago #349227

Hi,

Could you explain what the purpose of knowing the items bought is ?
In the default return URL you have the order_id, with that order_id, and a few lines of PHP code it's possible to know all the data of the order, including the data on the products.
What exact code to use and where to place it would depend on what you're trying to achieve.

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

  • Posts: 6
  • Thank you received: 0
1 year 2 months ago #349229

thanks for support.
i use hikashop in order to permit to registered user to buy coin.
I need to know if the user buy items "1 coin" or items "10 coin" because after the succesfull payment i need (with my php code) to add the correct number of coin to the user profile. so i need that the return url is a custom php page (created by myself) because i need with a php code add the coin to the user.
How i can manage this situation?
thanks

Last edit: 1 year 2 months ago by fania.

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
1 year 2 months ago #349235

Hi,

So, which payment plugin are you using ? Normally a "return URL" is where the user is redirected back after paying on the payment gateway. And generally, you don't run code in the "return URL". You run code in the "onAfterOrderUpdate event by checking that $order->order_status is set to "confirmed" and that $order->old->order_status is not "confirmed". That will tell you that the order is currently being confirmed after a successful payment.
What's great with this method is that it should work with any payment method. Even if you manually confirm the orders in the HikaShop backend (after a bank transfer is received for example).
You can read more about how to write a plugin for HikaShop here:
www.hikashop.com/support/documentation/6...r-documentation.html
And more about this event here:
www.hikashop.com/support/documentation/6...l#onAfterOrderUpdate

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

  • Posts: 6
  • Thank you received: 0
1 year 2 months ago #349260

i use paypal pluigin. can i pass in the return url the order id by parameter?
in the return url php page how i can extract the product ordered knowing the order id?

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
1 year 2 months ago #349262

You can add the order id in the return URL by adding the tag {order_id} to the return URL.
On the return URL, you can use the loadFullOrder method of class.order to get all the data of the order, including the products in the products array attribute. You can see an example code in our developer documentation:
www.hikashop.com/support/documentation/6...umentation.html#code

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

  • Posts: 6
  • Thank you received: 0
1 year 1 month ago #349607

good morning
in the return page i use this code but i don't show the prodcuts name. what is the error?

$orderClass = hikashop_get('class.order');

$app =& JFactory::getApplication();
$order_id = $app->getUserState('com_hikashop.order_id');

$order = $orderClass->loadFullOrder($order_id, true, false);

foreach($order->products as $product) {
echo $product->product_name.'<br/>';
}

thanks

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
1 year 1 month ago #349609

Hi,

The issue is probably that you're not able to retrieve the order_id for some reason.
The code:

$app =& JFactory::getApplication();
$order_id = $app->getUserState('com_hikashop.order_id');
will retrieve the order_id from the user session. This variable is normally set by HikaShop when it creates the order, before redirecting to the payment gateway.
If the user session changes for whatever reason between the order creation and the redirection to the return page, it's possible this will set $order_id to "null".
You added the tag {order_id} to the return URL to add the order_id in the URL.
For example, suppose you've used the return URL :
https://www.hikashop.com/extensions/hika-business.html?my_variable={order_id}
In that case, you can use this code to get the order_id:
$order_id = (int)$_REQUEST['my_variable'];

Last edit: 1 year 1 month ago by nicolas.

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

  • Posts: 6
  • Thank you received: 0
11 months 3 weeks ago #351232

ok thanks now i can read order_id in the return page
but i still can't detect the product ordered, the following code don't work i don't see anything print on the screen

$orderClass = hikashop_get('class.order');
$order = $orderClass->loadFullOrder($order_id, true, false);
foreach($order->products as $product) {
echo $product->product_name.'<br/>';
}

thanks

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
11 months 3 weeks ago #351234

Hi,

It should be order_product_name and not product_name

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

  • Posts: 6
  • Thank you received: 0
11 months 3 weeks ago #351296

ok thanks
in order to know the price of the items in order what is the variable to read?
thanks

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
11 months 3 weeks ago #351300

It's $product->order_product_price
The tax is in $product->order_product_tax and the quantity in $product->order_product_quantity

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

Time to create page: 0.067 seconds
Powered by Kunena Forum