0
votes

I want to retrieve products_tax_class_ids in checkout payment page in OSCommerce shopping cart software. E.g., the user has 20 items in his shopping cart and if any of product has products_tax_class_id = 30, the site will warn him.

This code is not working.

$tax = tep_db_query("select products_tax_class_id 
                    from " . TABLE_PRODUCTS . " 
                    where products_id = '".$card[$products_id]."'");

while ($warn = tep_db_fetch_array($tax)) {
    if (warn== '30') { 
        echo "attention ....";
    } 
    else { 
        echo "..."
    }
}

How can I compare tax_class_id of products?

2
do you see some errors? There are obvious syntax errors in your codeEjaz
no, i check error.php, no error, i think i can not select shoppisnk
no, i check error.php, no syntax error, i made a class and called in checkout_payment with require, nothing happened. functions like (echo $cart->show_total()) can be called and executed perfectly in checkout payment. $card[$products_id] could be wrong? i tried contents[$products_id]['products_tax_class_id'] or $orders_products['products_id'] from orders.php in order to products_id = '".$card[$products_id]."'") no results again. i can not understand how i can call items from shopping card and their products_tax_class_ id. little bit confused.snk
are you sure $card array exists? it could be $cart in a shopping cart softwareEjaz
if i copy and paste shopping card php, would it be problem for forum?snk

2 Answers

0
votes

You didn't point name of field in while loop.

$tax = tep_db_query("select products_tax_class_id 
                    from " . TABLE_PRODUCTS . " 
                    where products_id = '".$card[$products_id]."'");

while ($warn = tep_db_fetch_array($tax)) {
    if ($warn['products_tax_class_id'] == '30') { 
        echo "attention ....";
    } 
    else { 
        echo "..."
    }
}

And word "card" should be a "cart" I think...

0
votes
/**************************************************************************/
//Add following function in includes/functions/general.php
/**************************************************************************/

function tep_get_products_tax($product_id) {
    global $languages_id;

    if (empty($language)) $language = $languages_id;

    $product_query = tep_db_query("select products_tax_class_id from " . TABLE_PRODUCTS . " where products_id = '".$product_id."'");
    $product = tep_db_fetch_array($product_query);

    return $product['products_tax_class_id'];
  }


/**************************************************************************/
//Add following code in checkout_payment.php
/**************************************************************************/
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  if (tep_get_products_tax($products[$i]['id']) == 30) {
    echo "attention ....";
break
  }
}
/**************************************************************************/
//EOD
/**************************************************************************/