VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: RhymeGuy on June 18, 2014, 12:46:37 PM

Title: Display prices of another shopper group
Post by: RhymeGuy on June 18, 2014, 12:46:37 PM
So i have two groups: default and vip.
Default group have one price, while vip group have discount but just on some categories or products (not on everything). Beside this discount amount is not always the same, sometimes it can be 5% for one category and 10% for another etc..

To accomplish that I have created calculation rules and have assigned them to the vip shopper group and specific categories and it works when Im logged in as vip member.

What i need right now is to display regular price and vip price for both shopper groups. Something like:
QuoteRegular price: $19.99
VIP price: $9.99

How can i accomplish that?

Title: Re: Display prices of another shopper group
Post by: RhymeGuy on June 18, 2014, 14:31:50 PM
So far I have created this:

Quote<?php
   $vm_category_id = $this->category->virtuemart_category_id;
   $db = JFactory::getDBO();
   $query = $db->getQuery(true);
   $query = "
   SELECT * FROM r54kf_virtuemart_calcs a
   INNER JOIN r54kf_virtuemart_calc_categories b
   ON b.virtuemart_calc_id = a.virtuemart_calc_id
   INNER JOIN r54kf_virtuemart_calc_shoppergroups c
   ON c.virtuemart_calc_id = b.virtuemart_calc_id
   WHERE b.virtuemart_category_id = $vm_category_id";
   $db->setQuery($query);
   $results = $db->loadObjectList();
   //print_r($results);
   $price = round($this->product->prices['salesPrice'], 2);
   
      $mathop = $results[0]->calc_value_mathop;
      $value = (float)$results[0]->calc_value;
      $currency = $results[0]->calc_currency;
      $coreMathOp = array('+','-','+%','-%');

      if(!$this->_revert){
         $plus = '+';
         $minus = '-';
      } else {
         $plus = '-';
         $minus = '+';
      }

      if(in_array($mathop,$coreMathOp)){
         $sign = substr($mathop, 0, 1);

         $calculated = false;
         if (strlen($mathop) == 2) {
            $cmd = substr($mathop, 1, 2);
            if ($cmd == '%') {
               
               if(!$this->_revert){
                  $calculated = $price * $value / 100.0;
               } else {
                  if(!empty($value)){
                     if($sign == $plus){
                        $calculated =  abs($price /(1 -  (100.0 / $value)));
                     } else {
                        $calculated = abs($price /(1 +  (100.0 / $value)));
                     }
                  } else {
                     vmdebug('interpreteMathOp $value is empty '.$rule['calc_name']);
                  }
               }
            }
         } else if (strlen($mathop) == 1){
            $calculated = $this->_currencyDisplay->convertCurrencyTo($currency, $value);
         }
         if($sign == $plus){
            $calculated = $price + (float)$calculated;
         } else if($sign == $minus){
            $calculated = $price - (float)$calculated;
         }
      }
   ?>
    <?php if ($calculated) { ?>
       <div class="PricesalesPrice" style="display : block;" >Price for VIP group: <span class="PricesalesPrice" ><?php echo round($calculated, 2); ?> $</span></div>
    <?php } ?>

It seems to work.. Any downside that I dont see?
Title: Re: Display prices of another shopper group
Post by: klattr1 on June 18, 2014, 14:36:14 PM
Take a screenshot of your current pricing configuration page and post it here so we can help.

Also, you can change the label/string in the Joomla Language Manager Overrides page. But it changes it across the board so you may want to use a more universal term that works for both public and VIP shoppers.

Try "Your price: " as an override for "COM_VIRTUEMART_PRODUCT_SALESPRICE"

Also make sure you have checked the box for "Enable shoppergroup specific price display" and "Show prices" in the Shopper Group parameters.
Title: Re: Display prices of another shopper group
Post by: RhymeGuy on June 20, 2014, 08:52:55 AM
Configuration pricing
(http://i.imgur.com/upNMLQH.jpg)

VIP shopper group pricing

(http://i.imgur.com/Oc7alQm.jpg)

Is this the only way to show prices of another shopper group? I mean without interacting with database and writing sql queries...
Title: Re: Display prices of another shopper group
Post by: Milbo on June 22, 2014, 15:52:41 PM
oh damn. I hoped never someone comes up with this. Actually the prices for other shoppergroups are not loaded. Directly filtered by sql. Usually you never want that. I will consider this and rewrite vm3 so that you can get also the prices of other shoppergroups.
Title: Re: Display prices of another shopper group
Post by: jenkinhill on June 22, 2014, 16:14:10 PM
As far as I recall this is the only time than someone has wanted to show another group's prices since VM2 was launched. I'd guess that it could be done by writing a plugin until it makes its way into the core.
Title: Re: Display prices of another shopper group
Post by: klattr1 on June 22, 2014, 16:34:55 PM
It would be useful feature though for wholesale sites. For example, on wholesale sites I manage here in the U.S., it needs to be able to display MSRP (manufacturer suggested retail price), MAP (minimum advertised price), discount, and their cost all on the product details page.

Here's what it looks like right now on one of my sites:

[attachment cleanup by admin]
Title: Re: Display prices of another shopper group
Post by: chimairax on March 01, 2018, 09:17:06 AM
This is a very interesting idea. Does anyone have a solution for this after the time this thread posted?