Question

I'm customizing a POS extension in preparation for vending at an off-site event.

Previously, we simply charged sales manually and went back to add the orders by hand after the fact. This POS extension will let us use our live site to sell items and then sales are properly recorded (and the existing payment methods will work).

Now I'm trying to apply special pricing to the items as they are added to the cart. The extension's code does this to add items to the cart:

$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();

Everything I have found about applying pricing is done to $item and not at the cart level. In other code, I have tried $product_model->setCustomPrice($price); and setPrice() and setOriginalPrice() but those aren't working. I feel like I'm very close to the solution.

Would someone with experience here help me get the item in context or find a way to apply the discount in the above code segment?

Thanks!

Was it helpful?

Solution

You would need to hook into an event take a look at the answer i provided here and let me know if you have any questions or come across issues:

Changing the price in quote while adding product to cart: magento

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top