[英]Add a product with multiselect custom option to the cart in magento
I am using magento 1.9
version. 我正在使用
magento 1.9
版本。 Doing a functionality to add a product and its' option to the cart programmatically. 进行编程以将产品及其选项添加到购物车的功能。
I have a product (id=120)
. 我有一个产品
(id=120)
。 Which have a custom option to select the multiple values ( say option=25, and option 27)
. 具有自定义选项以选择多个值
( say option=25, and option 27)
。 I want to add these product and it's custom option to the cart
. 我想
add these product and it's custom option to the cart
。
I know this functionality with single custom option value
. 我知道此功能具有
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 ? 标准是数组应始终从0索引开始,对吗? But magento will only take multi select option values array if you start it from index 2.. So for example below will work:
但是,如果您从索引2开始,magento只会采用多选选项值数组。因此,下面的示例将起作用:
'options' => array( 21 => 58, 20 => 55, 11 => 28, 12 => array( 2 => 31, ), 13 => array( 2 => 32, 3 => 35, ), ),
'选项'=>数组(21 => 58,20 => 55,11 => 28,12 =>数组(2 => 31,),13 =>数组(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. 在上面的示例中,您将看到option_id 13,它在数组中传递了多个值,该数组从2nd索引开始。 this worked for me.. i hope it will work for others as well.
这对我有用。我希望它也对其他人也有用。 :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.