我想在购物车中显示每种产品的总价格(按ID).
qty | single price | total
2 | $ 2.00 | $ 4.00 <-- that's what i need
3 | $ 5.00 | $ 15.00
| Subtotals: | $ 19.00 <-- that's what i get with the code below
$totals = Mage::getSingleton("checkout/cart")->getQuote()->getTotals();
$subtotal = $totals["subtotal"]->getValue();
echo Mage::helper('checkout')->formatPrice($subtotal);
Run Code Online (Sandbox Code Playgroud)
欢迎任何帮助.
我一直在尝试编写一个算法,该算法采用有向的节点集(我现在表示为稀疏的有向邻接矩阵),比如A,B,C和D,当被调用时,它给了我所有包含给定路径的可能路径(例如AB或AD).节点无法连接到自身,并且最终将所有节点定向为从A流向D.
到目前为止,我已经尝试编写递归python脚本,但成功有限 - 我的图论不强(实际上我没有背景).任何人都可以提供任何帮助,我应该去的方向将不胜感激.
作为免责声明 - 这不是家庭作业(我只是尝试处理大型数据集并为某些研究建立个人图书馆),我已经看了几个小时的"类似问题",但很大程度上没有用(除了前面提到的递归python脚本).
谢谢.
我试图在SQL Server 2008的View中运行总计
这是我的桌子
BankAccounts ------------ AccountID (KEY) Name Created Transactions ------------ TransactionID (KEY) Description Credit Debit TransDate Created AccountID
这是我到目前为止的查询..
SELECT t.Created, t.Description, t.Credit, t.Debit, t.TransDate, t.TransactionID, ba.AccountID,
(isnull(t.Credit,0)-isnull(t.Debit,0))+COALESCE((SELECT SUM(isnull(Credit,0)) - SUM(isnull(Debit,0))
FROM Transactions b
WHERE b.TransDate < t.TransDate
and b.AccountID = t.AccountID),0)
AS RunningTotal
FROM Transactions t
INNER JOIN dbo.BankAccounts ba ON t.AccountID = ba.AccountID
我得到的是......
TransDate Credit Debit RunningTotal ----------------------- ---------------------- ---------------------- --------------------- 2011-10-08 20:14:00 NULL 12 49.25 2011-10-08 20:14:00 2.11 NULL 63.36 2011-10-07 20:14:00 42.25 NULL …
我得到各种String ArrayLists的总数,如[1,3,4] ......通过将它们解析为整数并得到总数.当我编写每个单独的一个时,这有用,但是当我通过传入total int值和arraylist来创建一个方法时,我总是得到一个零值.
一种方法可以节省大量时间.
public class Playing {
static ArrayList<String> list;
static int Vigor;
public static void main(String[] args) {
list = new ArrayList<String>();
vigoroustotal(list,Vigor);
public static void Listtotal(String par, int tt) {
for (String s : par) {
int i = Integer.parseInt(s);
tt += i;
}
}
Run Code Online (Sandbox Code Playgroud) 我的SQL家伙度假很长.我知道这很危险.我有桌子,加入后会给我分区域和区域分解的各种位置以及潜在的钱和获取的钱.感兴趣的列是区域/区域/潜在/已实现.大约12个顶级区域和80个区域
我如何查询数据,以便我在每个区域的变化中获得休息,其中潜在的总和实现总数以及每个区域变化的潜在总数和区域总数?
就像是:
Area1 District1 500 200
Area1 District1 200 null
Total Row 700 200
Area1 District2 200 200
Area1 District2 null null
Total Row 200 200
Area Total 900 400
Area2 District3......etc.........
Run Code Online (Sandbox Code Playgroud)
编辑代码.到目前为止,如果我每次在AreaID或DistrictID发生变化时都可以得到总数,我认为我可以得到其余部分
DECLARE @FiscalYear INT
SELECT @FiscalYear = 2014
SELECT tblFacilities.FacilityID,
tblAreas.AreaID,
tblFacilities.DistrictID,
tblFacilities.UnitName,
tblDistricts.DistrictName,
tblAreas.AreaName,
TotalSavings = (SELECT TotalSavings FROM ufn_RainbowTCReductionStrategies(tblFacilities.FacilityID, @FiscalYear))
FROM tblFacilities INNER JOIN tblDistricts ON tblFacilities.DistrictID = tblDistricts.DistrictID
INNER JOIN tblAreas ON tblDistricts.AreaID = tblAreas.AreaID
Run Code Online (Sandbox Code Playgroud) 我想在另一个函数中使用此函数.这个"addTotal"函数的作用是返回某个客户端拥有的每个bankAccount的总余额.我知道插入"返回总数"; 声明,它只获得第一个bankAccount余额.对此有何建议?
private int addTotal(ClientList clientList, String name)
{
for(int i = 0 ; i<clientList.getClientList().size();i++)
{
if(name.compareTo(clientList.getClientList().get(i).getName())==0)
{
for(int j =0;j<clientList.getClientList().get(i).getBankAccList().size();j++)
{
int total = clientList.getClientList().get(i).getBankAccList().get(j).showBalance();
total+=total;
return total; // i know here is the problem. any suggestion on this?
}
}
}
return -2;
}
Run Code Online (Sandbox Code Playgroud)