我正在使用不允许我将 php 添加到模板文件的购物车脚本。使用的方法是$GLOBALS
在类文件中创建并从 tpl 文件中调用它们。我需要做的是以下。
$GLOBALS['DiscountedPrice']
需要等于后面的代码块。我尝试了一些语法选项来尝试将其包装起来,但它会中断,因为在代码块中使用了相同的语法。
$GLOBALS['DiscountedPrice'] = $query = mysql_query("
SELECT *
FROM isc_customer_group_discounts
WHERE `catorprodid` = '%%GLOBAL_ProductId%%'
AND `customergroupid` = 1
AND `discounttype` = 'PRODUCT'
");
$discounted_price = '';
while($proddisc = mysql_fetch_array($query)) {
$discperc = $proddisc['4'];
$discmeth = $proddisc['6'];
if($discmeth = 'percent') {
$discperc = $proddisc['4']/100;
$discounted_price = $row['prodprice'] * $discperc;
$GLOBALS['DiscountedPrice'] = $discounted_price;
}elseif ($discmeth = 'price') {
$discounted_price = $row['prodprice'] - $discperc;
$GLOBALS['DiscountedPrice'] = $discounted_price;
}elseif ($discmeth = 'fixed') {
$discounted_price = $discperc;
$GLOBALS['DiscountedPrice'] = $discounted_price;
}};