News:

Looking for documentation? Take a look on our wiki

Main Menu

Minimum Quantity by shopper group - Found old hack need to translate

Started by SoTrue, December 13, 2016, 21:24:43 PM

Previous topic - Next topic

SoTrue

Hi All,

I have fund an old hack from VM1/2 I think, which relates to a file:  /administrator/components/com_virtuemart/classes/ps_product_attribute.php

This file no longer exists, but I would like to try and make the hack work with VM 3, so that I can set a minimum order quantity for all products when shoppers are in the wholesale Shopper group.

The hack is:

Open the /administrator/components/com_virtuemart/classes/ps_product_attribute.php and locate the function "show_quantity_box". Depending on your exact VirtueMart version, it's around line 1050.

Go down until you find this code:

//Start output of quantity
//Check for incompatabilities and reset to normal
if( CHECK_STOCK == '1' && ! $product_in_stock ) {
$display_type = 'hide' ;
}
if( empty( $display_type ) || (@$display_type == "hide" && $child == 'Y') || (@$display_type == "radio" && $child == 'YM') || (@$display_type == "radio" && ! $child) ) {
$display_type = "none" ;
}

Below that, insert this:
$auth = $_SESSION['auth'];
if($auth["shopper_group_id"]==6) {
$display_type = "drop" ;
$quantity_options['quantity_box'] = "drop";
[i] }

Save it.[/i]

You are done with hacking part. Now let's set up the products accordingly. Presuming that you want all the products to behave similarly, as described above, go to your hosting panel, open phpMyAdmin, and run this query:
UPDATE `yourdatabase`.`jos_vm_product` SET `quantity_options` = 'none,0,240,6';

Where is the CHECK_STOCK code now? Any pointers would be most appreciated.

Best Regards
Donna

SoTrue

I have located the following code in default_addtocart.php which I think may be related:

<?php // Display the quantity box

$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>
<?php
} else {
$tmpPrice = (float) $this->product->prices['costPrice'];
if (!( VmConfig::get('askprice'0) and empty($tmpPrice) ) ) {
?>

<!-- <label for="quantity<?php echo $this->product->virtuemart_product_id?>" class="quantity_box"><?php echo JText::('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
<span class="quantity-box">
<input type="text" class="quantity-input js-recalculate" name="quantity[]" 
   value="<?php if (isset($this->product->step_order_level) && (int)$this->product->step_order_level 0) {
echo $this->product->step_order_level;
} else if(!empty($this->product->min_order_level)){
echo $this->product->min_order_level;
}else {
echo '1';
?>
"/>
</span>
<span class="quantity-controls js-recalculate">
<input type="button" class="quantity-controls quantity-plus"/>
<input type="button" class="quantity-controls quantity-minus"/>
</span>
<?php // Display the quantity box END

// Display the add to cart button ?>

          <span class="addtocart-button">
          <?php echo shopFunctionsF::getAddToCartButton ($this->product->orderable);
// Display the add to cart button END  ?>

          </span>
<input type="hidden" class="pname" value="<?php echo htmlentities($this->product->product_nameENT_QUOTES'utf-8'?>"/>
<input type="hidden" name="view" value="cart"/>
<noscript><input type="hidden" name="task" value="add"/></noscript>
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo $this->product->virtuemart_product_id ?>"/>
<?php
}
?>

<?php
}
?>


Please feel free to contribute if you have any suggestions. I;m not very good at PHP so this may take me a while.

Regards
Donna