fails to create new cart for a custom product

  • Posts: 2
  • Thank you received: 0
11 years 8 months ago #92473

Hello,

my goal is to create an application where the user should be able to assemble the product with ingredients of his/her choice.

I'm currently facing a Problem. How can I create a new cart for my session from my php-file. I can create other database entries but it fails to create a cart.

$id= session_id();
$cart = '\'cart\'';
$query = "INSERT INTO jxe3i_hikashop_cart (user_id,session_id,cart_modified,cart_type) VALUES (0, '". $id."',$timestamp,$cart)";
mysql_query($query);

When I write this sql command direktly in phpmyadmin it works.

The code samples from the developer documentation also failed in my php file.
http://www.hikashop.com/en/support/documentation/62-hikashop-developer-documentation.html#code


Could you please help me.

Thank you

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

  • Posts: 13201
  • Thank you received: 2322
11 years 8 months ago #92541

Hi,

I tried the code:

$cartClass = hikashop_get('class.cart');

$cartClass->update($product_id,$quantity);
On my end and it's working fine, when displaying the page where I placed the code, a product is added to the cart.

Are you sure that you have set a valid product id, and a valid quantity ?

PS: a cart is created only when there is products inside, else it's not saved.

Last edit: 11 years 8 months ago by Xavier.

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

  • Posts: 2
  • Thank you received: 0
11 years 8 months ago #92574

Hi,

problem solved.
Your PS helped. :laugh:

Thank you

Last edit: 11 years 8 months ago by Stine.

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

Time to create page: 0.067 seconds
Powered by Kunena Forum