私の価格は、たとえば 10,00 €です。この価格は 100 g です。お客様は、数量フィールドに任意の g を追加できます(例: 300)
magento の小計は 3000 になりました。問題ありませんが、ここでの私のニーズには合っていません。
私がしなければならないこと: 価格と数量が設定されている場合、小計/価格数量を取得し、新しい小計を設定します
これに対する変更をどこに置くことができますか?
どうもありがとうございました!デニス
編集 とオブザーバーの 3 回目の試行 (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>