Hikashop checkout API

  • Posts: 7
  • Thank you received: 0
12 years 5 months ago #52153

I referred to the developer documentation I could only find the samples code provided to load product, add a product to cart, load the order details. But, it does not have the checkout process code samples. Which class should i get? help me out!!!

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

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
12 years 5 months ago #52164

What do you mean by "checkout process code" ? What are you trying to achieve ?

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

  • Posts: 7
  • Thank you received: 0
12 years 5 months ago #52165

Thanks for the reply. By the way, I am trying to write my own hikashop services for an Android App. Integrating Hikashop e-commerce into Android App.

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

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
12 years 5 months ago #52166

Well, there is lot of code to handle the checkout.
The main part is located in the file components/com_hikashop/controllers/checkout.php so I invite you to look there for the code you need based on what you want to do.

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

  • Posts: 7
  • Thank you received: 0
12 years 5 months ago #52170

There's lot of code. How do i proceed from here?
Say
1. Load a product:
$productClass = hikashop_get('class.product');
$product=$productClass->get($product_id);

2. Add/Update product(s);
$cartClass = hikashop_get('class.cart');
$cartClass->update($product_id,$quantity);

3. Currently, there's no payment integration for the Android App. Its a free product. How do i checkout from here skipping payment integration. Also, i have disabled payment gateway integration in the Hikashop Backend. Do i have to load this class components/com_hikashop/controllers/checkout.php But how?

Thanks.

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

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
12 years 5 months ago #52228

What you're interested in is in the function after_confirm of that file.
That's where the current cart is converted into an order and then the payment plugins are triggered to get the HTML form which will then redirect the user to the payment platform.

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

  • Posts: 7
  • Thank you received: 0
12 years 5 months ago #52453

Hey Nikolas, Thanks for that, i browsed through that code. How do i call this file in my application. Actually, I dont want HTML form to be loaded. I would require a json output from the hikashop, as its an Android App. Later, I will mimic a HTML form in the android app and redirect the user for payment platform. I was wondering do we have any method like say:
$cartClass = hikashop_get('class.cart');
$cartClass->AddToCart($parameters);

Last edit: 12 years 5 months ago by nuthan.

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

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
12 years 5 months ago #52456

There is no method to call that file.
Just include the helpers/helper.php file of the backend in order to load HikaShop's library and then load the controller file.

For the add to cart, you can do like that:
$cartClass = hikashop_get('class.cart');
$cartClass->update($product_id,$quantity);

HikaShop doesn't output any json.

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

  • Posts: 7
  • Thank you received: 0
12 years 5 months ago #52458

Thanks again..., I have included helpers/helper.php as per the Documentation . Sorry, i did not mean Add_to_cart method(I am aware update() method does that), instead i was looking for
$cartClass = hikashop_get('class.cart');
$cartClass->checkout($parameters); //something like this.
or
$cartClass->generateOrder($parameters); //something like this.
or
$cartClass->PaymentProcess($parameters); //something like this.

I am also aware hikashop does not return json objects. Indeed, I am looking for php multi-dimensional arrays(so does $cartClass->update() method).

Last edit: 12 years 5 months ago by nuthan.

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

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
12 years 5 months ago #52460

For generateOrder, you can do like that:

$obj = null;
//add params to $obj
$class= hikashop_get('class.order');
$class->save($obj);

There are no methods for checkout or PaymentProcess

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

  • Posts: 7
  • Thank you received: 0
12 years 5 months ago #52464

$order object in save() method has $obj many parameters. Do we have any methods that returns $order object.
Thanks.

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

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
12 years 5 months ago #52465

$class= hikashop_get('class.order');
$obj=$class->get($order_id);

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

  • Posts: 7
  • Thank you received: 0
12 years 5 months ago #52471

As per Hikashop documentation

get($order_id);
method is to load the generated order. I would not have the $order_id unless cart is processed to an order. I am totally confused. I think
$obj = null;
//add params to $obj
$class= hikashop_get('class.order');
$class->save($obj);
would the required function. All i need is $obj. get($order_id); does not return the $obj.

Last edit: 12 years 5 months ago by nuthan.

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

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
12 years 5 months ago #52473

There are no methods which would convert a cart to an order.
That is done in only one place:
in the function after_confirm of components/com_hikashop/controllers/checkout.php

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

Time to create page: 0.078 seconds
Powered by Kunena Forum