Support » Plugin: WooCommerce » Can not add product to cart

  • Resolved ngothoai

    (@ngothoai)


    Hi admin, i used to id product for add to cart,and using this:
    WC()->cart->add_to_cart( $product_id );
    But, when i go to page cart, it is empty, (not login).
    Pls check, and can you help me
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Thomas Shellberg

    (@shellbeezy)

    Automattic Happiness Engineer

    @ngothoai – Please paste in the full code, please? Are you using the code from here?

    https://docs.woocommerce.com/document/automatically-add-product-to-cart-on-visit/

    I just tested it and it worked fine; even when I remove the product from the cart(not logged in), it is re-added when the page reloads.

    I would check for any caching on the site(make sure your Cart and Checkout pages are exempt from caching) and test with a default theme(Storefront).

    Plugin Support Kenin

    (@kbassart)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can not add product to cart’ is closed to new replies.