• Resolved MiKeZZa

    (@mikezza)


    Hello, on the so called URL you see an empty ‘quantity’ (called Aantal) field when you add a product to the cart.

    The reason is in the code:

    <div class="quantity hidden">
    		<input type="hidden" id="quantity_5e727dfbcff2e" class="qty" name="cart[22785dd2577be2ce28ef79febe80db10][qty]" value="1">
    	</div>

    But can somebody tell me why this is caused? I can’t find the setting anywhere, but I don’t think it’s default behaviour… Right?

    The page I need help with: [log in to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Working for me, so it looks like you fixed it.

    If not, please say which product is in the cart.

    Thread Starter MiKeZZa

    (@mikezza)

    I’ve looked at the first of the two products and that doesn’t work for me.

    The tag: <div class="quantity hidden"> is coming from
    /plugins/woocommerce/templates/global/quantity-input.php
    and whether or not it shows is governed by a stock check of some sort. Unfortunately I’m unable to figure out the combination of stock parameters which will trigger the line. It doesn’t seem to be the “sold individually” checkbox.

    Please say if you have “manage stock” checked for that product, whether backorders are allowed and what the stock level for it is.

    Hi

    Seems you check Individually purchase options for some product or use a plugin to do it,

    Please check product options and if not solved add following line of code to active theme/child theme functions.php:

    add_filter( 'woocommerce_is_sold_individually', '__return_false', 999, 2 );

    Good luck

    Thread Starter MiKeZZa

    (@mikezza)

    Hi @yazdaniwp, yes it’s coming from the plugin that @lorro said. But if I add your code to functions.php, what can I expect then?

    The code will force that “sold individually” is not set for the product. Even if it is, that would result in a visible read-only “1” in the quantity column, not in the <div class="quantity hidden"> that we are seeing in the markup.

    Please say if you have “manage stock” checked for that product, whether backorders are allowed and what the stock level for it is.

    This filter, Disable Individually for all products.

    Absolutely this problem not from any plugin,

    Or you can do this:
    https://docs.woocommerce.com/document/managing-products/#section-6

    Actually you active Sold Individually option, You can test and you see that users just can add product to cart one time in every order.

    Good luck

    Thread Starter MiKeZZa

    (@mikezza)

    Adding that code to functions.php doesn’t change anything. It’s there now, but nothing has changed.

    The properties of the product called above is:

    View post on imgur.com

    So that’s correct I guess? The case here is that a product can have stock quantity of 1 or a little more. But it’s rental so it’s not sold out after it is ‘sold’. So that’s the case here; the quantity plugin is there to don’t let people order a higher number of products than products that are available.

    lorro

    (@lorro)

    I’m not clear. If its never sold out, stock is infinite and there is no need for stock management. I can’t see any system to set the hire date. Later your post mentions a limit.

    I think for the ring hire product, the sold individually checkbox should be checked on the inventory tab.

    What is the quantity plugin that you are using?

    Thread Starter MiKeZZa

    (@mikezza)

    OK, now I’ve deleted all kind of plugins that are doing anything with stock.

    The case is this: https://faesentertainment.com/product/klauterhelling/

    This product is 2 times in stock and it is for rental. So you can rent it 0, 1 or 2 times, not more than 2. But I can’t set the stock to 2, because of that it’s not a problem when somebody else wants to rent it on an other day.

    The process here is simple; people fill there cart and ‘checkout’. During checkout they pick a date and the rental company contacts people if something is rented on that day already and they offer an alternative.

    That’s the thing I want to cover here.

    Somebody has an idea?

    lorro

    (@lorro)

    I see that both the bokring and the klauterhelling are now not showing a blank/hidden field in the cart, so it would seem that your quantity plugin was causing that, and therefore the problem in your top post is resolved.

    You could consider setting up the items as variable products where the variation is the date. Set stock management=on, and stock=2. Of course there are many possible dates, so when you have set up one date variation as a sample, export the product as a csv file. Add more dates in your spreadsheet, and reimport. The process is explained here:
    https://docs.woocommerce.com/document/product-csv-importer-exporter/#

    This method will ensure that the item cannot be rented more than twice on the same day, and that the customer will not be frustrated by renting something only to be told it is not available. There would be less trouble with refunding money for unavailable items, or asking for a supplement where the alternative was a different price.

    If some stock is being rented through another channel, then there is still a possiblity that a customer could rent something that is not available.

    Picking a past date is possible but I think this would be rare.

    There are plugins that will allow a date-picker field on the product page.This would be more user-friendly than doing it on the checkout page. Look for “add-on” type plugins. However, this type of plugin does not allow stock management.

    For a better solution, this could be a case for getting a custom plugin. You can get an estimate from someone here:
    https://woocommerce.com/experts/
    or post a job:
    https://jobs.wordpress.net/

    Thread Starter MiKeZZa

    (@mikezza)

    Hi @lorro, thank you very much for your extensive reply.

    I think that your story makes sense but that’s not what my customer is looking for for some reasons (i.e. many rents from offline channels and a customer isn’t paying in front, but afterwards).

    I think I fixed it now; I’ve activated ‘product-quantity-for-woocommerce’ and changed something in the plugin code in a particular PHP-file. But now the question that I have to find out is how to maintain this. I now how to make changes to a child theme, but a child plugin is not what I’ve ever seen. So I have to check what I can do for this case. I don’t want this to be overwritten.

    lorro

    (@lorro)

    I think all you’ll need to do is make a copy in another directory, for example:
    wp-content/plugins/product-quantity-for-woocommerce-custom/…

    Alter the plugin file name in the copy from
    product-quantity-for-woocommerce.php
    to
    product-quantity-for-woocommerce-custom.php
    (file name must match the directory name except for .php)

    Alter the value for Name in line 3 of
    product-quantity-for-woocommerce-custom.php
    so you can tell them apart in the list of plugins.

    Deactivate the original and activate the copy.

    If you have the original and the copy activated at the same time it might break your site due to duplicate function names.

    The copy will not be updated.

    Thread Starter MiKeZZa

    (@mikezza)

    Yes, I fixed it!

    Thank you.

    For people who also want to achieve the same thing in the future:

    In includes/templates/quantity-input.php you can find an if + elseif with ‘hidden’. I’ve changed the if to make it always false (1 == 2) and then you always get the elseif value and then it works great for me.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Quantity in cart is hidden’ is closed to new replies.