Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Base price as a PHP variable

Base price as a PHP variable

Views: 1,014

Results 1 to 7 of 7
21 Mar 2015, 12:56 PM
#1
matt_staines avatar

matt_staines

New Zenner

Join Date:
Oct 2013
Location:
Portishead, North Somerset, United Kingdom
Posts:
34
Plugin Contributions:
0

Base price as a PHP variable

Hi Guys,

I'm working on my product page, i.e. includes/templates/mytemplate/templates/tpl_product_info_display.php

I need to get the current base price and define it as a php variable so that I can use it in an on page calculation. I can see that there is a load of script to display the base price, but I cannot figure out how to make it a variable. Something like:

$base_price = get_products_price($products_id);

Any of you guys that know PHP and can shed some light on this it would be most helpful.

Kind Regards

Matt

21 Mar 2015, 2:19 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: Base price as a PHP variable

How about

$base_price = get_products_base_price ($products_id);
21 Mar 2015, 2:46 PM
#3
matt_staines avatar

matt_staines

New Zenner

Join Date:
Oct 2013
Location:
Portishead, North Somerset, United Kingdom
Posts:
34
Plugin Contributions:
0

Re: Base price as a PHP variable

lat9:

How about

$base_price = get_products_base_price ($products_id);


Thanks, I'll give that a try!
21 Mar 2015, 2:56 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Base price as a PHP variable

Although not 100% accurate, a helpful tool for such function search is the published docs for zc 1.5.0 (http://www.zen-cart.com/docs/phpdoc-1-5-0/)

21 Mar 2015, 3:21 PM
#5
matt_staines avatar

matt_staines

New Zenner

Join Date:
Oct 2013
Location:
Portishead, North Somerset, United Kingdom
Posts:
34
Plugin Contributions:
0

Re: Base price as a PHP variable

Thanks everyone,

I achieved it using: ```php

<?php echo zen_get_products_base_price((int)$_GET['products_id']) ;?>
21 Mar 2015, 3:29 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Base price as a PHP variable

Question about the usage of the above, understand that it is used on the product_info page which ought not be displayed without a products_id, but I would suggest at least coding this section applicably. Or to put it another way, I kinda get the willies when I see GET statements used directly without some form of validation. The validation may already be there (executed before the above code), but just one of those "system views".

21 Mar 2015, 5:50 PM
#7
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: Base price as a PHP variable

mc12345678:

Question about the usage of the above, understand that it is used on the product_info page which ought not be displayed without a products_id, but I would suggest at least coding this section applicably. Or to put it another way, I kinda get the willies when I see GET statements used directly without some form of validation. The validation may already be there (executed before the above code), but just one of those "system views".
The fact that the value is cast to an (int) should be "validation" enough.