Magento-跟踪要回馈给谁

Magento-跟踪要回馈给谁,magento,Magento,我们有一个Magento多站点,可以将百分比返还给非营利组织,我们想做的是让客户选择哪个非营利组织或该非营利组织中的一个组来接收百分比 为了简单起见,我们认为允许客户输入一个名为“回馈给{non-profit name}”的折扣代码(但购买时没有实际的美元金额减去,或者可能只有一便士,我不认为你可以有一个0到一个折扣代码),然后在内部我们知道将百分比回馈给该非营利组织 这样做似乎有点奇怪,最好是在最后减少“无利润”,但我们不确定如何创建它 有没有人对简单的方法有什么建议 提前谢谢 您可以在报价/

我们有一个Magento多站点,可以将百分比返还给非营利组织,我们想做的是让客户选择哪个非营利组织或该非营利组织中的一个组来接收百分比

为了简单起见,我们认为允许客户输入一个名为“回馈给{non-profit name}”的折扣代码(但购买时没有实际的美元金额减去,或者可能只有一便士,我不认为你可以有一个0到一个折扣代码),然后在内部我们知道将百分比回馈给该非营利组织

这样做似乎有点奇怪,最好是在最后减少“无利润”,但我们不确定如何创建它

有没有人对简单的方法有什么建议


提前谢谢

您可以在报价/订单模型中添加一个属性,然后在购物车级别使用适当的值填充该属性?这是我们对过去构建的附属模块所做的思考

当客户从购物车移动到结账时,您需要一个自定义控制器来获取值,这意味着您还需要将
cart->checkout
步骤设置为表单提交,而不是直接链接

然后,在月底,您需要对集合运行一个报告,其中包含以下内容:

// I've added a * in the SELECT because I'm not sure of the attribute names off the top of my head :)
$collection = Mage::getModel('sales/order')->getCollection()
    ->addAttributeToSelect('*')
    // Make sure the orders are in the correct date range
    ->addAttributeToFilter(...)
    // Make sure the orders are in a valid state, e.g. processing, pending, complete, etc..
    ->addAttributeToFilter(...)

$donation_total = array();
foreach ($collection as $order) {
    // You'll have to investigate the attribute values for these
    $charity = $order->getData('charity_attribute_code');
    $order_total = $order->getData('order_total_attribute_code');

    if (!isset($donation_total[$charity])) {
        $donation_total[$charity] = 0;
    }

    $donation_total[$charity] += $order_total;
}

print_r($donation_total);
通过在查询中使用适当的
SUM()
ing,可以提高效率