Zen Cart Logo
Forums / General Questions / Please could I have help with a function

Please could I have help with a function

Locked

Views: 774

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
16 Jun 2009, 8:59 PM
#1
setter avatar

setter

New Zenner

Join Date:
Aug 2007
Posts:
16
Plugin Contributions:
0

Please could I have help with a function

Hi there everyone,
If anyone's passing here please could you help me with a function to multiply 2 values from the same table to give a new value.

This is what I've done but cant seem to make it work.
I do appreciate that I may well have got this wrong so could someone correct this for me.
(I've tried to work it out by studying other functions)

So if I wanted to multiply products_price by products_quantity to give products_sumtotal would I do it like this?

<?php function zen_get_products_sumtotal($products_price, $products_quantity) { global $db; $products_sumtotal = $db->Execute("SELECT $products_price * $products_quantity from " . TABLE_PRODUCTS . " where products_ourprice = '" . (int)$products_price . "' and products_quantity = '" . (int)$products_quantity . "'"); return $products_sumtotal->fields['products_sumtotal']; } ?>

Many thanks

16 Jun 2009, 9:32 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,604
Plugin Contributions:
0

Re: Please could I have help with a function

The cart already does that - What are you trying to do?

16 Jun 2009, 9:49 PM
#3
setter avatar

setter

New Zenner

Join Date:
Aug 2007
Posts:
16
Plugin Contributions:
0

Re: Please could I have help with a function

Hello.
Thanks for the reply.

I just wanted to try and display something in admin only.
What I'd previously done is added a box in the admin products page (collect_info.php and preview_info.php etc) which displays the price we pay for an item just above the 'products price (net) box' and the value was stored in the products table so it was called whenever we went to admin at a later date.

What I have added now is another row to the products table and another box to the admin new products page under quantity and was trying to multiply the price we pay for an item by the quantity in stock to show the value in the new box right below quantity.

I hope I've explained that ok.

Thanks once again.