News:

Support the VirtueMart project and become a member

Main Menu

Quantity Selector Change Empties Cart for 1 off Items.

Started by saviB, April 22, 2015, 16:01:59 PM

Previous topic - Next topic

saviB

Hello Folks,

VirtueMart 3.0.8

Joomla! 3.4.1

A client has a museum store with many 1 of a kind products. They also sell products with stock.

1. If a user changes the selector number for a 1 of a kind product and adds to cart, a system message states "product out of stock" and adds nothing to the cart.
2. If a 1 of a kind product is added to cart, and the user changes the quantity in the cart, a system message states "product out of stock: Product Name" and empties the cart - making the user thin the product is no longer available.

In config:

In Stock: 1
Booked, ordered: 0
Low Stock Notification: 0
Purchase Quantity Steps: (tried both 1 and blank)
Minimum Purchase Quantity: (tried both 1 and blank)
Maximum Purchase Quantity: (tried both 1 and blank)

Is there a way to configure product stock to avoid this?
Or, is there a method to disable quantity change for products with only 1 in stock?

I made a language change that is a decent work around for this issue in shopping views - so the real problem is in the cart view.




GJC Web Design

ugly hack would be get the stock of the product

if stock of  1 then echo some css to hide the quantity field

you could give the quantity a surrounding div with the product id css id etc
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

saviB

Thanks GJC -

That's a good idea.

So to be sure, this is just the way the VM system is for now - I don't have something incorrectly configured?

saviB

Hey folks, I'm no programmer - but I know what goes where. Any help would be greatly appreciated.

I found an older thread on showing product stock quantity: https://forum.virtuemart.net/index.php?topic=102087.0 Now I need a properly formatted If / THEN for the following:

IF quantity in stock = 1
Then .quantity-box{display:none;} and (first wrapping the update cart code in cart view in a <div> - shown below) .that_new_div{display:transparent;}
AND Show "Only One Available!"

IF quantity in stock > 1
Then .quantity-box{display:(inline or block - whatever is correct);} and (first add a class to the TD below) .that_new_td {display:(inline or block - whatever is correct);}


<td align="right" class="that_new_td"><?php

            if ($prow->step_order_level)
               $step=$prow->step_order_level;
            else
               $step=1;
            if($step==0)
               $step=1;
            ?>
         <input type="text"
               onblur="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
               onclick="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
               onchange="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
               onsubmit="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
               title="<?php echo  vmText::_('COM_VIRTUEMART_CART_UPDATE') ?>" class="quantity-input js-recalculate" size="3" maxlength="4" name="quantity[<?php echo $pkey; ?>]" value="<?php echo $prow->quantity ?>" />

         <button type="submit" class="vmicon vm2-add_quantity_cart" name="updatecart.<?php echo $pkey ?>" title="<?php echo  vmText::_ ('COM_VIRTUEMART_CART_UPDATE') ?>" />

         <button type="submit" class="vmicon vm2-remove_from_cart" name="delete.<?php echo $pkey ?>" title="<?php echo vmText::_ ('COM_VIRTUEMART_CART_DELETE') ?>" />
   </td>