Add Custom Option to Cart Without Adding to Product in Admin

custom-options

Is there a way to add a custom option to cart without first adding it to the product in the admin and saving it? I want to programatically add a note that shows on checkout below the product (just like custom options do) but I don't want to add this custom option to all products in the admin. If I can't do it like this, any suggestions? I want the info to show on emails and in the admin order view too.

I want something on cart like:

Product Name

 Custom Label: Custom Value

I have this code, but it doesn't allow adding a custom option if it doesn't already exist, so I don't know if it's possible:

$params = array(
        'product'   =>  $id,
        'qty'       =>  $qty,
        'options'   =>  array(
            1       =>  'value 1', // works cause is saved to product on edit product
            'Custom Label' => 'custom value' // doesn't work
        )
    );

    $request = new Varien_Object();
    $request->setData($params);
    $cart->addProduct($product,$request);
    $cart->save();
    Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
    $this->_redirect('checkout/cart');

Best Answer

I ended up using the code from a similar post: stackoverflow.com/questions/9862309/

Related Topic