我想在结账付款页在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
?
发布于 2013-09-02 08:38:45
您没有在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-11-06 17:15:48
/**************************************************************************/
//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
/**************************************************************************/
https://stackoverflow.com/questions/15938962
复制相似问题