Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Function Help


Andrew Yuen

Recommended Posts

Posted

I am trying to write a function that will display the number 1 if the products manufacture id (in the products table) =1 and the number 2 if the manufacture id (in the products table) does not equal 1. I want to incorperate the function in the shopping_cart.php page. I have two store fronts and eventually I want to replace the numbers with different picture and link locations for the products. I REALLY NEED HELP writing this function and am willing to pay someone to help me. Please PM me if you are interested or respond to this post if you can offer free advice.

 

Here is what I have so far: but it does not seem to work:

function tep_get_manufacturer($manufacturer) {
$product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
           $product = tep_db_fetch_array($product_query);
if ($product['manufacturers_id'] == 1) {
    return '1';
  } else {
    return '2';
  }
}

Andrew Yuen

osCommerce, Community Team

Posted

is manufacturers_id in the products table ?

Your online success is Paramount.

Posted

ignore last comment.

 

what happens then ?

 

try

 

return 1

 

instead of

 

return '1'

 

same for 2

 

and do you need to pass the product id in the function call ? or are u doin that ?

Your online success is Paramount.

Posted

if ($product['manufacturers_id'] == '1') {
 echo '1';
} else {
 echo '2';
}

 

Looks good to me. Perhaps the problem lies in the other data you are pulling, which the query is dependant upon.

Posted

Thanks for your help Draven and Yesudo but unfotunatly I still can't get it to work even with your suggestions. I tried echo and getting rid of the ' '. Maybe I am displaying the function incorrectly. I have the code I posted in the general.php page. What should be displated under the shopping_cart.php page to properly displat the function? I put in tep_get_manufacturer($manufacturer)

Andrew Yuen

osCommerce, Community Team

Posted

try:

 

function tep_get_manufacturer($products_id) {
$product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
? ? ? ? ? $product = tep_db_fetch_array($product_query);
if ($product['manufacturers_id'] == 1) {
? ?return '1';
?} else {
? ?return '2';
?}
}

 

and call:

 

$product_manufacturer = tep_get_manufacturer($products_id);

 

Where the value $product_manufacturer should equal either 1 or 2.

Your online success is Paramount.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...