0

我想products_tax_class_ids在 OSCommerce 购物车软件的结帐付款页面中检索。例如,用户的购物车中有 20 件商品,如果有任何商品有products_tax_class_id = 30,网站会警告他。

此代码不起作用。

$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 "..."
    }
}

我怎么能compare tax_class_id的产品?

4

2 回答 2

0

您没有在 while 循环中指向字段名称。

$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 "..."
    }
}

我认为“卡片”这个词应该是“购物车”......

于 2013-09-02T00:38:44.807 回答
0
/**************************************************************************/
//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
/**************************************************************************/  
于 2013-11-06T09:15:47.517 回答