Undefined variable: min \components\com_virtuemart\helpers\cart.php on line 903

Started by unk77, April 24, 2012, 16:43:10 PM

Previous topic - Next topic

unk77

Hi to all.
when I get on the cart page I get the following error.
Notice: Undefined variable: min in \components\com_virtuemart\helpers\cart.php on line 903


The function code in cart.php is:

Notice: Undefined variable: min in D:\Webs\amistani.com\components\com_virtuemart\helpers\cart.php on line 903
Quote * Check if a minimum purchase value for this order has been set, and if so, if the current
    * value is equal or hight than that value.
    * @author Oscar van Eijk
    * @return An error message when a minimum value was set that was not eached, null otherwise
    */
   private function checkPurchaseValue() {

      $vendor = VmModel::getModel('vendor');
      $vendor->setId($this->vendorId);
      $store = $vendor->getVendor();
      if ($store->vendor_min_pov > 0) {
         $prices = $this->getCartPrices();
         if ($prices['salesPrice'] < $store->vendor_min_pov) {
            if (!class_exists('CurrencyDisplay'))
            require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php');
            $currency = CurrencyDisplay::getInstance();
            $minValue = $currency->priceDisplay($min);
            return JText::sprintf('COM_VIRTUEMART_CART_MIN_PURCHASE', $currency->priceDisplay($store->vendor_min_pov));
         }
      }
      return null;
   }

Can anyone help me tu correct this errore?

Thanx a lot
Antonio

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Thomas Kuschel

Hi Antonio , hi Milbo!

I've tested this behavior too. ( only if the vendor is set to a minimum purchase value, this function is computed with that line 903)

Version 2.0.6

I think this line was for debugging purpose only. Neither the value $min is defined nor the value $minValue is used in this function.
You should comment this line out! E.g. the function $currency->priceDisplay(3.5) does convert the value 3.5 to a printed "3,50 €" .


Here at my site, this change works like a charme - printing e.g. "The minimum purchase value is 5,00 €." in the info field if a minimum of purchase is set to 5.0, and prevents to complete the check out.
The function priceDisplay() at currencydisplay.php  does this value convertion by itself. (next line)
Change:

$currency = CurrencyDisplay::getInstance();
//$minValue = $currency->priceDisplay($min);
return JText::sprintf('COM_VIRTUEMART_CART_MIN_PURCHASE', $currency->priceDisplay($store->vendor_min_pov));


@Milbo: Please commit this little bug, thx.

On the last svn (github), I've seen, somebody (see https://github.com/VirtueMart/virtuemart/commit/910a2901b796c94710233fe7d961ccdf335747d0#diff-14 )

has already changed the line to  $minValue = $currency->priceDisplay( $store->vendor_min_pov);
but this is not necessary.

Another Issue in this function:
When should this function fire this message and prevent the check out process??
If you have set the minimum of purchase to e.g. 5.00 Euro, you can _not_ buy with 5.00 Euro any more.
Because the line:

-      if ($prices['salesPrice'] < $store->vendor_min_pov) {
+      if ($prices['salesPrice'] <= $store->vendor_min_pov) {

has been changed in the svn repository ( 5 days ago) .

I think, if I set a minimum of e.g. 5.00 Euro; a customer should allow to buy things for 5.00 Euro. So I don't think this is a good change, or are there other opinions?
Please undo this change!

Regards,
Thomas

unk77

Hello Thomas,
Your analysis was perfect! I also installed the latest version and I set my shop with a minimum purchase.
If I remove that value, or comment that line of code all is ok.

Thanks for the help
Antonio