VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: ntunay on October 02, 2012, 22:35:47 PM

Title: stock refresihing / double sale
Post by: ntunay on October 02, 2012, 22:35:47 PM
Hi

i created a product has 1 stock. but if i click two times to add to cart button. it adds two products to cart. it is very big problem because there is only 1 product.
if product has 1 stock. it shoudnt sale two. when i click to add to cart button stock must be '0' untill logout end.

sorry about broken english but it is relly big trouble for me.

besides if i confirmed the cart but didnt finished the proses. ( i mean no credit cart confirm, no sale, stocks is changing)


Title: Re: stock refresihing / double sale
Post by: bytelord on October 02, 2012, 22:37:43 PM
Hi,

http://forum.virtuemart.net/index.php?topic=108215.msg362064#msg362064

But actually you didn't mention your joomla and virtuemart version you are using.

Regards
Title: Re: stock refresihing / double sale
Post by: ntunay on October 02, 2012, 22:50:07 PM
j2.5 vm 2.10
Title: Re: stock refresihing / double sale
Post by: bytelord on October 02, 2012, 23:12:11 PM
did you read the post after all? did you solve it?
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 08:59:19 AM
no i couldnt solve it. The posts dont show a solution for me. they recommend notify option but notify option doesnt stop double order. you can still buy a product twice time which doesnt exist in stock

someone say something about cart.php but i couldnt understand it
Title: Re: stock refresihing / double sale
Post by: bytelord on October 03, 2012, 09:12:19 AM
For me is working. just testing it again. When i click again add-to-cart does not let me to add it twice.
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 09:28:29 AM
i tried again again and again. when i click the add to cart button second time it adds to cart second product. when i click third time. it adds  3 products
please click http://shop.ng-style.com/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=2746&virtuemart_category_id=14 (http://shop.ng-style.com/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=2746&virtuemart_category_id=14)

and see


(by the way. thanks for quick help)
Title: Re: stock refresihing / double sale
Post by: bytelord on October 03, 2012, 09:52:48 AM
Hello,

i think the problem is that you have commend the quantity box controls from product page that includes code for the validation. if you want to hide them it's better to use css and not commend them.

Please test it again with the right configuration and by restoring the lines you commented on the productdetails template (addtocart).

Regards
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 10:06:32 AM
i already use css to remove quantity. now i upload the original vm product detail page. problem still there.  should i use original css too.
thanks again
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 10:26:30 AM
i remove "language Javascript Fix"
i think it s okey now
Title: Re: stock refresihing / double sale
Post by: bytelord on October 03, 2012, 10:28:08 AM
hi,

i don't think original CSS you cause any issues. I tested many times on two installations and is working (2.0.10 and 2.0.11e).

I have configure the product status as: In Stock:2, Booked:0, Low stock: 1, max product quantity:nothing

Then under configuration -> shopfront on the  Action when a Product is Out of Stock i have select Displays 'Notify Me' instead of 'Add To Cart' button.

Test it and works fine.

Title: Re: stock refresihing / double sale
Post by: bytelord on October 03, 2012, 10:31:20 AM
Quote from: ntunay on October 03, 2012, 10:26:30 AM
i remove "language Javascript Fix"
i think it s okey now

hmm ... didn't see any javascript issues on your site but didn't check if something misses. Also you will need "Using the product Scripts". Some time languages is an issue.

So, you find the solution :)
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 10:36:17 AM
i guess i did :)

but quantity button came back :o

i didnt understand why



Title: Re: stock refresihing / double sale
Post by: bytelord on October 03, 2012, 10:40:15 AM
hide it with CSS and clean your browser cache, i think you have commented that lines inside your template
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 12:36:31 PM
i dont know why its not working again.
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 12:59:31 PM
i really dont know what is wrong. it is adding again out of stock product
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 13:09:07 PM
i installed vm 2.10 again. noting is changed
Title: Re: stock refresihing / double sale
Post by: bytelord on October 03, 2012, 18:00:20 PM
hi,

as you told before you think was working without template overrides?
i don't know why this happen on your installation. Can you try on a test product without custom fields or any child products?
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 19:42:54 PM
i created a dummy product witout child product or custom field . it works.
Title: Re: stock refresihing / double sale
Post by: bytelord on October 03, 2012, 20:12:27 PM
ok,

So, there is an issue with the child products i suppose because may be there is stock available ...

Try now with your custom fields without child products. If it is working them try to select from the backend Do not Display Product, if child products also out of stock, to see what happens.

It could be a bug, or may be something that haven't been tested.

Regards

Title: Re: stock refresihing / double sale
Post by: bytelord on October 03, 2012, 20:22:47 PM
take a look here: http://forum.virtuemart.net/index.php?topic=100480.0
and here:
http://forum.virtuemart.net/index.php?topic=102211.msg339667#msg339667
http://forum.virtuemart.net/index.php?topic=99299
Title: Re: stock refresihing / double sale
Post by: ntunay on October 03, 2012, 21:11:35 PM
i add my dummy product a custom field. and problem back. i think problem is the custom field
Title: Re: stock refresihing / double sale
Post by: bytelord on October 03, 2012, 21:27:37 PM
Hi,

Check the posts i gave you before

Regards
Title: Re: stock refresihing / double sale
Post by: ntunay on October 04, 2012, 15:47:15 PM
ok i read the post and i already made custom fiels this way.

addtocart.php has these code

$stockhandle = VmConfig::get('stockhandle', 'none');
    if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock - $this->product->product_ordered) < 1) {
?>
      <a href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id='.$this->product->virtuemart_product_id); ?>" class="notify"><?php echo JText::_('COM_VIRTUEMART_CART_NOTIFY') ?></a>


but  if i remove this code ($this->product->product_in_stock - $this->product->product_ordered) < 1)

noting is changing.




shopfunctionsf.php has these code

public function getAddToCartButton($orderable){

      if($orderable){
         $html = '<input type="submit" name="addtocart" class="addtocart-button" value="'.JText::_('COM_VIRTUEMART_CART_ADD_TO') .'" title="'.JText::_('COM_VIRTUEMART_CART_ADD_TO') .'" />';
      } else {
         $html = '<input name="addtocart" class="addtocart-button-disabled" value="'.JText::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT') .'" title="'.JText::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT') .'" />';
      }

      return $html;
   }
and cart.php has these

if ($stockhandle!='none' && $stockhandle!='risetime') {

         $productsleft = $product->product_in_stock - $product->product_ordered;
         // TODO $productsleft = $product->product_in_stock - $product->product_ordered - $quantityincart ;
         if ($quantity > $productsleft ){
            if($productsleft>0 and $stockhandle='disableadd'){
               $quantity = $productsleft;
               $errorMsg = JText::sprintf('COM_VIRTUEMART_CART_PRODUCT_OUT_OF_QUANTITY',$quantity);
               $this->setError($errorMsg);
               vmInfo($errorMsg.' '.$product->product_name);
               // $mainframe->enqueueMessage($errorMsg);
            } else {
               $errorMsg = JText::_('COM_VIRTUEMART_CART_PRODUCT_OUT_OF_STOCK');
               $this->setError($errorMsg); // Private error retrieved with getError is used only by addJS, so only the latest is fine
               // todo better key string
               vmInfo($errorMsg. ' '.$product->product_name);
               // $mainframe->enqueueMessage($errorMsg);
               return false;
            }
         }
      }


i strugled with these codes but i coulnt find the codes which make stock control for child products or main products
i think it is controling main products stock situation not child products


i add these code

<?php echo JHTML::link($product->link, $this->product->product_in_stock); ?>

to see stock on the page bu t is shows main product stock. what is the child product stock code




sorry it took so much. but i am really deperate

Title: Re: stock refresihing / double sale
Post by: ntunay on October 08, 2012, 12:29:13 PM
is there anyone who can help me?
Title: Re: stock refresihing / double sale
Post by: ntunay on October 11, 2012, 10:59:27 AM
It is a virtuemart problem because i tried on another site. Child product has no stock control
Title: Re: stock refresihing / double sale
Post by: bytelord on October 20, 2012, 14:28:02 PM
Hello,

I think  is not working with child products ... someone else if have the solution could help you out with that.
I think in vm2.2 this will have been corrected but i am not sure.

did you try 2.0.12d?

Regards
Title: Re: stock refresihing / double sale
Post by: candrax on January 24, 2013, 14:23:07 PM
Same issue here. I tested with vm 2.0.18a and still same bug. If you have a child product with stock variant then you can add it multiple times in cart no matter if its stock goes empty.

I tested the same thing with the ordinary single product without children and there "add to cart" doesn't actually add the product in cart if quantity is beyond stock.

Anyone has ever found a solution for this?

Thanx