• rangelrmorais

    (@rangelrmorais)


    Hi, some products are getting negative stock quantity( -1 -2 -3 -4 -5 and even -6 ) and i dont know why.

    I have the latest versions of WC and WP

Viewing 15 replies - 1 through 15 (of 26 total)
  • Plugin Author James Golovich

    (@jamesgol)

    The first step is to make sure you have cleared all of your old WooCommerce sessions/carts. Generally this happens when items are added to carts before this plugin is activated

    Thread Starter rangelrmorais

    (@rangelrmorais)

    Hi @jamesgol, thanks for the quick reply!

    In fact, i use the “WooCommerce – Abandon Cart Lite” to clear all carts, but even cleared, the itens dont change back. All the store has only one item to sell, so i guess this is cleary a bug, since there is no way to someone add more than one item to the cart.

    Plugin Author James Golovich

    (@jamesgol)

    Please try to clear the WooCommerce sessions manually before doing anything, then at least you are starting at a clean slate.

    From the WordPress backend the button is under WooCommerce->Status->Tools->Clear all Sessions

    Thread Starter rangelrmorais

    (@rangelrmorais)

    Ok, it made the ghost carts go away, but the products still with the negative state and out of the stock. I just changed it back to In Stock 1 .

    off: about the other issue in the other topic. I guess that would solve all my problems.

    Plugin Author James Golovich

    (@jamesgol)

    Can you explain your actual needs related to the other topic? Using this plugin and an abandoned cart plugin are kind of opposite of each other.

    Thread Starter rangelrmorais

    (@rangelrmorais)

    Let me explain:

    I have a shop that 99,99% of the products stock is 1.

    Every time a product goes live, people come to the site and try to buy.

    They even wait for the timer runs out to see if the product is avaliable or if it was purchased by someone else.

    In the past it was ok to return the products to stock manualy after the people abandon their itens on their carts. But now this is becoming “not ok”.

    Then i notice that the plugin just clear the cart session if the owner is on the page or returns after the time runs out.

    So im searching for days for a way to clear the cart session after the owner of the cart goes out the site. Maybe some js + php would do it.

    Im thinking in trigger the function that clear the cart with a JS who detect the page is closed. But im no expert on this things and im bit of lost now.

    Plugin Author James Golovich

    (@jamesgol)

    The timer for expiring items is really the best way to handle this. You can’t count on code to detect when a user navigates away from a site, if someone just closes their browser/tab, turns off their devices, loses power, loses connectivity, etc. You just can’t count on the behavior.

    Thread Starter rangelrmorais

    (@rangelrmorais)

    Sure it is, but the timer today is kinda tricky because it depends of the user to remain on the site to expire. Right?

    Plugin Author James Golovich

    (@jamesgol)

    No the countdown timer is only for display. The expiration time is saved with the item and once the time has passed the item goes back into stock.

    Thread Starter rangelrmorais

    (@rangelrmorais)

    Yes, but the item just go back to the stock if the user that have the item on his cart:

    A) stays on the site till the countdown ends
    B) returns to the site after the countdown ends

    Im using this function right now:

    add_action( 'init', 'woocommerce_clear_cart_url' );
    function woocommerce_clear_cart_url() {
    global $woocommerce;
    
    if ($_SERVER['REQUEST_URI'] === '/') { 
        $woocommerce->cart->empty_cart(); 
    }
    }

    I just need to find how trigger this at the time the user leaves the page.

    Im trying javascript beforeunload, but i dont want an dialog message.

    I’ll keep trying this javascript for some time, and then move to ajax if the js doesnt work.

    Plugin Author James Golovich

    (@jamesgol)

    You cannot trust/depend on code executing when a users leaves the page, it’s just not a reliable method to do this.

    Setting the expiration time to a reasonable value is going to be the most reliable method for making sure items expire and are available to others for purchase.

    Please test this out to see for yourself. Set the expiration time to something like 5 minutes. Create an item that has 1 quantity in stock. Open the product in both browsers. In one browser add the item to the cart then close that browser completely. Reload the page in the other browser to see the item is unavailable. Reload the product page after 5 minutes and see that the item is now available even though the other browser never re-visited the page.

    Thread Starter rangelrmorais

    (@rangelrmorais)

    Hi @jamesgol, im sorry but your wrong.

    I made an local wordpress instalation, two plugins: Woocommerce and yours and the storefront theme.

    I’ve created the product and setted the timer to 5 minutes.

    With one browser in private mode, i clicked “buy” on the product and the timer started.

    Then i close the browser and waited for more than 5 minutes. When i came back, with another sesion of the private mode, the product still doesnt got avaliable.

    This is the message it was showing: This item is not available at this time due to pending orders. ( ps: i didnt proceed to the checkout, just added on cart ).

    Then i came to the backend and saw that the product was in stock, but also was on someone’s cart.

    Resume: the product doesnt come back to the stock and leave the cart after the timer has ended.

    Plugin Author James Golovich

    (@jamesgol)

    If it is not working that way then you have a configuration error on your site. Do you have item expiration enabled (it is disabled by default)? Please take a screenshot of the Cart stock reducer settings

    Thread Starter rangelrmorais

    (@rangelrmorais)

    Plugin Author James Golovich

    (@jamesgol)

    How about the specific item configuration? Something is definitely not working in the expected way.

Viewing 15 replies - 1 through 15 (of 26 total)
  • The topic ‘Products getting -5 on stock’ is closed to new replies.