Author Topic: HELP! Seemingly simple request is not-so-friggin simple!  (Read 7954 times)

slappadudle

  • Beginner
  • *
  • Posts: 25
HELP! Seemingly simple request is not-so-friggin simple!
« on: January 27, 2009, 15:42:13 pm »
My client wants the prices in the category flypage to include the unit number (Eg. "Price (1000 pcs):") like it is displayed on the product flypage (here) - http://www.rcr.com.au/test/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=2&category_id=5&option=com_virtuemart&Itemid=166

Sounds simple right? So I figured just copying a little piece of code from the product flypage to the category flypage would do the trick.

WRONG.

In flypage.tpl.php the unit number is fetched by inserting <?php echo $product_price_lbl ?> but if I paste that same little piece of code into browse_1.php it does nothing!!

WHY?!?!

I am quite sure that I am editing the correct file here...

klutzon

  • Jr. Member
  • **
  • Posts: 319
  • Knuckles the Echidna
    • Rage3D
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #1 on: January 27, 2009, 17:12:48 pm »
Hey slappadudle,

The reason it's not working is because the parameter $product_price_lbl is used only in flypages / product details, it cannot be used on browse or product listing pages. :)

Check the "Themes and Templates" section in the Developer's Manual to know which parameters you can use on which of the flypages, because even though most are shared, there are some big differences between the two.

http://virtuemart.net/documentation/Developer_Manual/Modifying_the_Layout.html

Have fun! :D

slappadudle

  • Beginner
  • *
  • Posts: 25
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #2 on: January 28, 2009, 01:17:31 am »
Thanks for your reply, however "it cannot be used" is not a solution for me! I know anything is possible and I need to make this happen. Do you know WHY $product_price_lbl cannot be used on category flypage? How would I set about adding it to the list of defined variables, enabling its use? That's what I want to know.

I'm not very PHP savvy but I have managed to pull off some tricky edits thus far!

Here's what I just tried, I think I'm on the right track but with limited PHP skills I'm just causing fatal errors...

I took this piece of code from shop.product_details.php (line 262)

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 = "";
}

and pasted it into shop.browse.php just above this code (on line 307)

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 = "";
}

Here's the error:

Quote
Fatal error: Call to a member function f() on a non-object in /var/web/pro/auto/www.rcr.com.au/htdocs/test/administrator/components/com_virtuemart/html/shop.browse.php on line 308

There is some information about parsing at the bottom of this page, is it relevant? http://virtuemart.net/documentation/Developer_Manual/Modifying_the_Layout.html

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #3 on: February 27, 2009, 03:53:34 am »
The reason it does not work is because the $db_product database has not been created or queried in shop.browse!

Shop browse uses a complicated query and is created by shop_browse_queries.php and does not refernce the product_unit field.

So to use it in this manner would require the queries file mentioned altered and any reference to $db_product changed to $db_browse. Or create a new db called $db_product and use the product_id to query each product for it's product unit. So for each category at least 1-5 extra queries when displaying 5 products per page or 1-20 when displaying 20 products per page!!!

Things are never as simple as they first seem!
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

arathra

  • Beginner
  • *
  • Posts: 14
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #4 on: November 06, 2009, 13:02:50 pm »
Did this ever get solved? I am lookiing for exactly the same thing: on the browse page show

Price per unit: 10

But having spent two days on this and tried a myriad of ideas; nothing has changed!

Any help please?

namdreow

  • Beginner
  • *
  • Posts: 6
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #5 on: November 26, 2009, 14:27:31 pm »
Well i was looking for this to but i found the solution:
shop_browse_queries.php:
at line 37 after // These are the names of all fields we fetch data from
add the fieldname `product_unit`
shop.browse.php:
at line 292 after // If it is item get parent:
add product_unit after product_s_desc

add at the browse page you use: <?php echo $product_unit?>

And everything will be fine.
I hope it is clear

namdreow

  • Beginner
  • *
  • Posts: 6
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #6 on: November 26, 2009, 14:38:52 pm »
i forgot somethings, at shop.browse.php:

add

$product_unit = $db_browse->f("product_unit");
      if( empty($product_unit) && $product_parent_id!=0 ) {
         $product_unit = $dbp->f("product_unit"); // Use product_unit from Parent Product
      }

at line 404 (after the same code but then for Use product_s_desc from Parent Product

Add
      $products[$i]['product_unit'] = $product_unit;
after line 443
// Unset these for the next product

this was all

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2871
  • VirtueMart Version: 3.4
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #7 on: December 20, 2009, 14:52:21 pm »
namdreow  brilliant solution! worked perfectly

thanks
Andrew
regards
A

Joomla 3.9.1
php 7.1

masonwebdesign

  • Beginner
  • *
  • Posts: 3
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #8 on: January 07, 2010, 16:18:57 pm »
Very clear instructions. works perfectly. thanks namdreow

fprefix

  • Beginner
  • *
  • Posts: 2
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #9 on: February 24, 2010, 23:45:48 pm »
Worked perfectly!

1 else question, how i can to add the product_unit to the cart in field price after "/", see example:


any body know? ;)  ???

rbankole

  • Beginner
  • *
  • Posts: 2
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #10 on: February 28, 2010, 18:23:37 pm »
Well i was looking for this to but i found the solution:
shop_browse_queries.php:
at line 37 after // These are the names of all fields we fetch data from
add the fieldname `product_unit`
shop.browse.php:
at line 292 after // If it is item get parent:
add product_unit after product_s_desc

add at the browse page you use: <?php echo $product_unit?>

And everything will be fine.
I hope it is clear


Could you please clarify what you mean by "At the browse page you use: <?php echo $product_unit?>" ? I'm not sure exactly where to add that line.

Thanks for your help.

suzy@fsl

  • Beginner
  • *
  • Posts: 6
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #11 on: October 31, 2013, 16:23:12 pm »
I've tried and tried and tried this, but I can't get it right!

I've managed to get the product unit to appear on the flypage, however all products have now vanished from the browse page! Fortunately I saved the original files and have reverted back, any ideas what I'm doing wrong?!

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2871
  • VirtueMart Version: 3.4
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #12 on: November 01, 2013, 09:42:53 am »
suzy

you need to post your code for anyone to have any chance of seeing what you are doing wrong!
regards
A

Joomla 3.9.1
php 7.1

suzy@fsl

  • Beginner
  • *
  • Posts: 6
Re: HELP! Seemingly simple request is not-so-friggin simple!
« Reply #13 on: November 01, 2013, 11:37:01 am »
The code exceeds the word count limit, so here's a link to open copies of the original http://www.flooringsales.co.uk/images/shop_browse_files.zip