Author Topic: Display prices of another shopper group  (Read 992 times)

RhymeGuy

  • Beginner
  • *
  • Posts: 4
Display prices of another shopper group
« 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:
Quote
Regular price: $19.99
VIP price: $9.99

How can i accomplish that?


RhymeGuy

  • Beginner
  • *
  • Posts: 4
Re: Display prices of another shopper group
« Reply #1 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?

klattr1

  • Jr. Member
  • **
  • Posts: 80
Re: Display prices of another shopper group
« Reply #2 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.

RhymeGuy

  • Beginner
  • *
  • Posts: 4
Re: Display prices of another shopper group
« Reply #3 on: June 20, 2014, 08:52:55 am »
Configuration pricing


VIP shopper group pricing



Is this the only way to show prices of another shopper group? I mean without interacting with database and writing sql queries...

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9591
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Display prices of another shopper group
« Reply #4 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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26848
  • Always on vacation
    • Jenkin Hill Internet
Re: Display prices of another shopper group
« Reply #5 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.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM.3.2.15.9866 on Joomla 3.8.8 PHP 7.0.30

Testing VM.3.2.15.9866 on J3.8.8

klattr1

  • Jr. Member
  • **
  • Posts: 80
Re: Display prices of another shopper group
« Reply #6 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]

chimairax

  • Beginner
  • *
  • Posts: 13
  • A beginner
Re: Display prices of another shopper group
« Reply #7 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?