2

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');
  • Will adding a custom cart item message work for you? Message like default stock notification in the cart rigght below the item. – Amasty Jul 31 '14 at 23:22
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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