0

I'm adding a new step in OneStepCheckout page, after Billing and before Payment, where the user can see and choose other special products just once.

But the problem is that I'm not able to add those to the cart.

In /app/code/local/Mage/Checkout/Model/Type/Onepage.php I'm adding

public function saveAddons($data){


    if ($this->getQuote()->hasProductId(113)) {
         $this->getQuote()->removeItem(113);
    }

    if ($data['newProduct'] == 1) {
        $product = Mage::getModel('catalog/product')->load(113);
        $params = array(
            'product' => 113,
            'qty' => 1
        );

        $this->getQuote()->addProduct($product, $params);
    }

    $this->getQuote()->save();

    $this->getCheckout()
    ->setStepData('addons', 'allow', true)
    ->setStepData('addons', 'complete', true)
    ->setStepData('payment', 'allow', true);

    return array();
}

There's something wrong on that piece of code. Any help would be much appreciated.

1 Answer 1

0

Instead of adding the product to the quote, I needed to add a quoteItem with that product:

$quoteItem = Mage::getModel('sales/quote_item')->setProduct($product)->setQty(1);
$quoteItem->setStoreId(Mage::app()->getStore()->getId());
$quote->addItem($quoteItem);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.