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

#   CartClass add product in empty cart nothing happen

##

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

Less More

- Posts: 32
- Thank you received: 2
-
-

11 years 2 weeks ago -  11 years 2 weeks ago [\#218681](#218681) by [PortobelloDigital](/forum/user/13368-portobellodigital "View PortobelloDigital's Profile")  *[CartClass add product in empty cart nothing happen](/forum/3-bug-report/880116-cartclass-add-product-in-empty-cart-nothing-happen#218681 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.5 -- PHP version -- : 5.6.x  Hi,  I want to add product in cart via hikashopCartClass-&gt;update (like:   www.hikashop.com/support/support/documen...umentation.html#code ). If cart got products (1 or more) this work, if i delete all products then try again it work but on a fresh session nothing happen.")* was created by *[PortobelloDigital](/forum/user/13368-portobellodigital "View PortobelloDigital's Profile")*

-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.4.5
-- PHP version -- : 5.6.x

Hi,

I want to add product in cart via hikashopCartClass-&gt;update (like: [ www.hikashop.com/support/support/documen...umentation.html#code](http://www.hikashop.com/support/support/documentation/62-hikashop-developer-documentation.html#code)).
If cart got products (1 or more) this work, if i delete all products then try again it work but on a fresh session nothing happen.
Code:

if(!@include_once(rtrim(JPATH_ADMINISTRATOR,'/').'/components/com_hikashop/helpers/helper.php')){ return false; } $productId = 1; // this product exist in hikashop $cartClass = hikashop_get('class.cart'); $datas = array( 'item' =&gt; array('spec' =&gt; 'somevalue') ); JRequest::setVar('data',$datas); $check = $cartClass-&gt;update($productId,1,1,'product',true,true);

Last edit: 11 years 2 weeks ago by [PortobelloDigital](/forum/user/13368-portobellodigital "View PortobelloDigital's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84ODAxMTYtY2FydGNsYXNzLWFkZC1wcm9kdWN0LWluLWVtcHR5LWNhcnQtbm90aGluZy1oYXBwZW4/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

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

Less More

- Posts: 32
- Thank you received: 2
-
-

11 years 2 weeks ago [\#218824](#218824) by [PortobelloDigital](/forum/user/13368-portobellodigital "View PortobelloDigital's Profile")  Replied by *[PortobelloDigital](/forum/user/13368-portobellodigital "View PortobelloDigital's Profile")* on topic *[CartClass add product in empty cart nothing happen](/forum/3-bug-report/880116-cartclass-add-product-in-empty-cart-nothing-happen#218824 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.5 -- PHP version -- : 5.6.x  Hi,  I want to add product in cart via hikashopCartClass-&gt;update (like:   www.hikashop.com/support/support/documen...umentation.html#code ). If cart got products (1 or more) this work, if i delete all products then try again it work but on a fresh session nothing happen.")*

After some further investigation, i noticed on a fresh session, when using a **plgHikashop**, calling Code:

$cartClass-&gt;get($cart-&gt;cart_id)

in Code:

onBeforeCartUpdate

function, prevent adding product.
Using Code:

$cartClass-&gt;get($cart-&gt;cart_id,true)

fix this.

Topic can now be closed.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84ODAxMTYtY2FydGNsYXNzLWFkZC1wcm9kdWN0LWluLWVtcHR5LWNhcnQtbm90aGluZy1oYXBwZW4/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) 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.046 seconds

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