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

chrs23

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




logobis

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





Hi everybody,

I'm in the same case.
Does someone could explain us how we can display multi prices ?
Thank's by advance

logobis

A little up...
It seem's incredible that there is no solution to display multiprices !!!
OK, prices change well when quantity is updated but if the customer doesn't show all the price's ranges it's a joke !
no one has a solution ?
Thank's.

chrs23

Quote from: logobis on March 26, 2013, 21:11:45 PM
A little up...
It seem's incredible that there is no solution to display multiprices !!!
OK, prices change well when quantity is updated but if the customer doesn't show all the price's ranges it's a joke !
no one has a solution ?
Thank's.

I have a half solution, without hard php programming.
I do not need short description, so I change at the template, that short description will be shown under the BUY bottom.
Of course at every products should write hand the price range, but it do not change a lot of time. So price is shown. The modify it is very easy later at administrator page.

JoelSTK

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

How do I change the displayed values​​, the lowest to be first?

Many Thanks.


GJC Web Design

You could do a query in the template for all prices for the product id from jos_virtuemart_product_prices and display them as a list in your template.
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

lanthan

#7
Hi all,
as many people and me too where seeking for a solution here is mine. Direct DB access is not! recommended. For showing all multiple prices on your productdetailpage add the following code to your productdetail.php. If your product quantity end of the last price is zero, the price is shown only with the start amount plus a different text ->COM_VIRTUEMART_MULTIPRICES_FROM. Tax and currency is checked. Output is ordered by "price_quantity_start" could be changed into "product_price". This means, even if you add a price later, everything will be in order.


//get multiprices form current product_id
$db = JFactory::getDBO ();
$q = 'SELECT `product_price`,`price_quantity_start`,`price_quantity_end`,`product_tax_id`,`product_currency` FROM `#__virtuemart_product_prices` WHERE `virtuemart_product_id`="' . $this->product->virtuemart_product_id . '" ORDER BY `price_quantity_start` ';
$db->setQuery ($q);
$multiprices = $db->loadObjectList();

//get the number of multiprices
$count = $db->getAffectedRows();

//get tax and currency

for ($i = 0; $i < $count; $i++) {
$q = 'SELECT `currency_symbol` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $multiprices[$i]->product_currency . '" ';
$db->setQuery ($q);
$currency[$i] = $db->loadresult();

// for default tax rule, check your default tax id and probably change ...product_tax_id = "1" into your default tax id
if ($multiprices[$i]->product_tax_id == "0") {$multiprices[$i]->product_tax_id ="1";}

$q = 'SELECT `calc_value` FROM `#__virtuemart_calcs` WHERE `virtuemart_calc_id`="' . $multiprices[$i]->product_tax_id . '" ';
$db->setQuery ($q);
$taxvalue = $db->loadresult();
$q = 'SELECT `calc_value_mathop` FROM `#__virtuemart_calcs` WHERE `virtuemart_calc_id`="' . $multiprices[$i]->product_tax_id . '" ';
$db->setQuery ($q);
$mathop = $db->loadresult();

//tax calculation
if ($mathop == "+%") {$multiprices[$i]->product_price = $multiprices[$i]->product_price * (1 + $taxvalue / 100);}
if ($mathop == "-%") {$multiprices[$i]->product_price = $multiprices[$i]->product_price - ($multiprices[$i]->product_price * ($taxvalue / 100));}
if ($mathop == "+")  {$multiprices[$i]->product_price = $multiprices[$i]->product_price + $taxvalue;}
if ($mathop == "-")  {$multiprices[$i]->product_price = $multiprices[$i]->product_price - $taxvalue;}

//price rounding, changing . to ,
$multiprices[$i]->product_price = number_format (round ($multiprices[$i]->product_price, 2), 2, ',', '.');
}
 
//display only if multiprice
if ($count > 1) {
echo '<div id="multiprices">'; //your multiprice div container
echo JText::_('COM_VIRTUEMART_MULTIPRICES')."</br>";

for ($i = 0; $i < $count; $i++) {

if ($i == ($count - 1) && $multiprices[$i]->price_quantity_end == "0"){
//display if last multiprice and quantity end is = 0
echo JText::_('COM_VIRTUEMART_MULTIPRICES_PRICE')." ".$multiprices[$i]->product_price ." ". $currency[$i]." ".JText::_('COM_VIRTUEMART_MULTIPRICES_FROM'). " " .$multiprices[$i]->price_quantity_start ." ". JText::_('COM_VIRTUEMART_MULTIPRICES_QTY')."</br>";
}
else {
//default display
echo JText::_('COM_VIRTUEMART_MULTIPRICES_PRICE')." ".$multiprices[$i]->product_price ." ". $currency[$i]." ".JText::_('COM_VIRTUEMART_MULTIPRICES_START'). " " .$multiprices[$i]->price_quantity_start. " " .JText::_('COM_VIRTUEMART_MULTIPRICES_END') ." ". $multiprices[$i]->price_quantity_end ." ". JText::_('COM_VIRTUEMART_MULTIPRICES_QTY')."</br>";
}
}
echo '</div>';
}


And add theses language vars to your language overrides

COM_VIRTUEMART_MULTIPRICES ="Staffelpreise"
COM_VIRTUEMART_MULTIPRICES_START = "von"
COM_VIRTUEMART_MULTIPRICES_FROM = "ab"
COM_VIRTUEMART_MULTIPRICES_END ="bis"
COM_VIRTUEMART_MULTIPRICES_QTY ="Stück"
COM_VIRTUEMART_MULTIPRICES_PRICE ="Preis:"

Hope this helps some of you! I would appreciate, if someone could add the DB access into a function and provides the vars to productdetailpage.php.

fallnet

#8
Hi lanthan,

thank you for share your code.
I have problem with show price with VAT.

When is payment rules default, it doesnt add VAT.
So I must select rules VAT 21%.

Thank you.

lanthan


AH

Just for info

Milbo has said in VM3 all prices will be available (although he does not say how they will be structured)
Regards
A

Joomla 4.4.5
php 8.1

lanthan

#11
@Hutson -> Yes, I read it. If VM3 (stable) comes out I will have a look at this.

@fallnet
If you choose "default" the stored product_tax_id is zero. As there is no tax calculation with that id, no tax will be calculated. To solve this problem you just have to set the product_tax_id to 1 or any other existing id. Please give me feedback if this works. I couldn´t test it. Thanks.


//get tax and currency

for ($i = 0; $i < $count; $i++) {
$q = 'SELECT `currency_symbol` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $multiprices[$i]->product_currency . '" ';
$db->setQuery ($q);
$currency[$i] = $db->loadresult();

// for default tax rule, check your default tax id and probably change ...product_tax_id = "1" into your default tax id
if ($multiprices[$i]->product_tax_id == "0") {$multiprices[$i]->product_tax_id ="1";}

$q = 'SELECT `calc_value` FROM `#__virtuemart_calcs` WHERE `virtuemart_calc_id`="' . $multiprices[$i]->product_tax_id . '" ';
$db->setQuery ($q);
$taxvalue = $db->loadresult();
$q = 'SELECT `calc_value_mathop` FROM `#__virtuemart_calcs` WHERE `virtuemart_calc_id`="' . $multiprices[$i]->product_tax_id . '" ';
$db->setQuery ($q);
$mathop = $db->loadresult();

//tax calculation


fallnet

Hi lanthan,

your fix works like charm :)
Default tax get tax with id 1 now.

Thank you.

lanthan


motybz