我的价格是例如 10,00 € 这个价格是 100 g 客户可以在数量字段中添加任何 g 例如 300
magento 现在有 3000 的小计,还可以,但不适合我这里的需要。
我需要做:如果设置了价格和数量,获取小计/价格数量,设置新的小计
我可以在哪里进行修改?
非常感谢!丹尼斯
编辑 和观察者的第三次尝试(不工作 atm,没有错误,没有任何反应):
class Xyz_Catalog_Model_Price_Observer
{
public function __construct()
{
}
public function apply_quantity_order($observer)
{
$order = $observer->getEvent()->getOrder();
$pricequantity = $order->getPricequantity();
if($pricequantity != ''){
$old_sub_total = $order->getTotals();
$new_sub_total = $old_sub_total / 100;
$order->setTotals($new_sub_total);
} else {}
return $this;
}
public function apply_quantity_quote($observer)
{
$quote = $observer->getEvent()->getQuote();
$pricequantity = $quote->getPricequantity();
if($pricequantity != ''){
$old_sub_total = $quote->getTotals();
$new_sub_total = $old_sub_total / 100;
$quote->setTotals($new_sub_total);
} else {}
return $this;
}
}
XML:
<?xml version="1.0"?>
<config>
<global>
<models>
<xyzcatalog>
<class>Xyz_Catalog_Model</class>
</xyzcatalog>
</models>
<events>
<sales_order_save_after>
<observers>
<xyz_catalog_price_observer>
<class>Xyz_Catalog_Model_Price_Observer</class>
<method>apply_quantity_order</method>
</xyz_catalog_price_observer>
</observers>
</sales_order_save_after>
<sales_quote_save_after>
<observers>
<xyz_catalog_price_observer>
<class>Xyz_Catalog_Model_Price_Observer</class>
<method>apply_quantity_quote</method>
</xyz_catalog_price_observer>
</observers>
</sales_quote_save_after>
</events>
</global>
</config>