News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Display prices of another shopper group

Started by RhymeGuy, June 18, 2014, 12:46:37 PM

Previous topic - Next topic

RhymeGuy

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?


RhymeGuy

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

#2
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

#3
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

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jenkinhill

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
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

klattr1

#6
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

This is a very interesting idea. Does anyone have a solution for this after the time this thread posted?
Joomla 3.8.13
Virtuemart 3.4.2