News:

Support the VirtueMart project and become a member

Main Menu

listing multiple prices on product page

Started by chrs23, March 18, 2013, 14:42:02 PM

Previous topic - Next topic

jccompagnon

did this option get added to VM3 ?
if so where ?

lanthan

The code works also for VM3 (Short test on V3.02). You could have tested this on your own by the way.

override folder
html/com_virtuemart/productdetails/default.php
insert it from line 160. DonĀ“t forget the language overrides.

Like Hutson said, it might be possible that all prices are available on productdetail page with vm3. So probably there could be a solution without DB access. I will check this out in a few weeks and let you know.

lindapowers

Quote from: chrs23 on March 18, 2013, 14:42:02 PM
I have Joomla 2.5.9 VM 2.0.12 and want to upgrade to make possible mutliple pricing for products.

I test now 2.0.18a, but as I see the price will change only after I modify the quantity. This is bad, because customer who wants to buy more pcs, left page because high price. (costomer do not test quantity modifying)
Customer buys normaly not 1 pcs, so pricing is for example the following:

Can somebody help me, how to make a list at product page like so:
1-19pcs - 1 EUR/pcs
20-49pcs - 0,8 EUR/pcs
50-     -0,7 EUR/pcs

(min. and max Quantity is changing.)

Many thanks. ;D





I need exactly the same, so still no solution in the core of VM2 or VM3?

Would be nice if customers had a way to see that one product has different prices per quantity as the example you mentioned.

Milbo

Buy the membership, it is included there.

The code for vm2.6 is


$usermodel = VmModel::getModel ('user');
$currentVMuser = $usermodel->getCurrentUser ();
if(!is_array($currentVMuser->shopper_groups)){
$virtuemart_shoppergroup_ids = (array)$currentVMuser->shopper_groups;
} else {
$virtuemart_shoppergroup_ids = $currentVMuser->shopper_groups;
}

$allPrices = VmModel::getModel('product')->loadProductPrices($this->product->virtuemart_product_id, 0,$virtuemart_shoppergroup_ids,true);

array_reverse($allPrices);

echo '<table>';
foreach($allPrices as $prices){

echo '<tr>';
echo '<td> '.$prices['price_quantity_start'] .'</td>';
echo '<td> '.$prices['price_quantity_end'] .'</td>';
echo '<td> '.$this->currency->priceDisplay($prices['product_price'])  .'</td>';
echo '</tr>';
}

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

serge-web54

hello,
I tried the code and put it into my layout, it works.
but i woul like to have tax included prices

what is the code to change it ?
thanks
Serge

nikolaoskai

Hello, i know that this is an old post but i need some help please. The price listing working fine but how can i show seperate tax amount for every single price in product page.
Example:
Price: 150,00 from 0 to 10 Pieces (Tax amount 20$)
Price: 100,00 from 11 to 20 Pieces (Tax amount 15$)
Price: 50,00 from 21 to 30 Pieces (Tax amount 10$)

Many thanks

GJC Web Design

echo out the $prices to see if tax is there

otherwise just do a calc on each price to work out the tax if it is always the same and display it
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

lausianne

#22
Quote from: Milbo on March 09, 2015, 19:37:03 PM
Buy the membership, it is included there.

What membership? I'd love to buy, and to see what extra features there are, but can't find it.

EDIT: Finally I found this: http://extensions.virtuemart.net/support/virtuemart-supporter-membership-detail
I had seen donation links, but never read the small print. OMG. Used Virtuemart for the first time almost 10 years ago, never knew this existed. Please advertise more prominently!

razor7

#23
Hi! Today I found myself searching the same thing, so I checked out the code and came with my own implementation using sublayouts like this:

create a new sublayout in vm directory or your tremplate override named multiprices.php and paste this code
<?php
defined
('_JEXEC') or die('Restricted access');

$product $viewData['product'];

if (
count($product->allPrices) > 1) {
    
$usermodel VmModel::getModel('user');
    
$currentVMuser $usermodel->getCurrentUser();
    
$currencyDisplay CurrencyDisplay::getInstance();
    
$productModel VmModel::getModel('product');
    
$shoppergroupModel VmModel::getModel('shoppergroup');

    if(!
is_array($currentVMuser->shopper_groups)){
        
$current_user_shopper_groups = (array)$currentVMuser->shopper_groups;
    } else {
        
$current_user_shopper_groups $currentVMuser->shopper_groups;
    }
    
?>

    <div class="price-ranges">
        <h3>
            <i class="fa fa-sliders" aria-hidden="true"></i> <?php echo JText::_('COM_VIRTUEMART_MULTIPRICES'); ?>
        </h3>
    <?php
    
foreach ($current_user_shopper_groups as $sgKey => $shoppergroup_id) {
        foreach (
$product->allPrices as $key => $price) {
            if (
$shoppergroup_id == || $price['virtuemart_shoppergroup_id'] == $shoppergroup_id) {
                if (!
array_key_exists('salesPrice'$price)) {
                    
$product->selectedPrice $key;
                    
$price $productModel->getPrice($product$price['price_quantity_start']);
                }

                
$shopperGroupDetail $shoppergroupModel->getShopperGroup($shoppergroup_id);
                
$quantityEndText = ($key !== (count($product->allPrices) - 1) && (int)$price['price_quantity_end'] > 0) ? VMText::_('COM_VIRTUEMART_MULTIPRICES_END') . ' ' $price['price_quantity_end'] : VMText::_('COM_VIRTUEMART_MULTIPRICES_END') . ' ' VMText::_('COM_VIRTUEMART_MULTIPRICES_FINAL');
                
$shopperGroupText VMText::_('COM_VIRTUEMART_SHOPPERGROUP_GUEST') != $shopperGroupDetail->shopper_group_name VMText::_('COM_VIRTUEMART_MULTIPRICES_SHOPPER_GROUP_PREFIX') . ' ' $shopperGroupDetail->shopper_group_name VMText::_('COM_VIRTUEMART_MULTIPRICES_SHOPPER_GROUP_PREFIX') . ' ' VMText::_('COM_VIRTUEMART_MULTIPRICES_SHOPPER_GROUP_GENERAL');
                
$priceRange '<span class="shopper-group">' $shopperGroupText '</span>' '<span class="price">' $currencyDisplay->priceDisplay($price['salesPrice']) . '</span> <span class="range">' VMText::_('COM_VIRTUEMART_MULTIPRICES_START') . ' ' $price['price_quantity_start'] . ' ' $quantityEndText '</span>';
                
?>

                <div class="price-range">
                    <?php echo $priceRange?>
                </div>
                <?php
            
}
        }
    }
?>

    </div>
<?php
}


then in your productdetails/default.php template paste this line of code where you want the multiprices table to be rendered:
<?php echo shopFunctionsF::renderVmSubLayout('multiprices', array('product'=>$this->product)); ?>

then load this lang strings in your overrides lanf file

COM_VIRTUEMART_MULTIPRICES ="Price Ranges"
COM_VIRTUEMART_MULTIPRICES_SHOPPER_GROUP_PREFIX="List"
COM_VIRTUEMART_MULTIPRICES_SHOPPER_GROUP_GENERAL="General"
COM_VIRTUEMART_MULTIPRICES_START = "from"
COM_VIRTUEMART_MULTIPRICES_END ="to"
COM_VIRTUEMART_MULTIPRICES_FINAL = "&infin;"


last add this CSS to your template css

.productdetails .vm-product-details-container .price-ranges {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: initial;
    line-height: initial;
    color: #555;
    word-spacing: 3px;
    margin-bottom: 10px;
}

.productdetails .vm-product-details-container .price-ranges h3 {
    font-size: 20px;
    margin-top: 30px;
    border-bottom: 1px solid #e5e5e5;
    padding: 15px 0 10px;
    text-transform: uppercase;
}

.productdetails .vm-product-details-container .price-range {
   padding-left: 10px;
}

.productdetails .vm-product-details-container .price-ranges span.price {
    font-weight: bold;
}

.productdetails .vm-product-details-container .price-ranges span.range {

}
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

jlover

Hi
Thank you @lanthan for very useful mod.

I would need your recommend in case I want to show this listing multiple price to registered user only.

My price still show even user not login.

Agaton

Nice one razor7, that was a very elegant solution.

With a few tweaks it has allowed me to display a list of prices that are discounted via calculations.

Just wanted to say thank you.