私はオフサイトイベントでの販売に備えてPOS拡張をカスタマイズしています。カートの価格をプログラムで編集する(または商品追加時に割引を適用する)
以前は、手動で売上を請求し、実際に注文を手作業で追加しました。このPOS拡張機能により、ライブサイトを使用して商品を販売し、販売が適切に記録されます(既存の支払い方法が機能します)。
今、カートに追加されたアイテムに特別価格を適用しようとしています。拡張機能のコードは、これは、カートにアイテムを追加しない:私は適用価格設定について発見した
$product_model = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId());
$session = Mage::getSingleton('checkout/session');
$cart = Mage::getSingleton('checkout/cart');
$product_model = Mage::getModel('catalog/product')
->setStoreId(Mage::app()->getStore()->getId())
->load($pr_id);
if(!$product_model)
throw new Exception("Product id {$pr_id} not found");
$cart->addProduct($product_model, array('qty' => $qty));
$cart->save();
$session->setLastAddedProductId($last_pr_id);
$this->getPos()->getQuote()->collectTotals()->save();
すべては、カート・レベルで$item
に行われていません。他のコードでは、私は$product_model->setCustomPrice($price);
とsetPrice()
とsetOriginalPrice()
を試しましたが、動作しません。私はその解決策に非常に近いと感じています。
ここでの経験をお持ちの方は、上記のコードセグメントでディスカウントを適用する方法やディスカッションをお探しですか?
ありがとうございます!
ありがとう!そこに質問を明確にするように頼んだ。 –