[Skip to main content](#vessel-content)

#   fails to create new cart for a custom product

##

- **[Stine](/forum/user/14096-stine "View Stine's Profile")**
- [![Stine's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/14096-stine "View Stine's Profile") Topic Author
- [ Offline](/forum/user/14096-stine)

Less More

- Posts: 2
- Thank you received: 0
-
-

13 years 8 months ago [\#92473](#92473) by [Stine](/forum/user/14096-stine "View Stine's Profile")  *[fails to create new cart for a custom product](/forum/4-how-to/78836-fails-to-create-new-cart-for-a-custom-product#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&#95;id(); $cart = '&#92;'cart&#92;''; $query = &quot;INSERT INTO jxe3i&#95;hikashop&#95;cart (user&#95;id,session&#95;id,cart&#95;modified,cart&#95;type) VALUES (0, '&quot;. $id.&quot;',$timestamp,$cart)&quot;; mysql&#95;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.  Could you please help me.  Thank you")* was created by *[Stine](/forum/user/14096-stine "View Stine's Profile")*

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)[ www.hikashop.com/en/support/documentatio...umentation.html#code](http://www.hikashop.com/en/support/documentation/62-hikashop-developer-documentation.html#code)

Could you please help me.

Thank you

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc4ODM2LWZhaWxzLXRvLWNyZWF0ZS1uZXctY2FydC1mb3ItYS1jdXN0b20tcHJvZHVjdD90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

13 years 8 months ago -  13 years 8 months ago [\#92541](#92541) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[fails to create new cart for a custom product](/forum/4-how-to/78836-fails-to-create-new-cart-for-a-custom-product#92541 "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&#95;id(); $cart = '&#92;'cart&#92;''; $query = &quot;INSERT INTO jxe3i&#95;hikashop&#95;cart (user&#95;id,session&#95;id,cart&#95;modified,cart&#95;type) VALUES (0, '&quot;. $id.&quot;',$timestamp,$cart)&quot;; mysql&#95;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.  Could you please help me.  Thank you")*

Hi,

I tried the code: Code:

$cartClass = hikashop_get('class.cart'); $cartClass-&gt;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: 13 years 8 months ago by [Xavier](/forum/user/4105-xavier "View Xavier's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc4ODM2LWZhaWxzLXRvLWNyZWF0ZS1uZXctY2FydC1mb3ItYS1jdXN0b20tcHJvZHVjdD90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

- **[Stine](/forum/user/14096-stine "View Stine's Profile")**
- [![Stine's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/14096-stine "View Stine's Profile") Topic Author
- [ Offline](/forum/user/14096-stine)

Less More

- Posts: 2
- Thank you received: 0
-
-

13 years 8 months ago -  13 years 8 months ago [\#92574](#92574) by [Stine](/forum/user/14096-stine "View Stine's Profile")  Replied by *[Stine](/forum/user/14096-stine "View Stine's Profile")* on topic *[fails to create new cart for a custom product](/forum/4-how-to/78836-fails-to-create-new-cart-for-a-custom-product#92574 "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&#95;id(); $cart = '&#92;'cart&#92;''; $query = &quot;INSERT INTO jxe3i&#95;hikashop&#95;cart (user&#95;id,session&#95;id,cart&#95;modified,cart&#95;type) VALUES (0, '&quot;. $id.&quot;',$timestamp,$cart)&quot;; mysql&#95;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.  Could you please help me.  Thank you")*

Hi,

problem solved.
Your PS helped. :laugh:

Thank you

Last edit: 13 years 8 months ago by [Stine](/forum/user/14096-stine "View Stine's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc4ODM2LWZhaWxzLXRvLWNyZWF0ZS1uZXctY2FydC1mb3ItYS1jdXN0b20tcHJvZHVjdD90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.095 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
