简体   繁体   English

将具有multiselect自定义选项的产品添加到magento中的购物车

[英]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.

相关问题 添加到购物车中Magento中的产品自定义选项 - Add to cart with product custom option in Magento 添加到购物车中带有magento虚拟产品的自定义选项 - add to cart with custom option for virtual product in magento Magento使用即时生成的产品自定义选项将产品添加到购物车 - Magento Add product to cart with on-fly generated product custom option 将选项值添加到产品,然后使用Magento添加到购物车 - Add option value to product, then to cart with Magento 用户将产品添加到购物车时,Magento自定义选项值和选项标题存储 - Magento custom option value and option title store when the user add product to cart Magento 2使用自定义选项以编程方式将产品添加到购物车 - Magento 2 add product to cart programmatically with custom options Magento 2在未创建购物车的情况下添加自定义选项 - Magento 2 add custom option in cart without create 我们如何在Magento中使用自定义选项类型文件将产品添加到购物车中? - How can we add in code a product to the cart with a custom option type file in Magento? 自动在magento中向新产品添加“自定义选项” - Auto add a 'Custom Option' to a new product in magento 如何在可配置产品页面上添加自定义空购物车按钮:Magento - How to add a custom empty cart button on configurable product page:Magento
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM