VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: meysam66 on February 24, 2021, 14:31:57 PM

Title: error when last product getting purchased
Post by: meysam66 on February 24, 2021, 14:31:57 PM
hello i am using VirtueMart version 3.6.10 for my small shop, most of the time i only have 2-3 or only one of a specific product available for shopping.
i have faced an issue which is:

when a user buys the The last stock quantity of a product, he will get an error or warning message just right after making the payment which says "the quantity of that product in their cart have been changed to 0".


i have searched about similar issues to mine, there were some ideas about minor changes in cart.php helper file. but their code was a little different to me.

currently my check for product quantity method in cart.php helper file is like this:

----------------------------------------------------------------------------------------
      if ($checkForDisable) {
         $productsleft = $product->product_in_stock - $product->product_ordered;

         if ($quantity > $productsleft ){
            vmdebug('my products left '.$productsleft.' and my quantity '.$quantity);
            if($productsleft>=$min ){
               $quantity = $productsleft;
               $product->errorMsg = vmText::sprintf('COM_VIRTUEMART_CART_PRODUCT_OUT_OF_QUANTITY',$product->product_name,$quantity);
               vmWarn($product->errorMsg);
            } else {
               $quantity = 0;
               $product->errorMsg = vmText::_('COM_VIRTUEMART_CART_PRODUCT_OUT_OF_STOCK');
               vmWarn($product->errorMsg);
               return false;
            }
         }
      }
---------------------------------------------------------------------------------------------

does anyone, have clue what to change and how to prevent this issue?

Title: Re: error when last product getting purchased
Post by: jjk on February 26, 2021, 22:50:03 PM
How about testing an update to the latest VirtueMart version - preferably with a backup of your live shop on a separate test installation. The cart.php file received a lot of changes after VM 3.6.10.
Title: Re: error when last product getting purchased
Post by: meysam66 on March 01, 2021, 13:04:22 PM

thanks for your reply and your recommendation, believe me l myself would like to be updated, but updating the vm any further makes me several incompatibilities issue with my template. and those would be extra Frustrating challenges for me at the time.

i think my problem somehow does relate to how virtuemart behave after the selected payment method, because i never receive a similar warning on my last stock, when the customer select the cash on delivery method, and by that the order status will be confirmed by shopper.

but i will receive the warning when the customer buys my last stock quantity through a credit card payment, in that case the status will be confirmed.

but the stock handling mechanism with both status in my system is reserved.
Title: Re: error when last product getting purchased
Post by: Jörgen on March 01, 2021, 14:57:43 PM
What is Your Payment method ? I would check with them, I never seen this before with other payments. Using both Paypal and standard payment.

Jörgen @ Kreativ Fotografi
Title: Re: error when last product getting purchased
Post by: meysam66 on March 01, 2021, 16:52:18 PM
hello again jorgen, thanks for your reply.

i am using a payment method which integrates with an online payment system called zarinpal, only supports credit cards in my country.

i have got the plugin from their supported system section.
Title: Re: error when last product getting purchased
Post by: Jörgen on March 01, 2021, 20:39:37 PM
Never heard of this payment, I guess  you should compare this helper with similar plugins that work, f.e PayPal. I suspect this is not a VM issue, it is a payment method issue.

Jörgen
Title: Re: error when last product getting purchased
Post by: meysam66 on March 01, 2021, 20:59:04 PM
ok, i think that's a progress, i will do that, thank you.
Title: Re: error when last product getting purchased
Post by: meysam66 on March 05, 2021, 23:18:55 PM
the problem was a conflict with awocoupon component, which get solved by updating it.