Author Topic: Add 'from' to Browse page prices, when product has children.  (Read 9875 times)

rippy

  • Beginner
  • *
  • Posts: 4
I've done a small modification to please one of my clients, who has a bunch of products whose children have varying prices. He wanted the browse page to reflect that the prices were "from X" rather than just "X".

I have the part I've done so far working fine, so if it's useful to someone, great.

I would like to also have it working for featured products, but struggling to find where VM looks up prices for featured products. Any help greatly appreciated.

Here is the code that works so far..

In administrator/components/com_virtuemart/html/shop.browse.php

Change

Code: [Select]
        // Price: xx.xx EUR
if (_SHOW_PRICES == '1' && $auth['show_prices']) {
$product_price = $ps_product->show_price( $db_browse->f("product_id") );
}
else {
$product_price = "";
}

to

Code: [Select]
// Price: xx.xx EUR
if (_SHOW_PRICES == '1' && $auth['show_prices']) {
if ($ps_product->parent_has_children( $db_browse->f("product_id") )) {
$product_price = '<span class="tiny">from</span>'.$ps_product->show_price( $db_browse->f("product_id") );
} else {
$product_price = $ps_product->show_price( $db_browse->f("product_id") );
}
}
else {
$product_price = "";
}

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+
Re: Add 'from' to Browse page prices, when product has children.
« Reply #1 on: June 02, 2009, 19:27:38 pm »
product.specialprod.php I believe is featured
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

rippy

  • Beginner
  • *
  • Posts: 4
Re: Add 'from' to Browse page prices, when product has children.
« Reply #2 on: June 02, 2009, 22:31:32 pm »
product.specialprod.php appears to be for the admin side of featured products.

rippy

  • Beginner
  • *
  • Posts: 4
Re: Add 'from' to Browse page prices, when product has children.
« Reply #3 on: June 04, 2009, 17:24:21 pm »
Same mod for Product Details page..

administrator/components/com_virtuemart/html/shop.product_details.php

Change

Code: [Select]
// PRODUCT PRICE
if (_SHOW_PRICES == '1') {
if( $db_product->f("product_unit") && VM_PRICE_SHOW_PACKAGING_PRICELABEL) {
$product_price_lbl = "<strong>". $VM_LANG->_('PHPSHOP_CART_PRICE_PER_UNIT').' ('.$db_product->f("product_unit")."):</strong>";
}
else {
$product_price_lbl = "<strong>". $VM_LANG->_('PHPSHOP_CART_PRICE'). ": </strong>";
}
$product_price = $ps_product->show_price( $product_id );
}
else {
$product_price_lbl = "";
$product_price = "";
}

to

Code: [Select]
// PRODUCT PRICE
if (_SHOW_PRICES == '1') {
if( $db_product->f("product_unit") && VM_PRICE_SHOW_PACKAGING_PRICELABEL) {
$product_price_lbl = "<strong>". $VM_LANG->_('PHPSHOP_CART_PRICE_PER_UNIT').' ('.$db_product->f("product_unit")."):</strong>";
}
else {
$product_price_lbl = "<strong>". $VM_LANG->_('PHPSHOP_CART_PRICE'). ": </strong>";
}
if ($ps_product->parent_has_children( $product_id )) {
$product_price = "from ". $ps_product->show_price( $product_id );}
else {
$product_price = $ps_product->show_price( $product_id );}
}
else {
$product_price_lbl = "";
$product_price = "";
}


hotelathome

  • Jr. Member
  • **
  • Posts: 129
Re: Add 'from' to Browse page prices, when product has children.
« Reply #4 on: January 28, 2010, 11:36:09 am »
This is a great hack, but is there anyway of changing the wording from "from" to something like "Prices start at" in the shop.browse.php I can do it in shop.product_details.php but when i do it in shop.browse.php the spaces do something to the line and it spreads out across the page.
The only solution I have been able to come up with is writing "Prices-Start-at" That works but it would be better if I could put in the spaces.

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+
Re: Add 'from' to Browse page prices, when product has children.
« Reply #5 on: January 28, 2010, 15:06:22 pm »
Prices&nbsp;Starting&nbsp;At

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

aftertaf

  • Jr. Member
  • **
  • Posts: 205
    • sO couture
  • VirtueMart Version: 3.2.14
Re: Add 'from' to Browse page prices, when product has children.
« Reply #6 on: April 03, 2010, 15:29:09 pm »
I saw your hack and decided to make a small change to allow multilanguage sites...

still in administrator/components/com_virtuemart/html/shop.product_details.php

Here is my code (around line 268)

Code: [Select]
// PRODUCT PRICE
// original
//if (_SHOW_PRICES == '1') {
// if( $db_product->f("product_unit") && VM_PRICE_SHOW_PACKAGING_PRICELABEL) {
// $product_price_lbl = "<strong>". $VM_LANG->_('PHPSHOP_CART_PRICE_PER_UNIT').' ('.$db_product->f("product_unit")."):</strong>";
// }
// else {
// $product_price_lbl = "<strong>". $VM_LANG->_('PHPSHOP_CART_PRICE'). ": </strong>";
// }
// $product_price = $ps_product->show_price( $product_id );
//}
//else {
// $product_price_lbl = "";
// $product_price = "";
//}
// PRODUCT PRICE
if (_SHOW_PRICES == '1') {
if( $db_product->f("product_unit") && VM_PRICE_SHOW_PACKAGING_PRICELABEL) {
$product_price_lbl = "<strong>". $VM_LANG->_('PHPSHOP_CART_PRICE_PER_UNIT').' ('.$db_product->f("product_unit")."):</strong>";
}
else {
$product_price_lbl = "<strong>". $VM_LANG->_('PHPSHOP_CART_PRICE'). ": </strong>";
}
if ($ps_product->parent_has_children( $product_id )) {
//$product_price = $VM_LANG->_('PHPSHOP_START_PRICE'). $ps_product->show_price( $product_id );}
$product_price_lbl = $VM_LANG->_('PHPSHOP_VARIABLE_PRICE');
$product_price = "";}
else {
$product_price = $ps_product->show_price( $product_id );}
}
else {
$product_price_lbl = "";
$product_price = "";
}

I have therefore created a new language file variable :  PHPSHOP_VARIABLE_PRICE
the file to modify is english.php in site/administrator/components/com_virtuemart/languages/product/, and any other languages in use on your site.
create variable PHPSHOP_VARIABLE_PRICE in this file and give it a value.
That way your text can be more or less what you want.
This way I didnt have to show the 1st/lowest price, just say instead Price varies according to choice.
Webmaster for my wife (link in my profile ;)
Extensions / plugins : POSForWebshops, TemplatecreatorCK ,MaximenuCK, and PageBuilderCK, VM BatchEdit Pro, VM CustomFilters Pro, Awocoupon Pro, slogin, supersaas,  among other things...
Joomla! 3.8.6//VM 3.2.14//PHP7.0.18 & mariadb 10.1.22 on Debian
big up to notepad++!!!!

Garrody

  • Beginner
  • *
  • Posts: 7
Re: Add 'from' to Browse page prices, when product has children.
« Reply #7 on: May 06, 2010, 12:46:32 pm »
Many thanks for sharing this info.
It helped me figure out something so cheers.

aftertaf

  • Jr. Member
  • **
  • Posts: 205
    • sO couture
  • VirtueMart Version: 3.2.14
Re: Add 'from' to Browse page prices, when product has children.
« Reply #8 on: May 10, 2010, 14:37:23 pm »
all in the same boat :) for my part you're welcome, and thx to all those who've helped me too (in)directly.
Webmaster for my wife (link in my profile ;)
Extensions / plugins : POSForWebshops, TemplatecreatorCK ,MaximenuCK, and PageBuilderCK, VM BatchEdit Pro, VM CustomFilters Pro, Awocoupon Pro, slogin, supersaas,  among other things...
Joomla! 3.8.6//VM 3.2.14//PHP7.0.18 & mariadb 10.1.22 on Debian
big up to notepad++!!!!

Giannis86

  • Beginner
  • *
  • Posts: 14
Re: Add 'from' to Browse page prices, when product has children.
« Reply #9 on: September 14, 2011, 11:26:26 am »
This works great but i am having one problem. The add to cart form for products that dont have child products has disappeared. Does anyone know how to fix this?