How can I save this custom value in database and get in the cart page with the custom option ?
-
When you add custom option, it is already saved in database and also shown on cart page.– Kishan PatadiaCommented Jun 5, 2017 at 12:38
-
@krishan Patadia i have to add two fields when click custom option i want to add these two field in database– Rahul KatochCommented Jun 5, 2017 at 12:40
-
Which two fields ?– Kishan PatadiaCommented Jun 5, 2017 at 12:41
-
i added one custom option and two value one is free and second is payed and i have to add two fields in payed one is option and other is textarea how i save these two fields– Rahul KatochCommented Jun 5, 2017 at 12:49
-
1@ Keyur Shah can you please tell me how i save these two attribute value i have to make one attribute and make two two value on is free and second is payed if user click in payed option and open two fields i want save these two fields with attribute value– Rahul KatochCommented Jun 6, 2017 at 11:18
|
Show 2 more comments
1 Answer
I think you should use, catalog_product_type_prepare_full_options
event because this event triggered just before the product with its custom options is converted to a quote item.
In this event you can get added product object $product
object by using,
$product = $observer->getEvent()->getProduct();
Now you can add your custom option like,
$infoOptions[] = array(
'label' => "YOUR_OPTION_LABEL",
'value' => "YOUR_OPTION_VALUE",
);
you can update this option according your requirement,
Now just add this custom option like,
Add this custom option by
$product->addCustomOption('additional_options', serialize($infoOptions));
-
1
-
keyur shah - here two products created. why this happen any idea? Commented Feb 7, 2018 at 7:12
-