Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @iamwpuser

    Thanks for reaching out!

    I understand that you want to customize the code snippet on this link to add to cart only one time, and, if deleted from cart not to be added again, correct?

    As stated on that page that we are unable to provide support for customizations under our? Support Policy. However, I’ll keep this thread open for a bit to see if anyone from the community can lend a hand.

    If you have any other questions related to development or custom coding, don’t hesitate to reach out to some of the great resources we have available for support. The WooCommerce community is filled with talented open-source developers, and many of them are active on the channels listed below:

    Hope this helps!

    Thread Starter iamwpuser

    (@iamwpuser)

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

    I have placed this code in my theme https://ibb.co/WgB0TP9 , it is working but I have some errors in logs every day,

    [07-Apr-2023 13:15:33 UTC] PHP Fatal error: Uncaught Error: Call to undefined function WC() in /home//wp-content/themes/child/functions.php:33
    Stack trace:

    0 /home//wp-includes/class-wp-hook.php(308): add_product_to_cart()

    1 /home//wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()

    2 /home//wp-includes/plugin.php(517): WP_Hook->do_action()

    3 /home//wp-includes/template-loader.php(13): do_action()

    4 /home//wp-blog-header.php(19): require_once(‘/home/x…’)

    5 /home//index.php(17): require(‘/home/x…’)

    6 {main}

    thrown in /home//wp-content/themes/child/functions.php on line 33

    Saif

    (@babylon1999)

    Hello @iamwpuser,

    [07-Apr-2023 13:15:33 UTC] PHP Fatal error: Uncaught Error: Call to undefined function WC() in /home//wp-content/themes/child/functions.php:33

    The error message you’re seeing essentially tells us that your site doesn’t recognize the WC() function. This could mean that either WooCommerce isn’t installed on your site, or the function itself has become deprecated, although I don’t think that’s the case.

    These kinds of problems are usually caused by a conflict with another plugin or your theme. The best way to determine this is by:

    • Temporarily switch your theme to Storefront
    • Disable all plugins except for WooCommerce
    • Repeat the action that is causing the problem

    If you’re not comfortable doing all of this on the live version of your site, you can create a staging environment using WP-STAGING.

    If you’re not seeing the same problem after completing the conflict test, then you know the problem was with the plugins and/or theme you deactivated. To figure out which plugin is causing the problem, reactivate your other plugins one by one, testing after each, until you find the one causing conflict. You can find a more detailed explanation on how to do a conflict test here.

    Let us know how it goes!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Automatically add product to cart on visit only one time’ is closed to new replies.