I am using magento 1.9
version. Doing a functionality to add a product and its' option to the cart programmatically.
I have a product (id=120)
. Which have a custom option to select the multiple values ( say option=25, and option 27)
. I want to add these product and it's custom option to the cart
.
I know this functionality with single custom option value
. But here I need to custom values of an option.
Does any one help me?
在参数数组中,使用array(value_id1,value_id2...)
代替选项ID的单个值。
Well, I don't know if this is your issue.. I found a simple way of magento to handle a multi selected custom option array to pass to the cart
The standard is an array should always start from 0 index, right ? But magento will only take multi select option values array if you start it from index 2.. So for example below will work:
'options' => array( 21 => 58, 20 => 55, 11 => 28, 12 => array( 2 => 31, ), 13 => array( 2 => 32, 3 => 35, ), ),
In above example you will see option_id 13 which has multi values passed in an array, which is starting from 2nd index. this worked for me.. i hope it will work for others as well. :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.