magento - Add a product to the cart with custom option file or image -
already try following code, stuck when try add option type of file
$product = mage::getmodel('catalog/product')->load(611); $cart = mage::getmodel('checkout/cart'); $cart->init(); //the file stored in http://domain/img1.png $image= 'img1.png'; $params = array( 'product' => $product->getid(), // $product->getid() 'qty' => 1, 'options' => array( 2 => "text field here", 1 => array( 'quote_path' => mage::getbasedir() . $image, 'secret_key' => substr(md5(file_get_contents(mage::getbasedir() . $image)), 0, 20) ), ), 'options_1_file_action'=>'save_new', ); try { $cart->addproduct($product, new varien_object($params)); mage::getsingleton('checkout/session')->setcartwasupdated(true); $cart->save(); echo 'success'; } catch (exception $ex) { echo $ex->getmessage(); }
found answer not how set custom option of type "file" when adding product cart in magento?
thanks in advance :)
Comments
Post a Comment