1

I need to create an order programmatically.

I tried this code:

$params = array(
    'product' => $productId,
    'qty' => 1,
    'options[99]' =>time(),
    );
    $cart = Mage::getSingleton('checkout/cart');
    $product = new Mage_Catalog_Model_Product();
    $product->load($productId);
    $product->setSpecialPrice(250);
    $cart->addProduct($product, $params);
    $cart->save();

But it is not adding custom option value.

Also I tried this code:

$params = array(
        'product' => $productId,
        'qty' => 1,
        'options_99' =>time(),
        );

But no luck, can someone suggest?

1 Answer 1

0

Below reolved my issue,

    $params = array(
            'product' => $productId,
            'qty' => 1,
            'options' => array(
                  99 => time()
                )
            );
    $cart = Mage::getSingleton('checkout/cart');
    $product = new Mage_Catalog_Model_Product();
    $product->load($productId);
    $product->setSpecialPrice(250);

$cart->addProduct($product, $params);
$cart->save();

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.