购物车oscommerce

时间:2013-04-11 00:41:30

标签: php shopping-cart oscommerce

我想在OSCommerce购物车软件的结帐付款页面中检索products_tax_class_ids。例如,用户在他的购物车中有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产品?

2 个答案:

答案 0 :(得分: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 "..."
    }
}

“卡片”应该是一个“推车”,我认为......

答案 1 :(得分: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
/**************************************************************************/