简体   繁体   中英

Magento Add product to cart with on-fly generated product custom option

I want to add a product in cart with custom options which is not defined in product. Actually I have a options which is not exactly related to products but want to See/Link it in cart as well as checkout page.

For ex- There are my various added customers in my account which I want to purchase a same product with different qty. I defined a custom option as "Gift customer" to product, but as "Gift customer" having different values against different login users which I can not fix it.

So I want to add "Gift Customer" programmatically while adding product in cart

Hope you understand my problem.

To add custom option to items in your cart you should use

Add Custom Attribute to item - additional_options

Using Observer - checkout_cart_product_add_after

Take a look @ Magento - Quote/order product item attribute based on user input

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM