How to store dropdown widget(Dropdown plugin) into cart.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 年 前
Hi Community Members,

I have made one DropDown Widget (DropDown Plugin),  which is displayed on the product page.

So please help me with how to store this DroDown value in the cart, so we can see this value in the respective order in the admin side.

Thanks in advance.
3 年 前
Is there a reason why you did not use Product Attributes which are stored Automatically ?
If you used Prodct Attributes then it would be automatically displayed on the product page, in the cart and in the order?

What does the DropDown value represent ?
If you want to display the Drop down value in the Cart from a plugin then you need to make an override and new a new razor page.
If you want to store the data you can either make a new table or store it in order.CustomValuesXml
3 年 前
Hi Yidna,

Thanks for your reply.

Is this possible to bind product attributes based on customer role conditionally?
3 年 前
Not sure
You can limit a product availability to a customer role
So it follows that the Attributes defined for that Product are limited to that role

Maybe you would need to modify or override
source\Presentation\Nop.Web\Views\Product\_ProductAttributes.cshtml
3 年 前
[/i]Hi Yidna

Thanks again for the reply.

For the below statement, it is possible to give me a code example if you have.

[i]If you want to store the data you can either make a new table.
3 年 前
What version are you building ?
You can look at other plugins with data access i.e. Nop.Plugin.Shipping.FixedByWeightByTotal
or https://docs.nopcommerce.com/en/developer/plugins/plugin-with-data-access.html
3 年 前
I am using 4.2 version.

If you want to store the data you can either make a new table or store it in order.CustomValuesXml

It is possible for you to provide some code for the above things. I am new in nopCommerce so I don't have ideas about this.

Thanks
3 年 前
Creating a table to store values is an advanced topic so you need to study the example provided above

To save a value in the order this is an example where I store the Payment Receipt No.

var order = _orderService.GetOrderById(order.Id);
if (order == null)
    throw new NopException(string.Format("The order ID {0} doesn't exists", order.Id));
else
{
    var processPaymentRequest = new ProcessPaymentRequest();
    processPaymentRequest.CustomValues.Add("Payment Receipt No.", chargeInfo.ReceiptNumber);
    order.CustomValuesXml = _paymentService.SerializeCustomValues(processPaymentRequest);
    _orderService.UpdateOrder(order);
}

Note: the values saved in order.CustomValuesXml will automatically be displayed on the customer account order details page which may or may not be helpful.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.